Skip to main content

Full text of "Dr. Dobb's Journal - Vol 5"

See other formats


Dr. DoBB'S ToURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


A Reference Journal for Users of Home Computers 


volume Five 



(ijS The People’s Computer Company Series 























Dr. DoBB'S JoURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


)ine (Computers 


ve 


ts The People’s (Computer Company Series 


run HAYDEN BOOK COMPANY, INC. 
I H 1 Rochelle Park, New Jersey 












Acknowledgments 

Many thanks to all authors and readers who have contributed articles, ideas and il¬ 
lumination to the pages of Dr. Dobb's Journal. Many of the items found in these pages 
would have been inaccessible to the microcomputer hobbyist, or available only at great 
expense, had their creators not felt that immersion in the critical caldron of the comput¬ 
ing community were more important than financial compensation. 

Much gratitude also goes to the Friends of PCC. They are a large! and loose-knit band 
united by such ephemeral and fleeting moments as potluck dinners, spontaneous music 
in the parks, coffee house synergisms,and occasional moments of genius. These Friends 
keep us sane, and make microcomputing human. 


Cover: Linocut of griffin by Wendy Palmer. The mythological griffin, half lion and half 
eagle, has long stood as an enemy of ignorance. 

Book production: Wendy Palmer and Associates, 

Palo Alto, California 

Index by Julie Anton, Palo Alto, California 
Full-page computer art by David Dameron. 


ISBN 0-8104-5492-0 

Copyright© 1982 by People's Computer Company. All rights reserved. No 
part of this book may be reprinted, or reproduced, or utilized in any form or 
by any electronic, mechanical, or other means, now known or hereafter invented, 
including photocopying and recording, or in any information storage and 
retrieval system, without permission in writing from the Publisher. 

Printed in the United States of America 
123456789 PRINTING 


82 83 84 85 86 87 88 89 90 


YEAR 



Dr. Dobb’s Journal 

of Computer Calisthenics 6 Orthodontia, 
Volu me Five 








Editors Preface 


And where will it lead? 

That was the question posed in Dr. Dobb’s Journal, Volume III. It was a time when 
a body of microprocessor knowledge had been accumulated, but the number of persons 
with access to and understanding of that knowledge was extremely small. Manufacturing 
techniques were being perfected, but costs were still high. The bandwagon was rolling, 
but no one was holding the reins. 

At least, that's the way it appeared. 

Dr. Dobb's Journal was born in a time of chaos. Some fantastic new machines had 
been bred in basement test tubes. The problem was how to optimize their potential? 
Then a handful of radical-thinking idealists produced Tiny BASIC and a publication in 
which to communicate the good news. More good things have been cropping up since 
then, and now the magazine serves as a broad forum for the micro community. 

To answer the original question, the revolution in microcomputing will lead when¬ 
ever we direct it. In the beginning, when there was very little momentum to the personal 
computing movement, a handful of movers and shakers could do most of the guiding. 
They saw to it that the power of small computers would indeed rest in the hands of indi¬ 
viduals instead of with corporations or government. 

The movement has, of course, gained gigantic proportions as more and more people 
have begun to grasp its significance and to reap its benefits. With its present inertial 
force, many more guiding hands are needed to keep it on track, to preserve the original 
dream. Dr. Dobb's Journal has kept pace by opening its pages to new authors, more free 
thinkers and guiding lights. 

The proliferation of hardware and software has required that we grow to meet the 
challenge presented by our own idealism. In order to keep alive the concept of personal 
computing power, we must riot only keep stride with technology, we must shape the fu¬ 
ture. We must be in the forefront, developing systems tools and refining the programming 
languages,techniques and very concepts which will influence what small computers will 
be able to do, and for whom 

Lest we become too grandiose, too filled with the importance of our mission, we 
have Doc Dobb's humbling influence. Always ready with a bit of irony and keen wit, 

Doc sees to it that the pages of his journal remain open as a forum and that they do not 
become a soapbox dominated by any particular group or prejudice. His philosophical 
outlook is often expressed in such homilies as "Let a thousand lilies bloom . .." and "If 
it's grist for the mill, we'll grind it." That view is tempered by another of Doc's sayings, 
"The quick brown fox keeps his tail out of the lazy dog's mouth." 

That is Doc's way of reminding us not to be influenced by any special interests. Its 
broad, objective approach has enabled Dr. Dobb's Journal to serve the world as the lead¬ 
ing publication in its field. But more than a publication, it is a style of thinking which 
makes technology work for humans — and not the other way around. 


Marlin Ouverson 
Editor 




Contents 


VOLUME 5, NUMBER 41, 1980 


2 The History of CP/M Gary A. Kildall 
4 An Overview of CP/M Compatible Software Steve Newberry 
11 Go: A Utility Command Under CP/M Anthony Skjellum 
13 Linking CP/M to George Morrow’s Cassette Interface Wayne Miller 

15 Implementing a Tiny Interpreter with a CP/M Flavored C Les Hancock 

24 ALS-8 to CP/M File Converter Hollis Frampton 
26 Converter Listing 

29 CP/M and CDOS Program Compatibility Jim Warner 

32 Changing SPI Formatted Programs to CP/M Compatible Text MarkM. Zeiger 

34 CP/M-Pen, Pen-CP/M Rod Hallen 

37 Programming Pastimes and Pleasures Charles Wetherell 


VOLUME 5 , NUMBER 42, 1980 


46 TI 9900 Fully Reentrant Formatter Operating Under TIPMX Norman V. Walters 

55 North Star Disk STOIC 

56 Feature Enhancements for ADM-3A John Wakerly 

59 A Table-Driven Assembler on CP/M Darrel J. Van Buer 

67 A User Interface to APPLE-II Program Renumbering DeWitt S. Brown 

73 Converting Binary to Decimal Dennis Allison 

75 UCSD PASCAL Terminal Parameters Ronald G. Parsons 

77 Programming Pastimes and Pleasures Charles Wetherell 

79 A Microprocessor-Assisted Graphics System Griffith Hamlin, Jr. and Thomas Crockett 


VOLUME 5, NUMBER 43, 1980 


88 Mathematical Typography Donald E. Knuth 

104 SYMBOL: Generating Symbol Table Alpha Listing on the H8 William W. Moss 
108 TI9900: Fully Reentrant Formatter Operating Under TIPMX, Part 2 

Norman V. Walters 

121 Can You Afford to Retire? David E. Raeside 

122 A Hex Keyboard with Applications for the 1802 ELF Martin Bronstein 






VOLUME 5, NUMBER 44, 1 980 


130 An Introduction to Algorithm Design Jon Louis Bentley 

141 All the Secrets You Ever Wanted About Poly 88 BASIC Marvin A. Konopik 

142 Meta II: A Syntax-Oriented Compiler Writing Language D.V. Schorre 

151 A Northstar BASIC Cross-Reference Tool Titus Purdin 

159 Some Useful Subroutines for a Z-80 Assembler John W. Carter 
164 A Fast Fourier Transform for the 8080 Robert D. Fusfeld 
169 Algorithm: A Monthly Algorithm Column Dennis Alliscn 


VOLUME 5, NUMBER 4 5, 1 980 


176 A Small C Compiler for the 8080’s Ron Cain 

191 The C Programming Language D. M. Ritchie, S. C. Johnson, M. E. Lesk, 
B. W. Kernighan 

201 Structured Programming, C and tiny c Tom Gibson and Scott Guthery 

205 Help with OSI’s CP/ M Lee Barker 

207 Algorithm: A Monthly Algorithm Column Dennis Allisc n 

209 MITS DOS - Disk to Disk Copy Routine Andrew Bender 

216 An 8080 to Z80 Translator System Robert W. Dea 


VOLUME 5, NUMBER 46, 1 980 


226 A Survey of Computer Networks Art Kleiner 

230 The Personal Computer Network (PCNET) Project Dave Caulkins 

234 MCALL-C: A Communications Protocol for Personal Computers Tim J. Pugh, Jr. 

239 Electric Phone Book 

240 On Modems William Smith 

242 Adding Arrays to FORTH Ralph Deane 

243 ROM Byte-Finder for the Apple II Stephen E. Bach 

244 The Errata of Computer Programming Donald E. Knuth 

257 Random Ruminations of Networks of the Future Jonathan Sachs 

259 Displaying 2 Columns with North Star O. K. Hudson 

260 A Versatile Memory Dump in BASIC Hal Knippenberg 

261 Conversion: ALS-8toCP/M Edward Elizondo 

264 Algorithm: A Monthly Algorithm Column Dennis Allison 


VOLUME 5, NUMBER 4 7, 1 980 


272 ZX65: Simulating a Micro Richard M. Kruse 

279 Harlie: A “No Programming” Computer J. L. Lawrence and Jay Sprenkle 
282 Clean Starts for COSMAC 1861 Video Output Gary H. Price 

284 PCNET Notebook Dave Caulkins 

285 Programming Pastimes and Pleasures Charles Wetherell 

287 Z-80 Circuit for the H-8 Ted T. Stowe 

289 Indirect Addressing for the 8080 and Z-80 Anthony Skjellum 






VOLUME 5, NUMBER 4 8, 1 980 


312 A Runtime Library for the Small c Compiler Ron Cain 
324 Thoughts on Small Systems and Monitors H. T. Gordon 
330 Programming Pastimes and Pleasures Charles Wetherell 

332 Polymorphic Tallis to the H-14 Printer Marvin Konopik 

333 A Note on 6502 Indirect Addressing W. D. Maurer 
339 Northstar X-Reference Tool John Holtrichter, Jr. 

341 Hardcopy Device Driver Programs for CP/M Steve Willoughby 

345 The Love Program Gary Gaugler 

348 A Problem with Logic Probes David N. Bertollo 

349 An Error-Correcting Record Linking Method Sylvan Rubin 

350 Algorithm: A Monthly Algorithm Column Dennis Allison 


VOLUME 5, NUMBER 49, 1 980 


356 Even Further with Tiny BASIC Robert Hudson 
364 Microcomputers as They Should Be Olav Naess 
367 CP/M to UCSD PASCAL File Conversion Tor Sj0wall 

371 Extended Source-Text Area and Label Capability for SC/MP N1BASM W. F. Long 
373 Opcode Design: 9 or 16 Bits? H. T. Gordon 
375 MFT: A Multiple File Transfer Utility Lawrence E. Hughes 

382 A Cross Reference Program for Northstar BASIC Larry Hudson 

392 Solution of Three First Order Differential Equations with an SR-52 Programmable 
Calculator S. Andrew Yakush 


VOLUME 5, NUMBER 50, 1980 


400 N-Logs: A New Number Language for Scientific Computers Keneth A. Simons 
406 Las Vegas Super Slot: A CP/M Game Machine Program Using Flashwriter I Graphics 
David W. Friedman 

418 Quick-Key: A North Star BASIC Statement Generator Leonard E. Garcia 
423 TUTOR: A Foreign Language Vocabulary Trainer Gary D. Gaugler 

425 Interfacing the WH14 Printer to Your Microcomputer’s Serial Port Is Simpler Than You 

Think Lacliman Sippy 

426 Program Documentation Freeman L. Moore 

431 MOVIT William D. Loughman 

432 6800 and 1802 Cross-Assembler for CP/M William C. Colley, III 

434 A Proposal on Strings for FORTH Ralph Deane 

439 A 6800 Video Display Program Kenneth Drexler 

447 Index 








About 

People’s Computer Company 

People’s Computer Company, the publisher of Dr. Dobb’s Journal, was founded in 1972 as 
a non -profit source of education and information about computers. Bob Albrecht, one of the 
founders, explained the inspiration for the company in the first issue of the PCC Newspaper ■. 

“Computers are mostly used against people instead of for people, used to control people 
instead of free them. It’s time to change all that. We need a People’s Computer Company.” 

PCC has initiated a number of successful service-oriented projects in order to empower 
people to take more active part in a society in which computers are a significant factor. It has 
published a newspaper, three magazines, and several books on home/personal computing. It has 
also operated a neighborhood computer center, a mail-order bookstore, a computer van, and has 
sponsored telecommunications research (PCNET). 

The main emphasis of the company has been small, personal computers - the kind anyone 
can learn to use and many families can afford. ComputerTown, USA! is a major project begun 
with financial assistance from the National Science Foundation. It provides a model of how to 
make everyone in a small- to medium-size community “computer literate.” It shows how to use 
local resources - public libraries and museums, schools, community centers, local businesses, and 
donations of hardware and volunteer time - to give children and adults direct, hands-on ex¬ 
perience with computers. ComputerTown shares its experience and resources in a newsletter and 
via various other services. Affiliates already exist in the United Kingdom, Europe, Australia, and 
across the United States. 

Dr. Dobb’s Journal was PCX’s second publication. The first issue was published in 1976 to 
provide a short-term forum for the newly written Tiny BASIC language. Reader response was so 
strong that it went into monthly production immediately. It has since led the way by focusing on 
important advances, printing public domain software, and fostering vital reader interaction on 
technical matters. Readers generally describe their experience with computers as intermediate to 
extensive. About ten percent of them live outside the United States. Volumes One through Five 
cover the first five years of DDJ’s publication, and are available in matching, bound volumes 
from Hayden Book Company. 

People’s Computer Compsiny grew from the same roots as the Whole Earth Catalog. They 
were offshoots of the Portola Institute of Menlo Park, California, an organization investigating 
and promoting the idea of alternative technology. For the founders of PCC, this meant learning 
to use computers as a liberating force in society. 

To make these ideals manifest, it has been necessary to think far ahead, to be creative and 
innovative. PCC published the first personal computing periodical in 1972, a time when the 
technical community at large found the thought of “personal” computers preposterous. Shortly 
thereafter, the company produced the world’s first book of computer games. Now in its sixth 
printing, What to Do After You Hit Return has been a model for many other publishers. 

The PCC staff members have a wide variety of personal and professional interests and 
experience. Their work stems from a conviction that the personal computing revolution is of 
tremendous significance, and that familiarity with computers fosters confidence and greater 
control over one’s life. 

People’s Computer Company 
Box E 

Menlo Park, CA 94025 




Dr. DoBB'S JoURNALof 

COMPUTER 

(Calisthenics ^ Orthodontia 

Running Light Without Overbyte 

Number 41 January 1980 Volume 5, Issue 1 

A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 

All - CP/M Issue! 


The Evolution of an Industry: One Person’s Viewpoint 6 

Gary A Kildall 

Overview of CP/M Compatible Software 8 

Steve Newberry 

Implementing a Tiny Interpreter with a CP/M-Flavored C 20 

Les Hancock 

CP/M-Pen, Pen-CP/M 39 

Rod Hallen 

GO: A Utility Command Under CP/M 16 

Anthony Skjellum 

CP/M and CDOS Program Compatibility 34 

Jim Warner 


... and, as always, even more 


1 





THE EVOLUTION OF AN INDUSTRY: 

ONE PERSON’S VIEWPOINT 





BY GARY A. KILDALL 

Digital Research 
P.O. Box 579 

Pacific Grove, California 93950 


1973.... 

I was sitting quietly at my desk when Masatoshi Shima 
hurried into my office at Intel and asked me to follow him to 
his laboratory down the hall. In the middle of his work bench, 
among the typical snaggle of jumpers, oscilloscopes and multi¬ 
meters, sat a binocular microscope with spider-leg probes, 
all of which were subjecting a minute piece of silicon to help¬ 
less investigation. I peered through the microscope at the en¬ 
larged regular patterns with particular interest. As a consult¬ 
ant, my job was to design and develop certain software tools 
for Intel. One was Interp/80, a program which simulated 
Intel’s newly evolved 8080 microprocessor to be used by Intel 
customers on timesharing systems. As I searched for some¬ 
thing recognizable, I hoped my simulation resembled the 
operation of Shima’s first 8080 chip which had finally come to 
life. 

My proposal to Intel had been simple: I would provide 
them with a language, called PL/M, to replace serious systems 
programming in assembly language. The compiler would 
first be written in FORTRAN for operation on timesharing 
computers and “cross compile” to the eight-bit processors. 
Next, we would write a PL/M compiler in PL/M and “boot¬ 
strap” from the timesharing computer to a resident compiler 
operating on Intel’s new Intellec-8 development system. The 
first part was complete. PL/M cross compilers and Interp 
simulators were implemented for the now-best-forgotten 
8008, as well as the 8080. Programs had been written and 
tested by Intel’s software group, consisting of myself and two 
other people, and we were ready for the real machine. Things 
were going well: the resident compiler would be the next 
step. 


Unfortunately, nearly all small computer systems in 1973 
used paper tape as the backup storage device, with the ubiqui¬ 
tous model 33 Teletype serving as the nerve-shattering I/O 
device. It was readily apparent that resident development 
systems could r ot compete with timesharing services when 
considering throughput, resources, and services. Still the 
notion of a personal computer for software development in¬ 
terested everyone. 

I became intrigued with a new device, called a floppy disk, 
which, though designed by IBM to replace punched cards, 
appeared to have much greater potential. The device was 
ideal: over 3,000 times the data rate of a Teletype, each $7 
diskette could randomly access the equivalent of 2000 feet 
of paper tape. Best of all, the drive was priced at a low $500. 
Due to a slight problem of undercapitalization, I found this 
incredibly low price still a bit high. At that time, a smallish 
company called Shugart Associates was in operation a few 
miles up the road from Intel. Dave Scott, then marketing 
manager at Shugart Associates, donated one of their 10,000- 
hour test drives to the cause, complete with wom-out bearings 
and a bearing repair kit. It was only later, as I sat in my 
office at home, staring at the naked disk drive, that I realized 
I had no cabinet, no cables, no power supplies, no controller, 
and most distressing of all, no hardware design experience. 
To make matters worse, no controllers were commercially 
available, even if 1 could afford one. 

After several abortive attempts at constructing an inter¬ 
face to my Intellec-8, it became readily apparent that my 
efforts would be better directed toward the software aspects. 



Page 6 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 41 

2 





Between projects I put together the first CP/M file system, 
designed to support a resident PL/M compiler. The timeshar¬ 
ing version of PL/M, along with the Interp simulator, allowed 
me to develop and checkout the various file operations to the 
level of primitive disk I/O. A simulation is, after all, just a 
simulation, and the inability to make that 10,000 hour drive 
work for just one more hour was frustrating. 

Shortly thereafter, in the fall of 1974, John Torode be¬ 
came interested in the project. I offered as much moral 
support as possible while John worked through the aberra¬ 
tions of the IBM standard to complete one of my aborted 
controllers. Our first controller was a beautiful rat’s nest of 
wirewraps, boards and cables (well, at least it was beautiful 
to us!) which, by good fortune, often perfoimed seeks, reads, 
and writes just as requested. For agonizing minutes, we loaded 
the CP/M machine code through the paper tape reader into the 
Intellec-8 memory. To our amazement, the disk system went 
through its initialization and printed the CP/M prompt at the 
Teletype. 

Anyone who has brought-up CP/M on a homebuilt com¬ 
puter has felt this moment of elation. A myriad of connections 
are properly closed, bits are flying at lightning speeds over 
busses and through circuits and program logic, to produce 
a single prompt. In comparison to our paper tape devices, 
we had the power of a S/370 at our fingertips. A few nervous 
tests confirmed that all was working properly, so we retired 
for the evening to take on the simpler task of emptying a 
jug of not-so-good red wine while reconstructing battles, 
and speculating on the future of our new software tool. 

In the months that followed, CP/M evolved rather slowly. 
Intel was experiencing enormous growth and all software 
development was halted while new mangement structures 
were instituted. Intel expressed no interest in CP/M, nor in 
continuing any resident compiler work. Nearly two years 
passed before Intel again took interest in resident software 
tools, with their introduction of the ISIS operating system 
and later, the resident PL/M-80 compiler. 

Meanwhile, John Torode redesigned and refined our origi¬ 
nal controller and produced his first complete computer 
system, marketed under his company name, Digital Systems 
(which later became Digital Microsystems). The first com¬ 
mercial licensing of CP/M took place in 1975 with contracts 
between Digital Sytems and Omron of America for use in 
their intelligent terminal, and with Lawrence Livermore Lab¬ 
oratories where CP/M was used to monitor programs in the 
Octopus network. Little attention was paid to CP/M for about 
a year. In my spare time, I worked to improve overall facilities, 
and added an editor, assembler, and debugger which were 
predecessors of the current ED, ASM, and DDT programs. 
By this time, CP/M had been adapted for four different con¬ 
trollers. 

In 1976, Glenn Ewing approached me with a problem: 
Imsai, Incorporated, for whom Glenn consulted, had shipped 
a large number of disk subsystems with a promise that an 
operating system would follow. I was somewhat reluctant to 


adapt CP/M to yet another controller, and thus the notion of 
a separated Basic I/O System (BIOS) evolved. In principle, 
the hardware dependent portions of CP/M were concentrated 
in the BIOS, thus allowing Glenn, or anyone else, to adapt 
CP/M to the Imsai equipment. Imsai was subsequently li¬ 
censed to distribute CP/M version 1.3 which eventually 
evolved into an operating system called IMDOS. 

By coincidence, Jim Warren and I were both consulting 
at Signetics Corporation during this time. Jim was then the 
editor of DDJ, and pushed for sale of CP/M to the general 
public. There was, at the time, a pervading paranoia among 
software vendors who felt that any and all loose software 
would be immediately “ripped-off ’ by this immoral group of 
computer junkies. Jim’s faith in the industry, however, led 
me to introduce the CP/M 1.3 system for sale on the open 
market at $70 per copy. In the months that followed, the 
nature of the computer hobbyist became apparent. In most 
cases he was, like myself, in the computer industry and merely 
wanted a personal computer for his own endeavors. CP/M 
gradually gained popularity through a “grassroots” effect 
and, to the amazement of the skeptics, the rip-off factor 
was practically nil. A new company called Digital Research 
was formed to support CP/M, develop new products, and 
provide administrative functions. 

It’s been nearly three years since CP/M’s initial introduc¬ 
tion, with several revisions and improvements. Although floppy 
disks maintain their popularity, CP/M 2.0 is now offerred 
to manage larger capacity hard disks which are becoming 
more readily available. Customer needs and demands have 
also led to the recent introduction of MP/M, a CP/M compat¬ 
ible multiterminal multiprogramming system for more so¬ 
phisticated applications. 

More important, however, is that CP/M provides a manu¬ 
facturer independent basis for an evolving software market. 
We all know that software is expensive to develop and support, 
with numbers quoted in the hundreds of thousands of dollars 
over the product lifetime. In a classical computer market¬ 
place, these costs are amortized over a few installations, re¬ 
sulting in seemingly outrageous prices. Active CP/M users, 
however, number in the tens of thousands and can be reached 
through any number of popular magazines. Thus, marketeers 
reduce their prices substantially to interest a much larger 
customer base. Software is sold profitably as an independent 
commodity by a large number of responsible companies, and 
the benefits to the consumer are clear. Competition forces 
low prices and quality control, with selection among a wide 
variety of software products. Currently, CP/M compatible 
products range from word processing programs through bus¬ 
iness systems to a variety of language processors for BASIC, 
FORTRAN, COBOL, PASCAL, and others. All are priced 
in the $100 to $700 range. The future is, without doubt, 
optimistic for producers and customers alike. 


Number 41 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 

3 



An Overview 


W* 

I s 

I * '• 


Of CP/N 
Compatible 
Software 


• -■ 


BY STEVE NEWBERRY 
NEWBERRY MICROSYSTEMS 
24225 Summerhill Ave 

Los Altos, CA 94022 CP/M User’s Group Software 

Most user’s group libraries represent a spectrum of program¬ 
ming interests and capabilities. The CPMUG library is no 
exception. Most of the programs fall into one of four 
categories: 

1. Utility programs other than language facility programs; 

2. Language facility programs, e.g., compilers, assemblers aid 
interpreters; 

3. Specialized device drivers which, e.g., interface a modem 
board or a TVT controller or a printer to the system in 
question; and, 

4. Recreational programs, games. 

The following programs are available from CP/M User’s 
Group, 164 West 83rd Street, N.Y.C. 10024. The Price is 
$8.00 per 8" floppy disk for domestic mailings and $12.00 
foreign. CPMUG membership costs $4.00, and includes a 
catalog of the library. As of this date (Nov 14, ’79) there 
are 33 volumes iri the library. The diskettes will be referenced 
in the sequel by the notation ‘x.y’ which means “Volume x, 
program y”. Thus ‘XREF.ASM (8.27)’ refers to program 
#27, of Volume #8, called XREF.ASM. The organization 
of the volumes recognizes the difference between games and 
non-games, so if you decide to purchase a volume (diskette) 
for one or two of its programs, there is a good chance that the 
rest of the volume will be of some interest as well. 

Volumes 1, 6, 8, 14, 15, 16, 18, 19, 24, 25 and 29 are 
primarily of the first and third categories: general utilities and 
specialized device drivers. Working backwards through this list 
(to get the most recently updated versions), we find: 

Page 8 Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 Number 41 

4 


Steve Newberry is a graduate of Stanford University. A 
member of ACM since 1966, member of the IEEE Computer 
Society, he is an independent consultant, specializing in 
contract programming and documentation. 

Introduction 

One of the reasons I use and recommend CP/M is that there 
is a lot of very good software that runs under it. In what 
follows I will give a necessarily sketchy overview of some 
packages of which I have knowledge. I make no attempt to be 
either complete or unbiased. There is only one computer game 
that I care about, The Greatest Game Of All: PROGRAM¬ 
MING! Therefore, most of the packages that follow will be 
found to reflect that outlook. 

NON-COMMERCIAL SOFTWARE 

By non-commercial I mean either public-domain or copy¬ 
righted but distributed very inexpensively. 





UNLOAD.ASM (29.23) This is the CP/M version of the 
ISIS OBJHEX utility which takes a COM file (binary load 
module) and converts it to hex. This is a VERY useful tool, 
Since CP/M lacks a linking loader. The CP/M utilities DDT and 

save do, however, enable you to load (typically in low 
memory) several COM (or HEX) files contiguously, to link 
these manually (i.e., by patching in the link; addresses), and 
then to SAVE the linked memory image to a COM file 
origined at lOOh. Using UNLOAD, you can convert the COM 
file to hex and then, again using DDT, relocate the HEX file 
to any desired location. Warning: Only the source of 
UNLOAD is given, and the Digital Research Macro assembler 
is required for assembly (but you ought to have that anyhow). 
This program alone is worth the $8.00, but there’s lots of 
other good stuff on the volume. 

COPY.ASM (1,3 and 25.17) A track-to-track diskette 
copying routine (the second version is for Tarbell controller) 
which is very fast and convenient to use. 

FORMAT.ASM (25.18) Initializes a diskette, requires 
Tarbell controller. 

DUMP.COM (24.2) Updated version of (14.6). Allows 
you to look at the contents of a diskette by file, by track, by 
sector or by group (the sequence of sectors used by CP/M in 
allocating disk space to a file), and allows you to directly alter 
any byte on the disk. Used to recover inadvertently ERAsed 
files or to recover (sometimes!) files w'tiich have been 
otherwise lost. An invaluable tool! Three cheers for Sam 
Sinser, the man who wrote it. Includes source code. 

XDIR.COM (24.11) Another Sam Sinser goodie, this 
prints out the directory of the indicated diskette, alphabetical¬ 
ly sorted, formatted so that it all falls on a single screen 
display, and tells you how much space is left. Try it, you’ll 
love it. 

BYTEMOV.ASM (8.7) Driver program for either 
Cromemco Bytesaver or Piiceon Program Saver from boards. 
Ve ry elegantly programmed by Jeff Shook. 

XREF.ASM (8.27) Use this to convert the assembly 
listing from ASM or MAC (the Digital Research assemblers) to 
a fully CROSS-INDEXED listing. An invaluable aid in docu¬ 
menting (and debugging) assembly code programs. 

COMPARE.ASM (6.4) Compares two files, tells you 
WHERE they differ (if they differ) and how long they are (if 
they don’t). This is the sort of program, that you don’t use 
often but that you’ll sell your soul to have when you DO need 
it! (Like when PIP tells you that a filecopy has aborted on a 
VERIFY error but won’t tell you WHERE—it KNOWS, but it 
won’t tell—at such times COMPARE is a godsend.) 

IDIR.COM (1.18) 

ICOPY.ASM (1.17) Given an ISIS diskette, you can (a) 
find out what is on it, and (b) copy what is on it to CPM 
diskette. NICE! 


Dr. Dobb's Journal of Calisthenics & 


The above programs represent only a small fraction of the 
utilities in the CPMUG library, but they are some of the ones 
that I have on my system disk and use all the time. 

Volumes 2, 4, 5, 7, 10, 11, 12, 16, 23, 30 and 31 are 
primarily devoted to the second category,i.e., language facility 
programs. 

LLLBASIC.ASM (2.1 and 10.1) 

LLLBASIC.COM (2.2 and 10.2) 

LLLFP.ASM (2.4 and 10.3) Lawrence Livermore Lab 
BASIC is in the public domain. The later versions are to be 
preferred. 

TEMYBAS.COM (2.8 and 11.7) Lichen Wang’s (public 
domain) Palo Alto Tiny BASIC, patched for CP/M SAVE and 
LOAD, with full documentation (2.9 and 11.8). The later 
version is to be preferred. 

BASIC.COM (30.5) 

RUN.COM (30.7) 

FPCONV.SRC (29.24) 

FPDATA.SRC (29.25) 

FPDMT.SRC (29.26) 

FPPKG.SRC (29.27) 

TRAN.SRC (29.28) Gordon Eubanks’ BASIC-E is the 
best BASIC in the public domain. It is a semi-compiled BASIC 
and is a precursor of the very successful CBASIC by the same 
author (Volume 30 also contains the PL/M source if you care 
to see how he did it). BASIC-E includes the transcendental 
functions, string manipulation and CP/M file I/O. Floating 
point arithmetic numbers are represented to slightly better 
than seven digits of significance. Variable length strings and n- 
dimensional arrays are both dynamically allocated. Line 
numbers are required only when targeted by GOTO or 
GOSUB. Identifiers may be any length and the first 31 charac¬ 
ters are significant. Execution is rather slow: the canonical 
“FOR 1=0 TO 10000: A=5: NEXT I: END” takes about two 
minutes and ten seconds to execute. A manual used to be 
available from Digital Research. 

BASIC/5.ASM (11.1) 

BASIC/5.COM (11.2) 

BASIC/5.DOC (11.3) This is Processor Technology’s 5k 
BASIC adapted for disk. An alternative to LLL BASIC, 
approximately the same size, but different flavor. Not in the 
public domain. 

PILOT Volumes 7 and 12 are devoted to John Stark¬ 
weather’s masterpiece; the former is for Intel MDS, the latter 
for CP/M. If you are interested in writing Computer Aided 
Instruction programs, then this is the language of choice — 
it was designed for precisely that purpose. It can be EASILY 
learned by children in kindergarten or by people who “hate 

Orthodontia, Box E, Menlo Park, CA 94025 Page 9 

5 


Number 41 



computers.” PILOT is in the public domain. Persons wishing 
to obtain further information on PILOT would probably get 
pointed in the right direction by Gregory Yob.P.O. Box 354, 
Palo Alto, CA 94301, Telephone (415) 326-4039. 

Z80ASM The Z80ASM package (16.15 through 16.21) 
includes a running Zilog-mnemonics 8080/Z80 cross-assem¬ 
bler, source code for same, and some documentation. 

MACASM.COM (16.8) This is a short macro assembler 
(no source) with a small bug which could be rapidly located by 
the DDT II debugger (see below in the commercial section). 

ASMX.COM (16.1) This is another 8080/Z80 cross- 
assembler (no source), recognizes extended-Intel mnemonics, 
and is extensively documented in file VOLUME16.DOC and 
(17.11). 

STOIC Volume 23 is devoted to STOIC, a dialect of 
FORTH which is well-suited to interactive real-time control 
systems. The system includes a file handling system, an editor, 
an interrupt handler, a rich assortment of floating and fixed- 
point arithmetic routines and “much, much more.” WARN¬ 
ING: Learning to program in STOIC (or FORTH) is a non¬ 
trivial undertaking. Although its proponents regard it as a high- 
level language, it is in fact a structured macro-assembly 
language for a virtual stack machine. The experienced systems 
hacker will take it in stride, particularly if he has a background 
in assembly programming a zero-address machine, but the 
neophyte may find it hard going at first. 

PROCSELF.ASM (18.7) The source code for the classic 
“Processor Technology Software #1”. A small, fast, dumb 
assembler for non-disk systems, primarily of historical interest 
as the first public-domain software for 8080 available to the 
general public. Back in 1975, it and Microsoft BASIC were 
almost the only systems software available for the 8080. Rest 
in peace, old friend. 

RATFOR.COM (26.4) This is a preprocessor which 
translates a nicely structured language (called RATFOR) into 
ANSI Fortran. It is extensively documented in the classic text 
“Software Tools”, by Kernighan and Plauger. Some slight 
amount of editing is required to reconcile the emitted 
FORTRAN declarations to the conventions recognized by the 
Microsoft FORTRAN compiler. Although I no longer 
remember the specifics, a couple of macros in ED does the job. 
I’ve done it myself—it’s no big deal. 

ALGOLM.COM (28.10) 


good news: ALGOLM, ALGOL-60 and PASCAL are 
fundamentally just variant dialects of the same language, and 
therefore conversion of programs from one dialect to the other 
is, in the general case, largely a matter of reconciling the 
declaration-formats. Since there is a prodigious amount of 
PUBLISHED software in ALGOL-60 and in PASCAL, it 
follows that ALGOLM is not merely elegant (which certainly 
it is), but REALLY useful as well! Here are some of the 
characteristics of ALGOLM: 

Three types of variables, signed integer, signed decimal and 
string. Decimals may be declared with up to 18 digits of 
precision and strings may contain up to 255 characters. 
Decimal precision and string length may be represented as 
integer variables which are assigned actual values at run time. 

Arrays may be of type integer, decimal or string, may have 
up to 255 dimensions, and dimension bounds may be 
represented as integer variables which are assigned actual 
values at run time. 

Control structures are: BEGIN, END, FOR, IF THEN, IF 
THEN ELSE, WHILE, CASE and GOTO. 

BEGIN/END blocks may be nested to nine levels. Variables 
declared within a given BEGIN/END block are only accessible 
from within that block, and run-time storage space for such 
variables is de-allocated upon exit from that block. 

Functions and procedures may take parameters (call-by- 
value only) and may be called recursively. 

ALGOLM is semi-compiled and therefore both compact 
and reasonably fast in execution. (The canonical benchmark 
ran in one minute and five seconds.) 

The ALGOLM package is well documented and there are a 
number of sample programs. 

TBASIC The complete package consists of Volumes 31 
and 32. TBASIC is said to be “upward compatible” to Micro¬ 
soft 8k (Release 4.0), and is very well documented. The editor 
is a vast improvement (to my taste) over that in Microsoft 
BASIC, and is rather similar in style to ED. TBASIC has 
several features not found in other BASICs. ASSIGN and 
DROP commands permit assignment/de-assignment of up to 
10 physical devices to any of 6 logical I/O devices. Long 
variable names and non-numeric labels are permitted. 
Arguments may be passed to subroutines, and local variables 
may be declared. Linkage to machine-language subroutines is 
convenient (CALL command). The bad news is that I was 
unable to get the CSAVE (to disk) to work. But I imagine that 
the version which is sold by Tarbell (for $36.00) has that 
fixed. TBASIC IS FAST: THE CANONICAL BENCHMARK 
(SEE BASIC-E ABOVE) RAN IN TEN SECONDS FLAT! All 
in all, a very well thought out alternative to BASIC-E. 


RUNALG.COM (28.11) Volume 28 is one of the most The balance of the CPMUG library is largely devoted to 
outstanding software values that I know of. It contains, in games (except for volume 9, which is a General Ledger 

addition to the ALGOL package, a set of database, inventory package for Microsoft 12k Disk Basic Version 4.0, and for 

and mail-list programs. But it is the ALGOL package which is volume 33, which is a very serious set of programs for auto- 

so utterly mind-blowing. Like BASIC-E, it is the product of mating aircraft search-and-rescue operations), 

the Naval Postgraduate School in Monterey, and is an 

intelligent and thoroughly reasoned adaptation of a classic WARNING!!! WARNING!!! WARNING!!! 
general-purpose programming language (in this case, ALGOL- 

60) to the CP/M environment. The majority of the CPMUG programs have never heard of 

First, the bad news: No linkage to assembly-language sub- lower-case ASCII. Fortunately, the assembly-source code is 

routines and no built-in transcendental functions. But now the generally given, so this problem is easily fixed: Invoke ED with 

Page 10 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 41 

6 




the source file. Look for an instance of ‘MVI C,l’ (or 
‘MVI C,l’ if tabs are used). You are looking for the set¬ 
up for a system call “read console” (Function #1, see p.7, 
CP/M Interface Guide). The command ‘brnfMVI C.IZOtt’ 
(or ‘brnfMVI C,l’) will quickly tell you how many such 
lines there are, (if any). If this draws a ‘BREAK AT 
AZ\ then there will be an EQU statement setting something 
like ‘CONSINP’ to 1, so look for that. Then follow the ‘CALL 
BEiOS’ or ‘CALL 5’ (just after the ‘MVI C,l’) with code to 
mask out bit 5 of all characters between 61 h and 7ah. Now 
assemble and enjoy. 

Two other sources of CP/M compatible public-domain 
software are: 

The Tarbell Public Domain Software volume, available from 
Tarbell Electronics, 950 Dovlen Place, Carson, CA 90746 for 
$10.00 (domestic). This is a collection of all of the Tarbell- 
dependent software in the CPMUG library (nought together 
on a single disk. 

The fig-FORTH package. The diskette is $35.00, available 
from FORTHRIGHT ENTERPRISES, P.O. Box 50911, 
Palo Alto, CA 94303. The documentation consists of two 
volumes, the Installation Manual and Glossary, and the 
Source Code listing + aids. These are available from the 
FORTH INTEREST GROUP, P.O. Box 1105, San Carlos, 
CA 94070 at $10.00 per volume. 

fig-FORTH is a standardized FORTH which ports 
smoothly between 8080, 6502, PDP/11 and very possibly 
several other machines as well. Its proponents regard it as the 
greatest thing since the invention of toilet paper, and they 
may well be right. (But see the comment on STOIC above). 

COMMERCIAL SOFTWARE 

The following are packages which either I own and use on 
my own system, or which I do not own but have used on some 
other system, or which I know of only indirectly through the 
testimony of colleagues and/or study of the documentation. 
Here again the selection is far from complete and reflects my 
own personal biases and interests. For a broader overview of 
the commercially available packages which run under CP/M, 
consult the advertisements of LIFEBOAT ASSOCIATES, 
2248 Broadway, NY, NY 10024. 

Editors and Output Formatters 

WORD-STAR WORD-MASTER is ED with a cleaner 
protocol for inputting and outputting subfiles, a more power¬ 
ful macro facility (conditional termination and nesting) and, 
in addition, a VIDEO MODE in which the alterations to text 
are dynamically monitored on the display screen as the edit 
commands are entered. WORD-STAR is the screen editor 
module of WORD-MASTER, plus an output formatter which 
is ;ilso dynamically monitored on the display screen. This is 
REALLY powerful, since you can see how the page sets up 
as you enter the formatting commands. It also has some other 
goodies, e.g., a menu-driven installation progiam which tailors 
the editor/formatter to a number of video terminals and hard 
copy printers, including the DIABLO and QUME daisywheel 
printers. 

If you already have extensive experience with ED (or any 
of the other sons-of-TECO), and/or if you already have a 

Dr. Dobb's Journal of Calisthenics & 


formatter that you like (or NEED a formatter that auto¬ 
matically generates a sorted index), then WORD-STAR is less 
attractive than WORD-MASTER. But if your text-entry is to 
be done by inexperienced personnel, then WORD-STAR 
would more than justify its purchase price by increasing the 
output of a newly trained operator. Both packages are 
SUPERBLY documented-an outstanding job. WORD- 
MASTER sells for $125.00, and WORD-STAR for $495.00. 

TEX This is the text formatter offered by Digital 
Research. It offers the standard controls, pagination, margins, 
line length, paragraphing, etc., and is entirely adequate for 
letters or short brochures. There is no user-defined macro 
facility. Documentation is very good, with many examples. 
TEX sells for $85.00. 

TEXTWRITER III This has all the functions of TEX, plus 
several extremely powerful capabilities for the generation of 
form-letters and sorted indexes. The form-letter feature will 
either take the names and addresses from a diskfile, or stop 
and prompt the operator to enter them manually. The 
indexing feature allows you to flag key-words (as they occur 
in the text) for inclusion in an index. Upon command, 
TEXTWRITER III will compile a sorted index with appropri¬ 
ate indentations. For tech writers this is an invaluable aid. The 
documentation is quite good. The power of the package, if 
you leave out the form-letter and sorted-index feature, is 
about the same as other formatters. There is no user-defined 
macro facility. TEXTWRITER III sells for $125.00 and is 
available from LIFEBOAT ASSOCIATES. 

TSC TEXT PROCESSING SYSTEM If you don’t need 
the sorted-index feature you should look into the TSC TEXT 
PROCESSING SYSTEM, available from Technical Systems 
Consultants, Inc., P.O. Box 2574, West Lafayette, Indiana 
47906. This sells for $50.00, is patterned after the UNIX 
utility NROFF, and is sold with a manual which INCLUDES 
THE ASSEMBLY SOURCE CODE! This is an EXTREMELY 
powerful package, with 27 memory-registers, user-defined 
macros, conditional macro-execution and access to diskfiles. 
There is a pre-defined set of macros which includes form- 
letter generation. I’ve used it since it first came out and have 
never had a complaint. 

ASSEMBLERS 

MAC In addition to the ASM assembler which comes as 
an integral part of the CP/M package, Digital Research also 
markets a macro assembler, MAC, which does not yet support 
relocation, but otherwise is very similar to the Intel macro 
assembler, ASM-80. MAC allows long (up to 16 characters) 
identifiers and puts out a special symbol table which is used by 
the SID debugging package (see below). The MAC package 
includes a set of macros called SEQIO.LIB (which VERY 
much simplifies interfacing assembly-level programs with the 
operating system), and another set of macros called Z80.LIB 
which enable MAC to assemble Z80 op codes. The Z80 facility 
utilizes extended-Intel mnemonics, rather in the style of the 
TDL/Xitan assembler. The documentation consists of a well- 
written tutorial and includes lots of worked examples. It got 
me started sooner than would have been the case had I ONLY 
the Intel “8080/8085 ASSEMBLY LANGUAGE PROGRAM- 

Orthodontia, Box E, Menlo Park, CA 94025 Page 11 

7 


Number 41 



MING MANUAL (Order Number 9800301C)” to work with. 
However, I did find it necessary to purchase the Intel manual 
in order to fill in certain gaps in the tutorial treatment. (The 
Intel manual was only $5.00, so no big deal.) 

MAC will assemble any source code accepted by the Intel 
ASM-80 assembler documented in the above manual, EXCEPT 
the relocation pseudos, ASEG, CSEG and DSEG. The MAC 
package sells for $100.00 and I recommend it highly. 

MACRO-80 The Microsoft MACRO-80 package is 
available either separately at $150.00, or as a part of either of 
the Microsoft BASIC or FORTRAN compiler. It is said to 
conform to the Intel ASM-80 specification in all respects, and 
the package includes a Linking Loader and Library Manager. 
The documentation is adequate. (But see remarks on 
FORTRAN compiler below). 

SMAL/80 SMAL/80 is for those who need to write 
assembly level code on an occasional basis, but are not yet 
familiar with the 8080 instruction set mnemonics. It is a 
Structured Macro Assembly Language which uses a semi-high 
level notation convention which shows a family resemblance 
to the C language. (The original version of SMAL was 
developed by C. Popper at Bell Labs.) Control structures are 
several flavors of brackets (BEGIN/END, DO/END, [/], 
{/ }), IF < condition > THEN < statement >, IF < condition 
THEN < statement > ELSE < statement > and loop controls 
LOOP < statement > REPEAT and LOOP < statement 
REPEAT WHILE < conditions THE MACRO PROCESSOR 
PERMITS NESTING TO ANY DEPTH AND RECURSION. 
Although it can. be cogently argued that SMAL should be 
used even by experienced 8080 assembly programmers, (be¬ 
cause of the enhanced readability of the code), I doubt that 
many will be convinced: The sensation is one of “too many 
extra keystrokes for too little payoff.” The documentation is 
in the Bell Labs style, clear, succinct and complete. SMAL/80 
sells for $75.00. 

SP80 

SAL/80 These two packages represent a middle way 
between SMAL/80 and straight macro-assembly programming. 
They are libraries of macros which provide control structure 
macros for specific macro assemblers. SP80 has versions for 
the TDL/Xitan macro assembler, the Digital Research MAC, 
“the Intel macro standard and MACRO-11 (PDP-11). I have 
not seen this package or its documentation, only the 
promotional literature, but I am myself the author of SAL/80, 
and it would appear that the two packages are quite similar. 
The SP80 package sells for $95.00 from SP80, P.O. Box 2745, 
Reston, VA 22091. 

SAL/80, in addition to the library of control structures, 
contains a library of utility macros, such as, e.g., multiplica¬ 
tion, division, string move and search, output string to console, 
etc., and will go into distribution in February for $50.00, 
available from Newberry Microsystems, 24225 Summerhill 
Ave., Los Altos, CA 94022. 

BASIC 

MICROSOFT BASIC (MBASIC) The “Industry 
Standard” is, of course, MBASIC by Microsoft. It is fast (as 
semi-compiled languages go) executing the canonical bench¬ 


mark in 28 seconds. Unlike most semi-compiled systems, 
MBASIC does the translation to intermediate code during 
program entry, so the translation process is invisible. The inter¬ 
mediate code is extremely compact and program development 
time is greatly reduced by the continuously interactive nature 
of the process. You enter some code, test it, modify it until 
satisfied, and then SAVE it to disk. The current release has 
overcome the shortcomings of most other BASICs: you can 
now use long variable names, loops may be written in 
structured fashion with the WHILE/WEND statement form, 
and conditionals may be nested. MBASIC has evolved into 
quite a civilized programming language. Moreover, MBASIC 
can be compiled to native code on the Microsoft BASIC 
compiler. Thus, the convenience of interactive program 
development can be combined with the speed of native code 
compilation—a truly impressive (and USEFUL!) achievement. 
MBASIC goes by the name of ‘Disk Extended BASIC’ and sells 
for $300.00. The MBASIC compiler sells for $350.00. 

CBASIC II CBASIC grew out of BASIC -E by the addition 
of bed arithmetic to fourteen places of significance, the 
WHILE/WEND control statement, integer variables, chaining 
with common variables, PRINT USING and improved file¬ 
handling capabikties. A number of very useful data-processing 
packages (e.g., accounting, database, merge-sort etc.) have 
been written in CBASIC and field-tested for several years. 
CBASIC sells for $109.00. 

COMPILERS 

FORTRAN FORTRAN-80 by Microsoft is being 
distributed by a number of firms under a number of names. 
There are a zillion copies out there and running. It’s been in 
distribution for several years now and is (presumably) well 
wrung out. It conforms to the ANSI ’66 standard (except for 
COMPLEX) and includes the MACRO-80 assembler, Linking 
Loader, Library Manager and a library of standard subroutines. 
The documentalion appears to be complete but reads more 
nearly like a design spec than a user document. 

PASCAL/M Written by DIGICON and distributed by 
Digital Marketing, 2670 Cherry Lane, Walnut Creek, CA 
94596, (415) 938-2880, Pascal/M is a recent arrival on the 
CP/M scene, and one most welcome. It is source-code 
compatible with UCSD Pascal, and hence is an almost “full 
spec” Pascal. The following restrictions apply: No parameters 
of type Procedure or Function. A File is NOT allowed as a 
component of a structure. The procedure DISPOSE performs 
no function. (However, MARK and RELEASE are provided to 
manage the heap.) Standard procedures PACK and UNPACK 
are not provided. A GOTO is not permitted to jump out of the 
procedure/function in which it occurs. (However the EXIT 
procedure of the UCSD version Is provided). Digicon lias 
designed a new 'drtual machine (new P-codes) and two inter¬ 
preters are available, one for 8080 and one for Z80. (I have the 
Z80 version arid it is FAST. The canonical benchmark 
executes in 10 seconds.) 

The package consists of the compiler, the interpreter, a 
runtime library iind a set of installation programs. I brought 
my copy up in just the time that it took to insert the diskette 
and execute the INSTALLP program. (There is another 
program for tailoring the interface to particular consoles, but I 


Page 12 

8 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Msnlo Park, CA 94025 


Number 41 



did not have to use it.) The documentation is concise without 
being excessively terse. It sells for $350.00 and I think it’s a 
real winner. 

PASCAL/Z This is a native code compiler for a subset of 
Pascal. Missing are floating point, variant records, the ability to 
pass procedures/functions as parameters and (SOB!) 
POINTERS. This assessment is based on the documentation 
which prevailed almost a year ago, before they (Ithaca 
InterSystems) had a CP/M version. The documentation of the 
compiler was rather scanty, suggesting that the product was, at 
that time, VERY new indeed. It sells for $275.00 and merits 
further investigation. 

WHITESMITH’S C Compiler This is a BIG compiler. It 
compiles the full spec C language as set forth in Kemighan and 
Richie’s book “The C Programming Language” (Prentiss-Hall, 
1978). The package includes the compiler, “narrative 
assembler”, linking loader, library and a set of installation 
programs. The documentation is in the style of the UNIX Pro¬ 
grammer’s Manual, encyclopedic but terse. 'Hie installation is 
simple: plug in the diskette and follow instructions. The 
compiler consists of four modules (including the “narrative 
assembler”), which total out to 156 Kb. There are lots of error 
diagnostics and substantial code optimization is performed. 
The first module is the preprocessor which does macro ex¬ 
pansions. This is overlaid by the PI pass, v/hich does lexical 
and syntactical analysis and some optimization. PI is then 
overlaid by P2 which completes the optimization and emits 
the intermediate code in “narrative assembler” notation. (This 
is a highly condensed assembly level notation which, like that 
of SMAL, is reminiscent of C.) The assembler, called ‘A- 
natural’, overlays P2 and generates a relocatable load module. 
The compilation process is initiated by calling a SUBMIT file 
wliich handles the overlaying and creation and deletion of 
scratch files. The whole operation is somewhat faster than a 
PLM compilation, but not a whole bunch. The link-load 
process is also handled by a SUBMIT file, and generates a COM 
file. 

Bill Plauser (at Whitesmith’s) tells me that there are about 
150 copies in the field to date and that the feedback indicates 
that the system is very stable. The Whitesmith’s C Compiler 
sells for $630.00 from LIFEBOAT ASSOCIATES. If you want 
an optimizing compiler for a structured language, this is the 
one. 

BDS C Compiler This is the work of Leor Zolman (at 
M.I.T.) and realizes a subset of C. There is no data initializa¬ 
tion, no long types, no floating point, no STATIC or 
REGISTER declarations, and not a whole bunch of optimiza¬ 
tion. However there is still plenty left for systems program¬ 
ming, and the package includes a linking loader and library 
manager. Tom Gibson (of Tiny-c Associates) tells me that he 
and his associates have been using the compiler with uniformly 
satisfactory results. The compiler generates relocatable load 
modules for 8080, the linking loader link/loads (multiple) 
object file(s) into a COM file. The documentation (again 
quoting Tom) is written in the style of, “Here’s how to use 
my compiler”. The BDS C Compiler sells for $110 including 
the Kemighan & Richie book cited above. 

BASIC See MBASIC, above. 

Dr. Dobb’s Journal of Calisthenics & 


A GREAT WAY TO LEARN STRUCTURED 
PROGRAMMING 

TINY-C This is a tiny masterpiece. The documentation is 
so good that it can (and should) be used as an elementary text¬ 
book. The tiny-c language facility consists of a machine- 
dependent interpreter (currently available, 8080 and PDP-11), 
and a Program Preparation System (PPS) written in tiny-c 
(and hence machine independent). PPS comprises an editor 
and run-time monitor. This results in an interactive program 
development system which is as convenient to use as any of 
the interpreted BASICs. You enter the program, test it, revise 
it, retest, etc., and write out to disk without having to change 
environment. When runtime errors are detected, the monitor 
halts execution and gives remarkably good diagnostic mes¬ 
sages. UNlike the BASICs (with the exception of TBASIC) the 
editor is both pleasant to use and a preparation for bigger and 
better editors. Similarly, the language tiny-c. 

Although tiny-c is, indeed, a VERY tiny C, it is nonetheless 
quite adequate for getting taste of the “hows and whys” of 
full-scale languages. Indeed, the expressive power of the 
language is comparable to the systems language XPL (the 
forerunner of PLM), and literally hundreds of compilers have 
been written in XPL! Tiny-c has IF/ELSE, WHILE, RETURN 
and BREAK for control-structures, integer and character for 
data types, one-dimensional arrays for data-structures, and a 
pointer convention which permits call-by-reference as well as 
call-by-value. Not too shabby! 

The source code of PPS, together with several worked 
examples provide excellent models of style and program 
structure. PPS allows you to load any number of program 
modules, which are then “linked” by the runtime monitor. 
Provision is made for linkage to machine-code subroutines. 
The assembly source of the interpreter is given together with a 
34 page analysis of its anatomy and functional behavior. 
Finally, there is extensive systems-level documentation to 
facilitate the installation of the system on non-CP/M systems. 
The CP/M installation is essentially a matter of inserting the 
disk and calling the interpreter and PPS. Instructions are pro¬ 
vided for tailoring PPS to systems with more than 24Kb. An 
appendix contains Newsletter updates. Tiny-c sells for $75.00 
and is distributed by tiny-c associates, P.O. Box 269, Holmdel, 
N.J. 07733. 

DEBUGGING AIDS 

DDS-n This is the best debugging tool I have ever used. It 
is comparable to the ICE software on the Intel MDS system. 
DDS takes over the video display screen (you can toggle back 
to the program-generated display at will) and maintains a run¬ 
ning display of: 

the value of the stack pointer, the top five words on the stack, 
the five words pointed at BY the words on the stack (dis¬ 
played in both hex and ASCII) 

the next five instructions, disassembled (and the first byte 
also displayed in hex), beginning with the current instruction 

the AF, BC, DE, HL registers together with the value of the 
PC at the instruction PRIOR to the current instruction, 
including the ASCII interpretation of the A register and 

Orthodontia, Box E, Menlo Park, CA 94025 Page 13 

9 


Number 41 



mnemonic representation of the condition flags, and the hex 
contents of the memory words pointed at by the BC, DE and 
HL registers, and a DDT-like display (in either ‘D’ or ‘L ’ 
mode) of any chunk of memory you wish to look at. 

There is also a display, the “call-stack”, which shows the 
last five return-addresses stacked as the result of a call, and 
you can choose to be notified whenever a subroutine returns 
to an address other than that which was stacked when it was 
called (think about that!). 

You can choose to be notified of a LOT of behaviors: if the 
program references data outside of a predefined range, or 
when the PC goes out of a predefined range, or when the 
program references a given location, or when the SP goes 
beyond a predefined range, or when the program IS ABOUT 
TO store at a predetermined location, or when a given register 
or memory byte/word attains a given value. You can do any 
and all of the fill, insert, display, move etc., commands usually 
found in most debug monitors, including all the flavors of 
breakpoints imaginable. You can single-step or two-step or 
n-step, I mean you have that program by the short-hairs! 

The documentation is excellent, even to the point of 
including a nine-page explanation of what assembly program¬ 
ming is all about. (I think that qualifies as overkill.) The 
package is available in off-the-rack versions for either VDM-1 
or ADM3A video displays, and can be patched to run on any 
display which has x-y cursor addressability. I have only two 
criticisms of the package: the time and space given to a 
tutorial on assembly-language programming would have been 
more usefully employed in outlining the patching procedures 
for non-VDM/ADM displays, and I wish to God that the disas¬ 
sembler that drives this program understood about Z80 code. 
Distributed by PRS, 257 Central Park West, New York City, 
N.Y. 10024, and selling for $65.00, DDS-II is one of the great 
bargains of all time. No joke. 

SID Digital Research’s update of DDT, the Symbolic 
Instruction Debugger adds three instructions to the DDT 
vocabulary, two utilities (TRACE and HIST) and allows you 
to specify addresses by the labels assigned them in the source 
code as an alternative to the hex representation. While certain¬ 
ly it is very nice to be relieved of the need to refer back and 
forth to the listing to figure out the logical signficance of hex 
addresses, I haven’t really got much good out of that feature, 
since when I’m doing that kind of debugging I’m talking to 
DDS II instead. But the extensions to the command set, 
particularly the hex arithmetic and the pass counter command 
constitute a signficant enhancement of DDT. 

The TRACE utility will compile a backtrace record of the 
program addresses executed PRIOR TO hitting a specified 
breakpoint. This is one of those “you don’t need it often, but 
WHEN you need it, nothing else will do” utilities. Similarly, 
the HIST utility profiles the activity regions of a program in 
execution, enabling you to identify the “hot spots”. Empiri¬ 
cal studies have shown that most programs tend to “spend 
90-95 percent of their time executing 5-10 percent of the 
code.” Thus an improvement of even rather modest propor¬ 
tions in a critical area will have more impact on over-all 
execution speed than a dramatic speedup of the relatively 
idle areas. The HIST utility justifies the price of the package. 
SID sells for $85.00 and an updated version which knows 
about Z80 code is in the works. 



Page 14 

10 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 



A Utiility Command 
■ Under CP/M ■ 


BY ANTHONY SKJELLUM 

1S95 Shenandoah Road 
San Marino, CA 91108 

No facility is provided under CP/M to reexecute a machine 
language program already residing in the transient program 
area, nor is there a direct facility for loading binary files 
(.COM files) into the TPA without executing them except 
with the use of DDT, the debugging tool. However, both 
these functions can be performed through the CCP (central 
command processor) by way of two programming “tricks.” 

A special command must be created under CP/M in order 
to reexecute a program. This is done by way of a “null” 
.COM file. Using the CCP “SAVE” command, such a file 
may be created as follows: 

SAVE 0 @.COM 

When “<® <CR>” is typed at the console. CP/M will search 
the directory for “@.COM” but will not load any new bytes 
into the TPA since the program has zero length. CP/M will 
then give control to the program at the beginning of the 
TPA (100H) and, in effect, the old program will have been 
reexecuted. It is desirable to place the command at or 
near the beginning of the directory to save search time by 
CP/M. Also, the user should be aware of programs which oper¬ 
ate erroneously when reexecuted, such as the SAVEUSER 
command under CP/M on Micropolis and CP/M on Vector MZ. 

In order to get the CCP to load a .COM file without execut¬ 
ing it, you must cause it to issue an error message while pro¬ 
cessing your command line. This is done by imbedding a 
control character in the data field after the program name as 
follows: 

FILE "A <CR> 

Note : Any control character not used by the CCP’s line input 
routine are considered illegal and will remain imbedded in the 
command line, causing the desired error to occur. In this case 
the program FILE.COM will be loaded into ttie TPA. However, 
when CP/M scans the data field to set up the twp default 
FCB’s, it discovers an illegal character and issues an error 
message (a “?”). The program can be executed when desired 
by using the command discussed above. This is generally 
more useful for single drive systems, but sometimes comes in 
handy in two drive systems also. 


The program listing below is a non -trivial CP/M command 
called “60.” This performs a function which is useful when 
no monitor or front panel is available. The program will exe¬ 
cute the address specified by the four hex digits in the data 
field. Spaces are considered to be zeroes. 

I hope the preceding is useful to some of the CP/M users 
who read DDJ. I enjoy the useful content of this magazine 
and hope it continues in the future. Finally, if there are any 
usrs of CP/M Micropolis or Vector MZ who have programs 
they would like to trade, I would appreciate hearing from 
them. 



Page 16 


Dr. Dobb's Journal of Co mputer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 
11 







Number 41 

12 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 


10010000110000215I0004047EFE20C210013E307? 
10011000C01101D82305C20801EIE8EICD2801D8?E 
l0012000292?2?2VB54FEICm30D8FE0A3FDOI688 
0801300007FE0AD8FE103FC9CA 
0000000000 



















Linking CP/M To 
George Morrows 
Cassette Interface 


BY WAYNE MILLER 

905 Fairmount Blvd. 

Jefferson City, MO 65101 

I have found that maintaining compatibility with others is 
ideal for exchanging software; however, I have had problems 
since I acquired a double density minidisk system. Therefore, 
I decided to link a cassette interface to CF/M, allowing me to 
exchange software with others even if the}/ do not have disk. 
I decided on the Speakeasy by George Morrow because it 
used the KC300 baud standard. This is very slow; but the 
chances of losing data from bit drop-out is very unlikely. 
I accepted the drawbacks of the slow speed since I would 
only use the cassette to read the program tc> disk. 

I am presenting this program primarily as an example to 
others to use when writing software to transfer data from a 
disk to a cassette tape. 

The functions that effect a data transfer have been coded 
in a structured format, which should make it wasy to follow, 
'rhe reader, however, will need to consult the CP/M and 
Speakeasy manuals to get the full description of the disk 
and tape functions. 

To change the direction of the transfer, the order of read¬ 
ing/writing the tape and disk will need to be reversed. I have 
marked the areas in the program listing for Ihe reader’s benefit. 
Note that I transfer a sector at a time. This could be easily 
changed if block transfers are desired. Also, there are two 
possible disk errors. A # 1 error is caused when the program 
tries to open a nonexisting file. A #2 error occurs when 
a disk write exceeds available disk space or the disk is in a 
'vrite protect mode. If such an error occurs, the message 
generated by my program will have the following format: 

“# - DISK I/O ERROR ON FIDOS”. 


CP/P, TO GEOhGE POhhOVS CASSETTE INTERFACE 
SOFTWARE LINKAGE 

WAYNE KILLEh 



; 

905 FAIhKOUNT bLVL• 


\ 

JLFFLhSON CITY# KO* 6510 


# 

i 

FAY 1979 


OKG 

lOOh 

bLOS 

LQU 

0005hl LNThY POINT TO CP/K 

CASSLT 

tQU 

61 OAh 5 COPL TAPL SYS ILF. 

ChLATL 

LGU 

22; LOS ChLATL FILL 

CLOSL 

LQU 

16; CLOSL ThL FILL 

WhITL 

LQU 

21; LOS WhITL hLCOhL 

TAPLF 

LQU 

202Q 5 TAPL hLAL COKKANL 

OPLNF 

LQU 

15; OPLN FILL COLL 

hLALF 

LGU 

20; hLAL FILL COLL 

PhlNTF 

LQU 

9; PhINT ON CONSOLL 

TYPLF 

LQU 

2; TYPL ON CONSOLL 

CON IN 

LQU 

15 hLAL F hOK CONSOLL 

FCb 

LQU 

05Ch5 FILL CONThOL bLOCh ALLhLSS 

BUFF 

LQU 

fcOhi LISK LF.A bUFFLh 

; bLOb 

HLGISTLhS hLTUhN VALULS IN A ANU b 

; 


FUNCTION hLG• IN C 

1 


FOhWAhL VALULS IN L ANL L 


LM 

h#0 


LAU 

SP 


ShLL 

OLLSP 


LX I 

SP#SThTOP 


KVI 

A# *0 * 


STA 

IBP 


JKP 

FAIN 

IBP 

US 

1 5 SLCTOh COUNTLh 

OLLSP 

DS 

2 

STACK 

LS 

64 

SThTOP 

LQU 

S 

; PhINT ChAhACTLh hOOUNt 

PChAh 

PUSh h! 

PUSh L! PUSh b ; SAVL hLGISTLhS 


KVI 

C# TYPLF 


KOV 

L# A 


bLOS 

b! POP LI POP h JhESTOhE 
i TO ThE CALLEP. 

TINE TO PEINT bUFFEh ON CONSOLE 
H! PUSh D! PUSh EJ SAVE 
C.PhINTF 
bLOS 

bl POP LI POP hi EESTOhEL 
ChLF 

i TO ThE CALLEh 
TINE TO PERFORK LISK I/O 
hi PUSh LI PUSh bi SAVE 
bLOS 

bl POP L! POP hi hESTOhE 

TINE TO PEhFOhK TAPE I/O 
h! PUSh LI PUSh bi SAVE 
CASSET 

bl POP LI POP hi hESOhEL 

TINE TO SENL CAKfilAGE hETUhN ANL LINE FEEL 
A>0Lh 
PChAh 
A.OAh 
PChAh 

TINE PERFOhPS LOW LEVEL EhhOh ANALYSIS 
ChLF 
A # * # ' 

PChAh 

A#b 

•O’ 

PCHAH 





Page 18 


Dr. Dobb's Journal of Computer Calisthenics 8< Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

13 









CALL 

CRLF 


LXI 

D#MSG3 


CALL 

P.'il OUT 


JMP 

FINIS 

MAIN 

LX I 

D*MSG6 


CALL 

PFiIOUT 


IN 

40h 

* 




AN I 

200Q 


JZ 

MAIN 


CALL 

SETUP 


LX I 

b» MSG 1 


CALL 

PRIOUT 


MV I 

A* ' $ * 


STA 

DLLIM 


LX I 

h» F CB 


CALL 

PRIOUT 


CALL 

CRLF 

GLOOP 

IN 

OF FB ; GET SEGMENTS LIMITS 


MOV 

B*A 


LDA 

IBP ; DONE 


CMP 

b 


JZ 

finis ;yls 


LDA 

ibp ;no 


INR 

a 


STA 

IBP 


CALL 

CRLF 


LDA 

IBP 


CALL 

PCHAR 


MV I 

A,TAPtFf- ch ange to read or 



° WRITE FROM DISK ADD TAPE 



D*126 i 


LX I 

FwOfcOh v* 


CALL 

TAPLOP^) I 


CALL 

DISK ^ J 


LX I 

D*MSG4 


CALL 

PRIOUT 


JMP 

GLOOP 

FINIS 

LX I 

D#MSG2 


CALL 

PhiOUT 


LX I 

L/FCb 


MV I 

C w CLOSE 


CALL 

F1LE0P 


LULL 

OLDSP 


SPFiL 



JMP 

Oh 

MSG1 

DB 

’ CASSETTE TO LISK ROUTINE S* 

MSG 2 

DB 

' END OF JOB 

* 



MSG 3 

DB 

* LISK I/O EhhOR ON bDOS i* 

MSG A 

LB 

’ TRANSFEh FROM CASSETTE COMPLETE S’ 

MSG 6 

DB 

' PRESS ANY hEY TO RUN S* 

SETUP 

LX I 

D# FCB 


MV I 

C>CREATE^- QPEI. 


CALL 

FILEOP 


CPI 

2SS 


JNZ 

OPNOK 


MV I 

h, 1 


CALL 

ERR 

0PN0K 

XP.A 

A 


STA 

FCBCR 


RET 


DISK 

PUSH H! 

PUSh D! PUSh b 


LX I 

D,FCb 


MV I 

C.kihniL < - OR READ 


CALL 

BDOS 


POP B! 

POP D! POP h 


CPI 

0 


RZ 



CPI 

1 


JZ 

FINIS 


MV I 

B#2 


CALL 

EKh 

FCbLN 

LQU 

FCB+O 

FCBFN 

LQU 

FCB+1 

FCbFT 

LQU 

FCB + 9 

FCBRL 

LQU 

FCb+1 2 

FCbl 3 

LQU 

FCb+13 

FCB14 

LQU 

FCb+14 

FCbRC 

LQU 

FCB+1 b 

F CbCF. 

LQU 

FCB+32 

FbbLN 

LQU 

FCB*33 

DLLIM 

LQU 

FCb+34 


LNL 

I STOP hUN 

* 








Number 41 

14 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

























Implementing a tiny interpreter 
with a CP/M flavored C 


BY LES HANCOCK 

Software Products Group 
Yourdon Inc. 

1133 Sixth Avenue 
New York, N.Y. 10036 

CP/M users finally have a compiler for the C language. 
It’s a subset of the C defined at Bell Labs, 1 but a full and 
proper subset, perfectly adequate for most systems’ work. It 
was written by Leon Zolman, alias BD Software. Although he in¬ 
troduces the compiler as an “educational tool” in his user’s 
manual, I know at least one software designer who’s making 
serious professional use of it already. This article shows 
how it can be used as an implementation language on the 
8080/Z80. 

Last summer was quite a compiler season: a copy of the 
BDS ccompiler came to me for pre -release testing a few days 
before I was due to leave for the Denver SIGPLAN symposium 
on computer construction. The obvious thing to do was to pick 
up some hot tips in Denver, then test Zolman’s C by using it 
to implement a simple compiler. I believe it was just after 
coffee break on the first morning of the symposium, while 
Kari-Jouko Raiha was explaining Dynamic Allocation of 
Space for Attribute Instances in Multi-Pais Evaluators of 
Attribute Grammars, that I began to rethink this plan. What 
I finally did write wasn’t a compiler, it was an interpreter 
almost as tiny as my humbled ego. Maybe the results will be 
interesting to those of you who (like me) are: less than expert 
at language implementation. At any rate the interpreter puts 
BDS C on its mettle. 

My first job was to specify the language. It’s best to do this 
by building an LALR(l) grammar that can be elaborated into 
a parser. But I cut my teeth on comic books, not on syntactic 
structures, so I had to make do with a list of rules: 

• A program consists of one or more lines, each ending in a 
newline or an end-of-file mark. Any line may begin with a 
label. 

• The character set of the language includes the usual nu¬ 
merals and letters (upper and lower case), plus the special 
characters. 

+ -/ *: ??! ■ ' '<>•€> 


These symbols are used to represent tokens which fall into 
six categories: identifiers, labels, constants, strings, operators, 
and keywords. 

• Identifiers (variable names) are single lower-case letters. 
They may be assigned numeric values. 

• Labels (line labels) are single upper-case letters. They may 
not be assigned values by the programmer. 

• Constants are signed integers from -32768 through 32767. 

• Anything inside a pair of double quotes is a string. 

• The operators take action on their operands. An operand 
may be a label, an identifier or a constant. The operators 
are: 

+ - * / the usual arithmetic operators 

= assignment 

== < > <= >= <> relational operators; if the result 

is true the value returned is 1, else 
0 

; prints its argument 

: prints argument on a new line 

-> A branches to line labeled A 

“ ” encloses a string 

opens a comment 
closes a comment 

° The keywords provoke events but do not take operands. 
They are: 

| EEE J SSS if-then: if expression EEE is 

evaluated to nonzero, executes 
the statement SSS, which may 
contain another if-then 

? waits for numeric input from 

user’s console 

! halts execution 

• Expressions are evaluated right to left. (But note that the 
if-then construction proceeds from left to right, though the 
expression in each if-clause is evaluated right to left.) 

• Blanks and comments are ignored unless they occur in 
strings. 

• The operators -> : ; and the keyword ! terminate 
evaluation of a statement. 

• Only integer variables are permitted. 

• Comments nest. 


Page 20 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

15 




Now we know as much about the target language as the 
interpreter does, so we should be able to interpret a program 
ourselves. Let’s try this one: 

A 5 ‘enter a number (0 to stop)' 

-C 0 == x = ? > ! 
i ‘its souare is * 

t X * X 

-> A 

We can easily execute it by eye. The first line, labeled A, 
prints a string that tells the user what to enter. The second line 
contains an if-then construction. Evaluating the if clause right 
to left, we begin with the keyword ?, which gets a number 
from the user’s console. The = operator assigns that value to 
the identifier x. The == operator compares the value of x with 
the constant 0. If this comparison works — in other words, if 
the user entered a zero — the result of the expression is 1, 
which causes the then statement to be executed. That state¬ 
ment consists of the keyword !, which halts the program. But 
if x is anything except 0 the comparison fails and the program 
continues on to the next line, printing “its square is’’followed 
by the value of x multiplied by itself. In the last line the - > 
operator causes control to pass back to the line which begins 
with A. 

The interpreter works by doing exactly what we’ve just 
done: scan a line, evaluate it, scan another line, evaluate that, 
and so on. Scanning means reading the symbols and recogniz¬ 
ing the tokens they stand for. Some tokens can be recognized 
immediately: + always denotes the ADD operator, x an 
identifier, X a label. Others take more analysis. For example, 
when scanning turns up the symbol - the token it represents 
may be SUB (for subtraction) or NEC (negation). The - may 
even be half of the GOTO symbol ->. Context tells us what’s 
what: if the - symbol immediately follows an operator the 
token must be NEG; if it’s followed by a > the token is 
GOTO; if it follows an identifier or constant and precedes 
another identifier or constant, the token has to be SUB. Once 
all the tokens in a given line have been recognized, the line can 
be evaluated by following the rules of action set up for each 
operator and keyword. 

So the interpreter needs two main moving parts, a scanner 
and an evaluator. A prescanner would be nice too — it could 
strip out blanks and comments and make the source code 
more compact. 

That’s exactly how the interpreter was designed. Its driving 
function begins by calling out the prescanner, which filters 
the ASCII input file and pours the results into the program 
buffer. Then the scanner and evaluator are called to process 
the filtered code. The scanner gets the next token from the 
program buffer and disposes of it in one of six possible ways: 

1. operators go into an operator stack 

2. constants go into a value stack 

3. labels are copied from the symbol table into the value stack 

4. identifiers (variable names) are copied from the symbol table 
into the value stack; if an identifier isn’t yet in the symbol 
table, the scanner puts it there 

5. strings go into a string buffer; an entry in the value stack points 
to each string 

6. keywords are dealt with immediately. 


The evaluator never sees the ASCII symbols in the program 
buffer. Its job is to evaluate a single line on the basis of the 
tokens it finds in the operator stack, value stack, symbol table 
and string buffer. It pops operators and values from their 
respective stacks and handles them according to the rules that 
define the tiny language. 

Before looking at the C functions that run the interpreter 
we’d better understand its four data structures in more detail. 
The program buffer is a character array that contains the 
program’s ASCII source code as filtered through the prescan¬ 
ner. Here’s how the square-your-number program looks in its 
buffer: 

J'enter a nu»ber <0 to stop)'\n-C0*=x»?>!\nJ' 
its souare is *\n?x*x\n->A 

Note that the carriage-retum/linefeeds have been replaced 
by the C newline (represented here in conventional C notation 
as In) and that the initial line label A has disappeared into the 
symbol table, where it’s equipped with a pointer aimed at the 
first character in the program buffer. Incidentally, the last 
character in the buffer is always a CP/M end-of-file (Oxla), 
not shown in the example. 

The symbol table contains one entry for every label or id en¬ 
tifier encountered in the process of scanning (or prescanning) 
the source code. The symbol table symtab is an array of 
structures each of which contains a one-character symbol and 
its associated value, either an integer (for identifiers) or a 
pointer to the head of some line in the program buffer (for 
line labels): 

symbols < 

char symbol* /* l.c. for IDENT* u.c. for LABEL */ 
union < 

int integer* /% if ident is IDENT */ 
char ilinef /* if ident is LABEL */ 

> auidf 

> symtabCSTAKSIZED * *symptrJ 

The symbol table pointer symptr will always point to the 
next available element of symtab. 

Unlike the other data structures, the symbol table never 
shrinks; it can grow as the scanner finds new symbols, and its 
integer component can change as variables get new values, but 
nothing’s ever elided. The operator stack, value stack and 
string buffer are rebuilt from scratch every time a line (or an 
if-clause or a then-clause) is scanned. 

The value stash is an array of structures topped off bv a 
stack pointer — tokens may be pushed onto it or popped off it 
by incrementing or decrementing valsptr. In the first draft of 
the interpreter this data structure was called operandstack, 
which is more exact than valuestack but too easy to confuse 
with operatorstack, its opposite number. At any rate, the 
structures look like this: 

values < 

int taper /* naa be IDENTr LABELr CONSTANTr STRING »/ 
union < 

SYMBOLS #ptrsanif /% if type is IDENT or LABEL */ 

char tsubstrind* /* if type is STRING */ 

> auod* 

int value* /* if type is IDENT or CONSTANT */ 

> valuestackCSTAKSIZEJ* *valsptri 

The type of an entry determines which if any of quod's 
members are useful. When an operand is an identifier or a Line 
label quod's value is ptrsym, a pointer to the appropriate sym¬ 
bol table entry. When it’s a string quod's value is substring, 
a pointer to the string’s location in the array strings. For 
constants quod has no use at all. 


Number 41 

16 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Me nlo Park, CA 94025 


Page 21 



Where operands have a numeric value an entry is made in 
value, which otherwise contains garbage. 2 

The operator stack is just an integer array with a stack 
pointer: 

int operstorstackCSTAKSIZEJ r #oPSPtrf 


Every operator that can go into the stack has a numeric code: 


ASCII 

symbol 

mnemonic 

code 

comments 

+ 

PLUS 

1 


- 

MINUS 

2 


* 

TIMES 

3 


/ 

DIV 

4 


= 

GETS 

5 

assignment 


PRINT 

6 

piint with newline 

» 

PRT 

7 

piint sans newline 

-> 

GOTO 

8 


== 

EQ 

9 

logical equivalence 

> 

GT 

10 

greater than 

>= 

GE 

11 

greater than or 

< 

LT 

12 

equal to 
less than 

<= 

LE 

13 

less than or equal to 

<> 

NE 

14 

logical inequality 


The numbers can be anything so long as there’s no duplication. 
The string buffer is the simplest of all the data structures: 


char strinasCLINED r #strptr» 

As strings are encountered in the scan they go into strings. 
The pointer strptr always indicates the next available element 
in this array. 

So much for the data structures used to implement the in¬ 
terpreter. You may have noticed that each one is associated 
with a pointer. Like most other up-to-date implementation 
languages, C leans heavily on pointers and recursion. We’ll 
come to the recursion now as we look at the interpreter’s 
main functional modules, main, prescan, scan and evaluate, 
main is the driving function. It follows this outline: 

initialize stop/go flag, bugger pointer, symbol table pointer 
prompt for input file name 
prescan the file 
if no errors so far, 

reinitialize buffer pointer 
while the stop/go flag is GREEN, 
clear the value stack 
clear the operator stack 
clear the string buffer 

move the scanner through the program buffer till it 
hits the end of the current line or the end of the 
buffer, or encounters a STOP or an error 
if the scanner has reached the end of the buffer, set the stop/ 
go flag to RED 
call the evaluator 

prescan opens the input file and calls the supporing func¬ 
tion readchar to get new characters in sequence until end-of- 
file is reached, readchar is delegated the job of ignoring com¬ 
ments and linefeeds. Linefeeds are easy enough, but we’ve 
stipulated that comments nest. A global counter called incom¬ 


ment is used to keep track of how deeply we’re nested in 
comments at any given moment. There are two kinds of com¬ 
ment tokens, LCOMMENT (to open the comment) and 
RCOMMENT (to close it), readchar follows this strategy: 

get the next non-LINEFEED character from the file if it’s an LCOM¬ 
MENT, 

increment incomment 
else if it’s an RCOMMENT, 

decrement incomment 

if incomment is nonzero or if the character’s an RCOMMENT, 

call readchar recursively 
else return the character 

Recursion provides a neat solution to the nesting problem. 

prescan itself has the job of eliminating blanks and of 
putting labels into the symbol table. Since blanks in strings 
must be preserved, the local variable instring is used as a flag. 
Strings don’t nest, so instring need take only two possible 
values, YES and NO. prescan’s internals aren’t very interesting. 
When it finds an upper case alphabetic character at the head 
of a line it assumes it has a label and installs the character 
in the symbol table along with the current value of the pro¬ 
gram buffer pointer. Since the labels are no longer needed in 
the source code, they’re not read into the program buffer. All 
other characters, including labels which don’t occur at the 
head of a line, do go in. 

scan is the biggest and trickiest function of the lot—too 
big, really. Its argument is an ASCII character from the pro¬ 
gram buffer. A long series of case statements are used to recog¬ 
nize the argument as a keyword or as an operator (or as the 
first character of an operator’s symbol); if that fails, it should 
be an operand. Most of the operators get minimal processing: 
things like PLUS or TIMES or DIV simply go onto the opera¬ 
tor stack. But the keywords are handled entirely by the 
scanner, and one of them, IF, exercises scan to its fullest. 

Consider the if-then construction as a whole. Where we 
have a line like 

•C 0 == x = ? > ! 

we want to parse and evaluate the conditional clause before 
going on to parse and evaluate the statement that will be 
executed if the condition is true. This calls for recursion. 
Look at the ‘ | ’ case of scan in the C source code. When scan 
meets this symbol, it clears the value stack and the operator 
stack and calls itself just as it gets called in main. Successive 
characters are scanned until the matching ‘) ’ is reached. 
The effect of the ‘ J ’ case is simply to return a zero, which is 
the signal scan uses to tell its calling function that it’s reached 
a stopping place. At this point control passes back to the first 
invocation of scan, which checks to be sure that a ‘ J ’ is in 
fact what stopped the scanning process. If so, it calls evaluate 
to evaluate the part of the line just scanned—that is, the part 
inside the if-clause. The function evaluate returns the numeric 
result of its evaulation. Should that result be nonzero, scan 
clears the stacks again and returns 1, which tells the call¬ 
ing function to go ahead and finish scanning the current line. 
If the result is zero, scan pushes bufptr ahead to the next 
newline, skipping the statement following the THEN. In this 
little recursive drama scan briefly plays the part of main. 3 

Recognizing operands is a fairly straightforward business. 
Except in strings, an upper case letter must be a label, a lower 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

17 



case letter must be an identifier, and a digit can only be part 
of an integer constant. Since labels at the head of a line have 
already been dealt with by the prescanner, the scanner should 
find labels only after GOTOs. Whenever a GOTO turns up we 
peek ahead one character to be sure there’s a label coming: as 
soon as we reach the label we look back one character to be 
sure we had a GOTO. 

When the scanner encounters a label it calls idlookup 
to see whether the label’s in the symbol table. If not, that’s 
an error. Otherwise an entry is made in the value stack, setting 
the type to LABEL and setting quod.ptrsym to point to the 
label’s symbol table entry. 

The story’s somewhat different for identifiers. It’s per¬ 
fectly OK to find that an identifier is not yet in the symbol 
table. When that happens the scanner calls idinstall to put it 
there. The entry made in the value stack will have a type 
of IDENT, a quod.ptrsym pointing to the symbol table entry, 
and a value equal to whatever was contained in the symbol 
table’s integer field. 

When the scanner meets a constant it accumulates the con- 
sant’s integer value with the help of the library routine atoi? 
This goes into the value stack’s value member, with the type 
set to CONSTANT. Negative numbers are accumulated by a 
recursive call from the - case. 

Eventually we scan up to a newline, at which point main 
passes control on the evaluate. Though it’s fairly long, evaluate 
is a simple function. If it sees a RED flag it simply returns, 
leaving main to stop the program. Otherwise it pops the oper¬ 
ator stack once and the value stack twice. If either stack is 
empty, evaluation is finished. If not, evaluate goes to the case 
statement that matches the operator and carries out the 
action it finds there. Most operators are binary-that is, they 
take two operands. All binary operators do essentially the 
same thing: they combine the two operands in some way 
(add them, divide them, compare them), then put the result 
back onto the value stack as a CONSTANT. One binary oper¬ 
ator, GETS, stands apart. Its left operand must be of type 
IDENT. Otherwise it’s like any other binary operator, which 
makes expressions like 

0 == x = ? 

perfectly legal. 

The unary operators are PRINT, PRT and GOTO. One of 
the rules we used to define the language being interpreted 
was that these operators terminate execution of a statement. 
In fact they jump right out of the evaluator, using C’s own 
goto. There are nicer ways to do this—for example, by setting 
a local flag to be checked in the while- but I did want to 
wring out the compiler, and I’ve always had a salacious yen to 
use C’s goto. 

The interpreter’s GOTO operator works by setting the pro¬ 
gram buffer pointer to the address recorded in the label’s 
symbol table entry. When evaluate ends, main tells scan to 
start scanning the line that begins at that address. It’s very 
much like the 8080 jump instruction, which loads the jump 
address into the program counter. 

Examples are included here to show how BDS C compiles 
and runs the tiny interpreter, ccl and cc2 are the two halves 
of the compiler. They generate relocatable object files which 
clink links with libraries to produce absolute 8080 code. 

According to Leor Zolman, his C trades object code ef¬ 
ficiency at runtime for structure and clarity during program 
Number 41 Dr. Dobb's Journal of Calisthenics & 

18 


development. This is certainly true in a sense—the interpreter’s 
.COM file size is 12K bytes-but memory’s cheap these days, 
and as for time, I hate to think how long it would’ve taken me 
to code this interpreter in 8080 mnemonics. Where speed and 
space are really critical, C can be used to prove the logic of 
a system which will eventually be written in assembler. 

The BDS C compiler, with libraries, linking loader and good 
documentation, is available from tiny C associates (201/ 
671 -2296) and Lifeboat Associates (212/580-0082) for about 
a hundred dollars. I recommend it. 


Author's Self-Portrait 

Footnotes 

(1) The best definition is Appendix A of Brian W. Kemighan and 
Dennis M. Ritchie, The C Programming Language, (Prentice-Hall, 
1978). 

(2) I know: value could go into quod. There’s a reason I chose not to 
do that, but I can’t remember what it was. Also: why quod and not 
another quid'! It’s one of the BDS compiler’s few serious restric¬ 
tions. To quote the user’s manual, “Names of members and tags in 
the structure definitions cannot be the same as any regular local 
variable names, nor can more than one structure or union per 
function use a given identfier as a member or tag name.” 

(3) See line 18 of the test program 16.tst for an example of deeper 
recursion in if-then’s. 

(4) Zolman provides the usual C runtime routines, plus quite a few 
useful library functions. 

listing 

B. type x. c 

/*********************** 

## Tiny interpreter t version of 10/23/1979. 

## by Les Hancock 

** New Yor< City 

** 

** Operators 35 follows. 

** 

** + - / * as usual 

#* > >= < <= <>'also as usual 

## ? prints its argument* then a newline 

*# i prints its argument sans newline 

## ->A branches to line label A 

** 

#* Keywords? 

#* 

#* ? prompts for numeric input 

## ! halts execution 

-C expression > statement executes statement 
## if expression is evaluated to nonzero 

Orthodontia, Box E, Mnnlo Park, CA 94025 Page 23 




p 

CL 


P 

in 


u 

A 

-J 


2 -I 
UJ Ui 
Q A 
M <X 


<- in 

o ‘H in 


A 

Z 

w 

Q 


Ol 

X 

3 

ro 

e 


O pH 

JQ O 
e xi 
31 e 
in 3i 
in 


\ * 

s 


(- «at 
01 01 
w c 

Ol H 
P PH 

c * 


p 

CL 

£ 

31 

in 

* 


cn 

£ 

<E 


O 
JQ 

£ 

31 V U «*. W 
in v oxiu 


\ 

* 


Ui 

A 

<r 


-J 

UJ 

A 

<X 

-J 

\ 

u * 
O 

CD 
A Z 
Z *h 
u q: 
Q A 
M w 

m in 


Ol Ol 
CL CL 


CD 

z 


Ui 

z 


■p 

in 


A 

z 

Xi 

o 


01 * 
z 0 
10 



C C JZ 

H x 

01 V 

(. 

O -H Cl 

r ro 

D 

ro 

•H 

O P 

rH cn 

JZ 

c 

£ 

10 UJ 

Cl 

o 

A 31 

3 ZD 



UI 

_l 




* * \ <r 



A 

\ * * z> 


„ in 

_i * 

01 o 

CL V A t- 

31 Z ro -o ^ 

vpcaxo>ui 

o cn ci d ai 

•h G P Z 

C C C pH 

ro 

> 


t-S H 


CL Z 


h ui ii 
•h in 
oi i- 
v c P 
z -h it 
JQ t. i- 
O P P 
•h ui in 


Z t- 
JQ P 

ui cl 
o v 
c- z 

CL JQ 


■ * * * * * 
.***** 


01 

P 

c 

o 

CL 


p 

-J 

3 

3 

01 

Ol 


c. 

•H 


01 

c 


P 

P 

OL t- 

p 


01 


Cl 

cl 

•H 

■» 



3 P 

c 


p 

a. 

* 

o 

O 

h- 

V 

V 

P OL 

•H 


c 

U 

p 

* 

OL 

Z 

H 

•H 

in 

O 



P 

in 



u 



V pH 

OL 

A 

0 

OL 


at 


a 

* 

* 

•H IQ 

U 


OL 

P 

c. 

n 

U 

*H 


s 

> 

01 u 

'-r U 


3 

0 

UJ 

IQ 




Ql * 

V 01 

Cl 01 

c. 

X 

p 

N 

P 

01 



u 

4 - V 

P V 

01 

* 

>0 

►H 

01 

X 



0 - 

J V- 

Oi V- 

p 


C- 

cn 




«•» 

C n 

X O 

Ol D 

p 

at 

01 


01 

3 

£ 

Ol 

Ol UJ 

X 

V X 

z 

n 

OL 

<x 

D 

10 

3 

c 

•h N 

£ 


0 

UJ 

0 

p 

pH 

£ 

01 

•H 

M 

>0 £ 

3 Ol 


N 


cn 

ro 


(- 

t- 

* cn 

*- 10 

X C 

01 

►H 

a. 

LJ 

> 

* 

P 

p 

\ X 

Ol t- 

■H 

c 

cn 




\ 

c. 

in 

<r 

O Ol 

X t- 

•H 

u. 

a 

u 

* 


* 

X 

K 

O 

QJ P 

U 

3 

>0 

ro 




j 

cn 

OL U 

UI UI 

P 

A 

p 

P 


A 

Z 


Ol 

0. 

o 


o 

p 

10 

U 

0i 

CL 

O 


P 

c 

0l 

£ 

£ 

O 

u 


Ol 

•H 

01 Q 
C Ui 
••H <X 


•H C 

c. 

»- Z 

01 P 

c 

C P 

10 -H 

u 

in c 
01 01 
<- jc 

CL 3 

V £ 
•H 10 

u 

P Ol 

01 o 

in u 

CL 

11 

in 

p p 
C pH 
01 10 
E JC 
E 

O Ol 
U fo 

C rH 

•H P 


p 

c 

OJ 


x in 
c in 
10 01 
u 
0 i o 
Ol u 
ro CL 
UI 

01 t- 

01 0 i 

£ JZ 
p 
t- C- 

O Z 
t- A 


Ol 

V 

z 

JQ 

p 

Z 

0. 

c 




c 


3 

01 

X 

D 

Ul 


0 


o 

D 

«o 

£ 

P 


3 


pH 

ro 

pH 


c 




P 

pH 


pH 

10 


0 l 


(- 

o 

T 3 

Ql 

3 


pH 


01 

1 

0 l 

X 

V 


•H 

•• 

> 

p 

.. Ql 

10 

u 


P 

ex 

0 

•H 

ex c 

•« pH 

^ •• c 

•• 

c 

a: 

c 

c 

£ c 

ex c 

o ex x 

ex 


UJ 


/ 

Ui / 

ex / 

c ex ■ 

ex 

■ 

u. 

• 


_i» 

UJ > 

r- UJ ~ 

UJ 

N* 

3 


ex ^ 

A ~ 

A v 

LJC* 

z 

P 

A 

p «•> 

ex p 

•‘OP- 

<1 P 

OIOP j£i 

P 

* ex 

PXUJPX JPX JP 


\ JC 

* u 


e •» * 

Ql CL ^ «- 

~ 3 

C ro o 

£ Ol 

O U 0 

X _J 

H Ql u. 

0 ID * 

P P O C 

u 

t- t- 


C UI r- u 

P Ol 

CL X Ql 

£*•* 

H (- u 

•H ui 


•H 

t- o Oi Ql 

3 m 

ro 

*- * 

P 10 

c JZ * * 
•H U \ * 

ex p 

p p 

* * * \ c c 

* * * * H -H 1 

Ul CJ 

O 


c m 3 c ro u. c 

H Ol O 'H 01 


ro o _ 

01 Z H 


CL Xi Ql CL JQ 01 


fc. t- 


u u 


m Ci c 

01 HH -H 


CL JQ 01 CL JQ Ol CL 
01 UI 

10 ro 

U Cl 


* 

o 


10 

ui 

Ol P 

in c 

o 01 

pH £ 

Cl E 

o 

TJ Cl 

c 

ro ro 


10 

JC • 
Cl 01 
c 

01 10 
UI JZ 
ro U 


01 ro 
3 U 
O I 

rH C- 

Ql 

Ol 0 . 
pH CL 
01 Z 
C 

•H 01 
UI pH 

Ol 

01 c 

XI H 
ui 
p 

UI 01 
=1 JQ 
£ 

P 
U) 01 
(- Zi 
01 £ 


\ 

11 * 

••H Ol 
rH C 
3 H 

III PH 

Ii 3 

0 l 


p ui 

e: 

H p 

c- c 

£. -H 

u 

* OL 


m 

Ul 

01 

•H 



O TH Z 


CM 

n <\ 







c 

iTT 

ui 

P 

Ul 

Ul 

<X o 


•pH 

in 


CO 





Ol 

ai 

0 

•H 

pH 

01 

K _l ►— Z 


cn 

cn ►- 

N 



o 

pH 

cn m <r 

Cl 

Cl 

pH 

P 

01 

Cl 

z ui cn »h 

in 

cn 3 

uj cn 2 


o 

CS 

pH 

pH 

pH pH pH 

O 

O 

Cl 

c 

X 

3 

Ul A Z (X 

u 

3 z 

Z 3 A h 

A 

A 








ai 

ro 

P 

Q <E O A 

0 

_j m 

HHUIli 

iX 

o 

a 

A 

Ui 

A UJ UJ 

■ 


X 

T! 

pH 


h juin 

p 

u. Z 

A A CD £1 

u. 

CD 

Ui CD 

CD J J Z 




■H 


01 


ro 













Ql 

□ 

Ol 0 l 0 J 01 

t- 

0 i 0 j 

Ol Ql OJ 0 

01 

Oi 

0 i 

01 

0 i 

0 i 0 ! 01 




pH 

C 

pH 

c c c c 

Ol 

c c 

c c c c 

c 

c 

c 

c 

c 

c c c 




pH 

•H 

!0 

■HI H H H 

Cl 

-H H 

•H -H H -H 

■H 

•H 

■H 

•H 

■H 

•H -H -H 




<r 

-J , 

z> 

4 - P P P 

O 

P P 

P P P P 

A 

A 

A 

A 

A 

AAA 







Ol Ql Oi Oi 


Oi 01 

Oi Ql 01 Oi 

01 

Oi 

Oi 

01 

Oi 

Oi Ol Ql 

* 

* 

* * 

* 

* * \ 

* * 

\ O TJ "O "O 

* * 

\ *0 'O 

•o X X -O 

O 

U 

u 

u 

X 

XJ V *0 


U 

ro 

P 

UI \ 

* 

Ql 

□ «- 
pH Ql 

10 v 

> V 

Z 

•. jQ 
\ Ql 
* pH £ 
Xi f 0 
Ql ro t- 

C P Ol 

•h O 

pH pH t- 

O CL 
P JZl 

Z £ 01 
£L 31 -C 

c in p 

•H 

c C 

V rH ' *H 

UI 

Ol UI UI 
O! C *■ 
Ol 0 ) ro 

•H X 

jQ O u 



p 

C x 



H X <0 

• 


ro £ 

0 i 


in £ 

• 


u * 

■H 

ro 

ro * ^ 


X 

JZ \ 

* 

p 

u 

N 

(J p 


X 

Z Ci 

* O' 

X 

t- z 

\ «r o ' 

/ o 

P c- 

r-j o ' 

' pH M 


t- E 
r- \ 
no u. 
Cl CJ 


JC 

P 


A 

01 


JZ 

p 

•H 

3 

01 

ui 

Z 

u 

o 


ui - 

UI 

cn 

-J cn 

O Ui 

* ZD 

r _i 
>- <x 
cn z> 


lli A 
4 N Ui Z 
)hN UJ 
WHI 

J zcn z 
: <r u. o 

i I— ZD CJ 
JO)® J 


a a 
Z Ui 
UI UJ 
Z U. 
Z UJ 

o z 

CJ HH 
£X _J 


cn 

Ui 

U 1 pH >- 

Z X 

M O pH z 

_J ui o 

3 Ci cn ui 

UJ z u cc o 

Z Ui >- CD Z 


******** 




OiQl QlOlOlOlQlOlOiOlOlOlOl 

i ccccccccccccc 

I H -H H -rH - H H H f-4 -H -H H H H 
=*- C*_ pA PAAAAAAA 

OlOlOidiOlOiOlOiQiOiOlOlQl 

rNTD-O-O 3D "D XT3XJXI-0-0T3TD 


01 

> 

\ o 


01 

X 

<0 


* • 

\ • 


t- oj 
o A 
t- <*- 
u ZI 
Ql X 

C £ 
Ql ro 

CL <- 
O Ol 

o 

01 U 
pH Cl 
•pI 

4 - * 

\ 


"D 

O 


Ol 

* * \ T3 

N * * + 


\ 

* 

S 

* pH 
01 

t- X 
O ro 


Ql 01 
C P 
Z h Cl 
U i in e 
i in oi 

►-■■HP 
£ P 
i 10 

* 

u. \ * 

t-t \ 


\ N 

CD 

cx 

ex ex 
>o uj ex 
-J u 
ex A A 
ex <z <r 

ui -i _j 
Li- O C 
H Z H 


Ql Oi Ol Ol Ol 

C C C C C 

■H -H -H -H -H 

C*_ V V P 

Ol Ol Ol Ol Ol 

oo ooo 


ro 

cm ex 
ex 
ex uj 
iX u. 
u x 
Z A 
ll ex 
o z> 
u. o 


X 

10 

p 


o 

X 

£ 

31 


X 

10 


x cn 

£ -1 

31 O 

cn a 

z 

* * \ >- 

\ * * cn 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

19 







to 

* 01 









JO 

p 



»- 

K 






01 c 



z 

Z 





u 

3 H 



u 

u 





p 

rH • 



Q 

Q 





ft. 

ID XJ 



M 

Hi 





in 

> -H 









rH 

rH J 



B 

B 





ID 

a 



N 

H 





> 

01 A 










JO 1 



qj ^ 

ll 





m 

6 



0. W 

ft. 

«a> 




p 

\P Jl 



3 C 

3 

rs 




3 

* in in 


\ 

P -H 

P 

K 




ft. 

3 *- 


» 

A *• 

A 

C 





*- e p 



1 P 

K 1 

•H 

QJ 



+ 

O OL 


01 

rH ID 

* rH 

*- 

3 



+ 

p * • 


c 

ID JQ 

ID 

P 

ri 




■0 \ XJ 


•H 

> - 3 

01 > 

m 

ID 



*• 

C- O 


rH 

~ UI 

c 

JO 

> 



\ 

Ol 3 


3 

— Ol 

•H — «■. 

3 

A 




ol a 


to 

~ 3 N XJ 

rH — r» 

m 

1 




OVA 

N* 

c 

rH * O 

3 Ol 

• 

rH 




1 

* 


1- ID 3 

• 1-3 

x> 

ID 



«■. 

3 ~ *- 


JC 

Z > CD O 

C Z rH 

0 

> 



1- 

*- H P 

in 

p 

<T A Z A 

« ID 

3 


«a. 


Z 

ID Z CL 

*. 

•H 

K 1 M 1 

• K 3 

O 

II 

<ri 

O 

<x 

cum 

0 

3 

COH^H 

C CO A 

A 

— 



h 

•ri Q rH 

p 


Z ID h- ID 

• Z 1 

1 


II 

H 

CO 

JO M ft) 

ID 

P 

O > CO > 

m o rH 

rH 

01 



z 

> 

t- 

C 

u 

CJ ID 

to 

3 

Ol 

Ql 

o 

rH || 

01 

•ri 

H 01 H 

p > 

> 

r—i 

3 

3 

CJ 

ID fl II 

ft. 

V *- 

U ■ JQ • 

C fl 



rH ft) rH 

ftl > fO 

> A > 

A I A 

I *- I 

*- P *- 

P 0. P 

OL 10 L 

in r-t m 

H IT) H 

ID 3 ID 

Oi > ID Id ~ > 


OL fl "U » 

NVN 

* Hi c m c 

\ 1/ 3/ 

3> • e ■ 

p ~ ~ 

A %- * %- 

— | v \ P 

I“ rH C C 


« ° ~ 
^3 "N 
jB CL 

a a: 

H I Ui 

.> 3 
5» o 

a f; ? 


■ f— r-l C C rH C C ** rH •> O 

'2 ID'H 'H • « H H «- o • t; *■ 

M3*- *- j£ h- > t- «-.*►- 3 

(2^fL*(Li*o:^iiii«L loo^fl a; oi 


in 

01 z 

m 

P «•» 

CO 

ID ri 

> 

U «•. 

JC 0. 

in 

01 CL 

m 

H CD 

rH 

*- *- 

rH 

CL ^ 

h- 

> ID 

+ 

*• * •• 

O V 

rH 

*- V- 

pH 

*- %- 

Ol 

JQ Ol h 

01 

in id 

U 

~ > 

+ 01 

01 ID P 

P 01 H 

01 

jQ Ol H 

Ql 

JQ 01 -ri 


m 


ri ftl 

CD 


m 

01 rH 

•h m 


m 


m 


ID 


ID *- 


V 

rH 

*- 3 

3 ID 


ID 




u 


A > -Q 

01 

•H 

A 0l 

yQ ID 

in o 


0 


Cl 


P CO «*. 

ui -JO 

c o 

►H At. 

r id 

* * \ >- JC 
\ * * CO O' 


ID 


4*. 

«■. 

4» 

«*. 








P 


01 

01 

01 

01 








m 


3 

3 

3 

3 








01 


rH 

ri 

ri 

ri 








3 


to 

ID 

ID 

ID 








rH 


> 

> 

> 

> 








ID 


A 

A 

A 

A 








> 


1 

1 

1 

1 










ri 

rH 

rH 

rH 








A 


to 

ID 

ID 

ID 










> 

> 

> 

> 








(. 













P 


4- 

1 

* 

\ 








ft. 






0i 



r\ 


01 


m 


11 

0l 

01 

01 

□ 



01 


3 


ri 


3 

3 

3 

3 

r— 



3 


t—i 


ID 

\ 


rH 


r—i 

ft 



rH 


ID 


> 

* 

ID 

ID 

ID 

to 

3 



ID 


> 




> 

> 

> 

> 

A 



> 


A 


OO 

m 

A 

A 

A 

A 

1 



A 


1 


O0 

u 

1 


1 

1 

p-i 



1 


r—i 



O 

c- 

u 

C- 

U 

ft 



H 


to 



P 

P 

P 

P 

P 

3 



ID 


> 


(f 

ID 

OL 

ft. 

ft. 

OL 


«e. 

<s 

> «• 

•e. 



ID 

U 

in 

m 

« 

m 

II 

iH 

o 

rH 

o 

ll 

rH 

P 

to 

rH 

rH 

ri 

rH 

N 



A 


A 


m 

ft. 

*0 

ID 

ID 

ID 


H 

n 

II 

II 


II 

c. 

0 

> 

> 

> 

> 

a 



01 


Qj 


0 







Ol 

Ol 

3 QJ 

01 

3 

QJ 

p 

3 

B 

1 

B 

H 

r*l 

3 

3 

rH 3 

3 

ri 

3 

ID 

C- 

V 




ft 

rH 

ri 

do ri 

ri 

ID 


(- 

ID 

01 

Ol 

Ql 

Ol 

3 

ID 

ID 

> ID 

ID 

> 

ID 

01 

C 

~ J 

3 

3 

3 

A. 

> 

> 

A > 

> 

A 

3 

A. 

V -ri 

U rH 

rH 

ri 

ri 

| 

A 

A 

1 A 

A 

1 

A 

O 

JO 

P ID 

ID 

« 

ID 

(.. 

I 

1 

*- 1 

1 

C. 

1 


r*. 

ft. > 

> 

> 

> 

i- : 

(. 

C- 

P *- 

C- 

P 

u 

H *- 

*- * 

m a 

A 

A 

A 

ft. 

P 

P 

OL P 

P 

OL 

P 

A P 

P \ 

OL 1 

— 1 

— 1 

1 

Ui 

Ol 

ft. 

in a. 

OL 

in 

Ol 

OL 

OL 

0 *- 

CO c- 

CO *- 

U 

H 

in 

m 

rH m 

m 

r—l 

in 

*- m 

m 

* CO P «* 

D P - 

U P 

P «- 

III 

ri 

rH 

ID ri 

rH «»« 

to 



C <- XJ 

•HOC M 

o P id ~ ID 

CL ID QJ > 


CL 


c- m 

P 

* 

Dl 

c- 

1 

H 

rH 


in 

0l XJ 

ID 


ID 

3 



ID 

H 

•H 

Ol C 

3 

CO 

rH 

P 


rH 

> 


JC 

O ID 

ri 

u 

V 

01 

Ol 

ID 

1 

D) 

p 

u 

ID 

D 


c. 

rH 

> 

1 

ID 


XJ Qi 

> 

-J 



•H 



rH 

p 

C OL 

01 




■C 




*PH OL ♦♦ ♦• ^ D Ol .* Z ft. .* 

^ ft. ID«^ O *• CO CO J Id H M Id • - _ 

Old>(-#U)DUj*« CO.H 8IIH mhH 

^flLiP^32r^ .u iot- Qt- 

oi CL JhhhQI-UJKLJIiJP III > n Ol >JQ 

Cl ld£a.£l-QliJOO J JZ-H «l UI 

*- I H M 0 3 ID ID 

3 w iDPOiQioioJOioioiojoiQjmu u 

P H>H«oidiiiidiriiiiididtfi 
OiOiiDI 3fOiDiDiDroiDfOfOiDiD 
*- m 3 | ftUUUUUUUUUO 


^30L.tfZft..tfX*.a£^OL.tf**>ftl ID j* •* 3 
_J U» (0 Hi Ul OH id Oh HI ID CS > 0i 3 ID I- ~ 

dzh gihH iich miij in mo 

U ID*- fl)*- «*- ID*- %. rn fc. <P 

paj>jQai>£iai>jQii)>jjiiiri qj jq oi h 
p » ui w ui in in 

3 to ID to ID ID ID 

m u u a o o u 


ID ID j£ •* > ID 
>Ql>lDUJ~>ai 
in m cd in 

*H fc. V- rH 

m jo qj -h at 

in 

ID 


<r »d o 

p 

* * * * N C 

N. « * * * -M V 


Number 41 


Dr. Dobb s Journal of Calisthenics & Orthodontia. Box E Menlo Park, CA 94025 


Page 25 


valsptr->value = 0! *# Look ue identifier in symbol table (simple linear 

break! ** search). If there, return pointer to the entry! 

case LT! ** if not. return null pointer. 

if (valsptr->value < val->value) */ 

valsptr->value — 1! SYMBOLS ftidlookur(c) 






re 

in x 





r*N 


c 




flL 

> 

JC 

0) 

(. 









o 


•H 



E 

p 

•H 

p 

c 

01 



\ 








• 



O 

3 P 

•H 


JG 



«■ 






II 


TJ 



u 

X3 

ro 

3 

m 

E 









It 


•H 


• 

p 

■w 

Dl 


•H 

3 



P 


X 






3 


-X 


•H 

01 

TJ 


C 



•H 


* 




\ ^ 


O 


U 

rH 

O 

C 

0) 

01 




Dl 






» ^ 

«». 

A 


CO 

H 

P 



c 

01 



•H 


33 



\ 

0 


1 


P 

ID 

ID 

c- 

rH 

0 

> 



33 


QJ 



* 

p ~ 

u 

e 


m 

0 


QJ 

ID 


•H 



C 


■o 




•H flL 


31 

\ 



C Jj 

CJ 

flL 

P 



o 


0J 



t- 

3 

iH 

in 

* 33 

QJ 

•H 

£ 


3 

•H 



c 


Ol 



QJ 

pH £ 

rH 

u 


c 

> 

— 

3 

c 


in 

«•. 




c 



•H 

rH O 

ro 

P 

P 

ID 

•H 


C 

QJ 

Dl 

o 

/“V 


p 





P 

m O 

P 

flL 

C 

U 

in 

t- 


Ol 

C 

flL 

H 


X 


QJ 



•H 

P «H 

m 

• 

ro 

QJ 

t- 

ID 

0) 

XJ 

•H 




0l 


Dl 



P 

in 33 

c 

T3 

P 

OL 

3 

JI 

x: 


£ 

ID 

| 


c 


ID 



c 

C -H 

•H 

O 

in 

0 

U 

U 

p 

01 

u 






— in 



QJ 

•H 


3 

c 


Qi 



> 

ID 

p 

u 


0 


r. «n 



to 

II 

•H 

O 

□ 

c 

U 

01 

in 

ID JQ 

0 

p «•* 


p 


CJ QJ 



•H 

* 


A 

CJ 

•H 


c 

QJ 

JC 



flL t- 




E 




QJ E 

H 

1 



ID 

0 



O P 

P Z 


QJ 


* 



* 

rH 31 


f. «» 

* p 



ID 


in 

•H 

3 <X 


u 


> (- 

«•> 


s 

A in 

E 

P h- 

\ 

3 

m 

flL 

E 

rH 


Dl 

JQ t- 


c 


CJ 01 

/■X 



ID p 

31 

0. Z 


flL 

•H 

3 


•H 

* 

•H 

^ CD 

U 

ID 


K JC 

£ 



p p 

in 

in uj 





33 

3 + 33 

•H Z P 

> 


p 

£ 



flL 

c. 

rH a 


■> 

m 

Dl 

C 


+ 


0 o 

OL 33 


c t- 

til 

<■> 

V 

rH ♦ 

p 

ro m 

V 

0J 

•H 

C 

ID 

A 

t- 

p 

POP 

ID 


10 3 

-J 

rx 


O 33 

flL 

> 


3 

x: 

•H 


C P 

in 

ID 




U P 

A 

£ 

<*x 

JG O 

♦ 

ii 


rH 

p 

£ 

1 

ID 

flL 

u 

II 

Xj * 

s 

in 

« 

£ 


E 3 

TJ 

ii 


ID 


u 


U P 

•H 

|| 

* N 

» 

0 

3 

LU 

u 

31 O 

0 

0J 

u 

> 

p 

ID 

01 

in 

3 

P 

QJ 




P c 

O 

A 


in a 

3 

QJ flL 



•H 

Xi 

x: 

V XI 


QJ flL P 


fc. 

% 

z 

<X 

u 

1 

O 

3 31 

p 

QJ 



p 


* 

aj 

3 31 

■H 


0 

c » 

w 

_l 

01 

C t- 

A 

rH p 

H 

P 

P 

■s 


0l 


JC 

rH P 

Dl 


u 

ID X 

u 

a 

3 

•H P 

1 

no A 

Dl 

ID 

ID 

V 

in 

in 

P 

p 

ID A 

•H 


u 

U 

0 

M 

O 

flL 

c- 

> 1 

H 

rH 

x: 

1 

QJ 

•H 

C 


> 1 

XJ P 

ai 

C 

p 

x^ 

rH 

p in 

p 

A + 

T> 

3 

p 

v 

Tl 

3 

0l 

p 

A + 

in 

a. 


/ *- 

p 

P 

in 

O *H 

0. 

1 + 

in 

£ 



3 

t~ 

£ 

0J 

1 + 

•H 

p 

■» 

■ r\ 

Of 

0 

•H 

c ID 

in 

C- fc- 

•H 

3 

u 

01 

rH 

Ol 

3 

Dl 

(- U 


3 

s 

NT O 


fc. 


> 

rH 

p p 

— 

CJ 

p 

in 

CJ 

jC 

Dl 


P P 


Xj 


P ^ 


p 


p 

ID 

flL flL 


U 

0 

ID 

c 

P 

C- 

O 

flL a. 

Ol + 


P f~ 

01 

0i 

P 

•H 

> 

in in 

P 

ID 

z 

CJ 

•H 

O 

10 

P 

in in 

rH 

+ 


C 0 

in 


H 



rH rH 

•H 








rH rH 

•H 


V 

■H U 

•H 



* P 


id ro 


* 







ID ID 

JC 



u u 

A QJ 


01 

\ H 


> > 

QJ \ 







> > 

3 


QJ 

flL 01 


. 3 

P 
n 

a t- 

















IH 

►H 














•H 













h~ 







• 







£ Z 

P 






JC 

— 






<r <i 

£ 






01 (J 







a. r 

<X 






> p 

— 


— 


— 


^ _j 

a. 






ID ID 







o 







QJ E 

— 


— 




N 







rH 







CM 

CM 


CM 




P 

— 


— 


— 


• £ 

• 


♦ 




o in 







rH o 

H 


tH 




P ID 

— 


— 


— 


> UJ 






in 

rH 







o 






0l 

31 

— 


— 


— 


£ 

£ 





jC 

<- 0J 







UJ P 

UJ 





0 

P JC 

— 


— 


— 


_J A 

-J 


£ 



p 

P 







JH 

»H 


UJ 



ID 

•. 

— 


— 




£ O 

CL 




P 

E 

n jc 







r x 

r 


Z 


in 


p 

— 


— 


— 


o 0< 

o 


hH 


p 

n 

O H 







U TH 

CJ 


-1 


* 

CM P 3 

— 


— 


— 







sO 









u ~ 

(J 


CJ 


H 

JC 

TH p 

— 


— 




CJ 






p 

C 







UJ w 

UJ 


UJ 


♦ • 

•rl 

E Qi 

— 


— 


—■ 


£ 

£ 


£ 


QJ 

3 

O C 






U 

<1 h- 

<x 

>: 

<E 


rH 


f- O 


Qi 

—. 



♦ 

3 X 

3 


3 


H 

P P flL 


> 


n 


X 

P CD X 

P 

-s: 

P 


P 

C- 

flL 


0 

— 


—. 


U. M 

£ 

c: 

U_ 



ID 

Dl O 


E 


0l 


rH 

o £ r-j 

O 

r! 

o 


P 

P 

C 

— 


— 

* 

— 

CJ 

cn p u 

cn 

H 

tfi 


3 

in 

-H C- 


L 


ID 


CJ 

£ u 


Cl 


x| 

fl. 


^ 3 

—■ 

3 , 

—■ 

P 

— 

♦ 

AO 

A 


A 


c 

QJ 

ID O 


o H 




A 

A U A A 

0i A 

A 

HH 

3 P 31 

— 

31 0-- 

— 

IH 

— 


3 , 

o «r 

31 p 


X 

identifier #/ 


* 

-1 

P 

0 


UJ 

c 


X A 

■* <E 

1 


-1 

X 


rs 

Dl * 


A oj 

c 


1 jG 

H P 



33 h 


P 

Ql Dl 


O in 

CJ H 


P 3 

0J 33 


o e 

fc- 


CD 

flL ID \ 


c 

* 

X 

tx Ol 

L P 

* 

O * £ 

(D O CD 


o 

JO C UJ 

L 

CD O P 

0 z 


UJ P 

33 

Dl 

Z O P 

* c in 

QI 

CD X 

\ id X 

P 

(- QJ 

p 

c 

o in c 

~ * H 

•H 


•x x 


~ p * 

CM * 

ai 

1 H X 

^ X 

JO 


Qi 

p 

31 

jQ 


in 

£> 

3 

in 

01 

p 


c 

H \ 

E * 


0. 

V 


01 
* jC 
1 \ p 


CO X ~ 

3 ~ 

Z fc 
M V 

r no 
v p p 
QJ 3 0 

jo ~ no 


i ~ -p 

CM 

t- V 

P I V 01 
a. ui 

p fc ~ 

3 -P ~ W 
JO O (-N 
~ P P 

* 3 a. 


3 


•H 





X 

4- 



-I 


Xi P 


II JQ 

«•> 

£ 




33 A 

•4* 

II 


A 

L 

x" 3 

«•> 

- * 

X 

in 


cn 


rH 

X 

* 



<L 

OJ 

* Xi 

/X 


o 



3 


3 


XT 

+ 


-1 

3 

X- * 

U 

U || 

/ 

* 


J 


O 

II 

C- 

+ 


O 

O 

p ~ 

P 

P 

X 

X 


£ 


u 

II 

QJ 

L 


z 

rH 

H P 

flL 

OL + 








flL 

P 



m 

Dl H 

P 

P + 

H 



II 


* 

U 

flL 

flL 


L 

H 

H Dl 

3 

3 u 






X 

P 

3 

in 


O 

— 

33 H 

JO 

Xi P 

+ 

«•> 


+ 



Ol 

in 

flL 


L 

x^ 

in 3? 

* 

* fl. 

+ 

t- 


+ 



P 

•H 

0 


L 


•rH in 


N-r fc. 

L 

p 


L 



3 

XT 

* 

0l 

01 

P 

— H 

c 

P 

P 

fl. 


P 


•• 

JG 



in 


•H 


ro 

ai in 

a. 

P £ x 

a. 


X 

* 

P 


rH 



00 OC 

U 

rH « 

c. 

3 

ID + 

in 

ID 

1 

XT 

•H 


Ol 


Ol 

0« 0« 

in 

•H 

p 

JG 

0l x 

a. 

ai 

X 






in 



x; 

in 

+ 


0 

L 


P 





rH 




\ 

* 

co «- 
3 CO 
Z 3 
»h Z 
r »—i 

r 

in 

' H 
•p 


* fc 


3 

QJ 

C 

JC 

P 


3 

A 

ro 

h 

O 

u 

o 


II 

A 


LU 

CD 

V 

01 

XI ~ 


\ 

* 


z 

<x 

*- 

CO 

z 

o 

CJ 


XI 

i 

P 

I! 

31 

01 

c: 

\ -h 

* 


o 

CD 

3 

O -- 

•H tj 

O 

V fl. 

:> 

■p j; 
in o 
3 O 


cn 


II UJ 

UJ 

P 

ii a 

UJ 

P P 

p 

TO II UJ 

p 

V 

UJ 


X _J 

«- Z 

-J 

X QJ 

CD 

c z 

C — 

rH x CD 

CD 

HI 

r 



P 




•H M 

•H p 

3 


> ~ 

*H 

M 

H H 

flL II 

H 

ii ii 

11 

(- £ 

t- £ 

O N H 

H 

CD ~ 

P 

A 

H 

P 


ii 


flL £ 

flL £ 

a u 


JO u 



+ * fc 

3 + <»■ 

+ 

+ «- 

+ 



+ *“■ 

+ 


II 

H 

<- + t- 

JQ + (- 

+ 


+ 

* II 

# R 

# U + fc 


QJ fc 


* + xi ai * n 
in 
m 
u 


P C- P * fc p 

\p + ■+■ a. p a. ^ p a. 

n p p pip olp 
in t- fc 3 in 3 p in 3 

&«*••*+>«•>•• P «»>•• jG ll Xi -H (L jQ 

o ' o-^vjl^n^op op 
Qj ■* ro* inro\mrtJV'-'*4- qj * + 

in oi x a. <u x <l oj x m 

«“l*-Ot-0«-P rH 

A Ql x m »Xi 0i#D 01-H 

in in m 

ro ro id 

CJUU 


a. 

o £ 

i *• ro 

■ m 


p t- p 

fl.Pi 
p a. p 
3 in 3 
•• JO flL .Q 
' * O + 
II ^ U + 


A Qi X3 01 h 


«- X X X P 6- P 

P P P flL P flL 

fl. P P P flL P 

in u t- d in 3 

& «» •» p p jo a. jq 

O £ ' 1 X ' Ol^n »op 

1) H ro — tfi <10 — ifl m A ^ + 

in Qj x 1 0l ' fiLQl N 

^ t- OP op P 

01 XjQi*XjQl*jQQlH 


TO 

- * -P« 

3 X 

LU II «* 

a 3 

« X £: UJ 

_j * v 31 a 
~ 01 <1 
r-l ^ t. _J 

TO m x P 
C JO A fl. II 

P pH TJ Qj 
01 II C) flL 
flL * II 3 31 
OX C5 P 

~ A A 

C CM I I 

P P 

I P P 

fl. t- 

p m p 

p *-« fl. 

Al ro in 

P :► rH 

Dv id 

p 3 OlD v > 

P flL ~ 

flL * OL * P 

m n. D '-' •h 

ft. «•* in 

Oj£“-hP 
Hi -X- ro ♦> ^' •H 

U) 01 »H 

pH P 3 P 

rs oi n id -h 

p 
0) 

T 


Number 41 

22 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 







your move 


error 




Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

23 


whose turn? 











ALS-8 to CP/M 
File Converter 



BY HOLLIS FRAMPTON 

SUNY - Center for Media Study 
Buffalo, New York 14214 


This routine may be administered to alleviate pain. We can’t 
be the only people who are making the transition from ALS-8 
and its various cousins (Software Package # 1, et al.) to CP/M. 
There’s enough work in interfacing a library to the utilities of 
a new operating system, without battling the discrepancies 
between file formats as well. Reasoning that some drudgery 
is too grim even for system programmers, and faced with the 
transfer of some hundreds of files to the new system, I wrote 
CPCON and would like to share it. 

With several embellishments, it runs in 1085 bytes plus 
24 bytes worst case for the stack, and on a Sol-20 running 
at not quite 2 MHz converts itself in about 2 l A seconds; 
about half this time is taken up by two special passes through 
the ALS-8 source file to handle the special case of the quoted 
ASCII blank (as in MVI A,’ ’). A few redundancies allow 
some of the bells and whistles to be detached with ease: a 
couple of these are documented in the preamble to the listing. 
Some seeming software overkill (the recurrent MVI A, — 1) 
deals with bizarre special cases in source files. They are there to 
“bullet-proof’ the code, so remove them at your peril. If it 
seems over-commented, it is: I love to play the ‘you-figure - 
it-out’ game with other people’s code, but not with my own 
... 3 days later. 

A word about constraints. Our ALS-8 is the PROM version, 
resident from E000-FFFF hex. We’re running CP/M on North 
Star minifloppies, with a bootload PROM at E900 and a 
Thinkertoys DISCUS with PROM at E000. Hence the pain¬ 
fully slow strategy of dumping to tape. Those with more 
flexible memory maps, if they can arrange to have ALS-8, 
CUTER and the BDOS part of CP/M simultaneously resident, 
will of course want to automate the whole procedure. Since 
both SOLOS and CUTER return tape header data in known 

Number 41 

24 


RAM areas, it’s a trivial matter to have CP/M perform auto¬ 
matic disk saves from tape files read in under the SOLOS/ 
CUTER utilities. Equates in CPCON adhere strictly to the 
widely published labels in documentation for both SOLOS/ 
CUTER and ALS -8. 

The VDM output driver is a CRT driver that uses the 
VDM-1, a memory -mapped display, but partially simulates a 
terminal, conventionally blanking the screen and cursor on 
receiving ctrl-S and Ctrl- A respectively. Presumably the CP/M 
source file conventions will be known to anyone desiring to 
use CPCON; for ihose who wish to patch it for other source 
files than those native to ALS-8, the specs are as follows. A 
line consists of: (1) a ‘character count’ byte. The count tal¬ 
lies all characters in the line, plus the terminating CR, plus 
itself -, (2) Zero or more printable ASCII characters; and (3) 
a CR (not a CRI.F). Meaningful data begins in column 6 of 
an assembler source file, with a blank separating it from a 
4-digit decimal line number. Labels may or may not be fol¬ 
lowed by a colon; in either case the label field terminates 
with a blank. Labels are considered unique to 5 characters, 
but may contain 6; CPCON disregards label length. Opcode 
and operand fields terminate with blanks and may contain 
no imbedded blanks. The ALS-8 output formatter requires 
a dot as a dummy operand to pretty-print after RET, PCHL, 
XCHG and so on. Comment fields are separated by at least 
one blank from the preceding field, pretty-print with 2 
blanks, and tolerate a leading semicolon or asterisk delimiter. 
Comment lines may be indicated only by a leading asterisk. 
Does that sum it up? It’s hard to remember: the ALS-8 
assembler supports some fairly baroque ambiguities, dating 
perhaps from the days of the 4004 or the 2002 orlOOl. 
Handling of string constants is summarized on the preamble. 

Page 29 


Dr. Dobb’s Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 










Dear Suzanne, 

Here’s a fresh listing of CPCON, which converts 
resident source of text files in ALS-8 (SPKG1) format 
to CP/M format. The routine will accept anything 
the ALS-8 assembler finds edible, and produce an out¬ 
put file equivalent to a CP/M *.PRN file from ASM. 
COM or MAC.COM but stripped of its first 16 columns. 
All labels emerge followed by colons; semicolons pre¬ 
cede comment lines and fields; tabs are appropriately 
inserted. The ASC pseudo-op is converted to a DB, 
and all ambiguities in its argument string are resolved 
to single-quote delimiters. ALS-8’s directives COM, 
LIST and NLST are left undisturbed; tie feature that 
packed them out was removed when a fils written under 
the ALS-8 video editor suffered deletion of a macro 
call to something named LIST. Hand checking is urged 
for these cases. 

Users who aren’t in the habit of quoting ASCII blanks 
(20H) may shorten the routine by two entire passes, 
by deleting lines 94-106, line 141 (CALL SPFIX) 
and SPFIX itself (lines 404-412). Yet .mother pass is 
taken to convert comment fields in statement lines to 
lowercase: disable the option by deleting the CALL 
LCASE at line 142, and the apposite subroutine at lines 
414-460. With all options enabled, CPCON reformats 
itself (about 24K) in less than 2 seconds. It then saves 
the reformatted file twice to tape, and offers to display 
the reformatted file at the console (tabs are not expand¬ 
ed). The very nervous, wishing more than one verifica¬ 
tion, should enter via a CALL to CCOPY; the confident 
may delete the option and shorten the code by omitting 
lines 150-167 and all of MSSG4. 

Two idiosyncrasies should be noted. Fust: comment 
fields in statement lines, once detected (and proved not 
‘empty’) are passed intact to the reformatted output. 
An earlier version deleted leading blanks, and succeeded 
in trashing most of what was intelligible in a banner 
headline routine that depended on a large table. Those 
who wish to pack out leading blanks in comment fields 
can insert an appropriate test in TSTCF or TSCF1. 
Second: the command switch in CPCON offers to re¬ 
format pure text files, a much simpler procedure which 
simply removes the “character count byte” (see below), 
the line number, and the column thereafter. It has been 
our custom to use an ASCII dot (.) as a ‘line holder” 
in such text files, since an empty line produces bizarre 
(try it!) output from the ALS-8 console TEXT com¬ 
mand. Accordingly, entry at PTFOR tests for such “line- 
holders” and converts them to blanks; more than one 
dot is assumed to be part of an ellipsis and is passed 
unchanged. Anyone who has used the video text editor 
in ALS-8 as a convenient alternative to ED.COM may 
experience difficulty with this protocol where they 
have written input files for text processors, since most 
such software uses leading dots in column 1 to flag a 
command. Those wishing to reformat only assembly 
language files may make entry at ASFOR... but be 
sure you test for a non-existent source file or CPCON 
will attempt to reformat all of RAM. 

A few notes about system calls and file-structure 
assumptions. Those working with the PROM version of 


ALS-8, which resides at EOOO-FFFF and SOLOS/ 
CUTER, those superdreadnoughts of the late Processor 
Technology Corp., will be able to use this program as-is. 
ALS-8 expects to find RAM at D000-DFFF and stores 
the 5 -character name of it’s current file starting at D000 
(FNAME). Thereafter, binary pointers to start-of-file 
and end-of-file are stored at D005 and D007. As a 
convenience, ALS-8 returns the current filename and its 
address parameters to the console output driver on entry 
at FILE (E5BO) without checking file structure. EORMS 
(E060) is the warm entry point to ALS-8 (signs on with 
“READY”.) The VDM console output driver (FE77) 
accepts a printable character in register B and trashes 
the accumulator; a ctrl-Z blanks the screen, assuming 
IK of display RAM starting at CCOO. The SOLOS/ 
CUTER input routine behaves like the specs for CONIN 
in CP/M, returning with the zero flag set on no input, 
else delivering the character in A. Tape routines in 
SOLOS/CUTER assume a header block, starting address 
and byte count: patch them for your own drivers ad lib. 
The persent version dumps formatted files to tape at 
1200 baud, in CUTS format, under the filename known 
to ALS-8 and typed “A” or “T”. 

For those who have not undergone the pain of 
working with the ALS-8/SPKG1 format, this is it. Files 
are line- oriented and line-numbered. A formal line 
consists of 1 -65 lines (there’s a terminal-width switch in 
command mode, but EDIT truncates all lines on exit). 
Each line consists of: (1) a “character count” byte. The 
count of characters in the line includes itself ; (2) a 
4-character ASCII decimal line number; (3) a dummy 
character, normally a blank, ignored by the assembler; 
(4) a string of printables; (5) an ASCII carriage return 
(CR: = ODH), the end-of-line marker. Thus an empty 
line contains only a “character count” byte, which 
evaluates to a binary 1 (that is itself). Therefore hex 01 
is the end-of-file character. The far simpler CP/M file 
structure assumes no line numbers, inserts a CR and a 
LF after each line, and posts an arbitrary ctrl-Z as an 
end-of-file mark on all but *.COM files. Incomplete 
pages under CP/M are filled with ctrl-Z, a convention to 
which CPCON conforms. 

CPCON was built for systems (514” North Star and 
8” Thinkertoys) whose boot load PROMs overlap the 
ALS-8 address space. Hence the download to tape. 
Then change circuit boards, and read back the tape files 
under SOLOS/CUTER. The tape loader returns a hexa¬ 
decimal filesize parameter: convert it to decimal and 
call it “bb”. Warmboot CP/M and type “SAVE bb 
FILENAME.TYP” and CR. It’s a lot easier if CP/M and 
your version of ALS-8/SPKG1 and SOLOS/CUTER 
can be made co-resident, but ours can’t, so we didn’t 
bother to write it that way. No trouble about asking 
CP/M to pick up the parameters, build a new FCB 
(file control block), and autosave the source: see the 
manual “CP/M Interface Guide,” a model of lucidity 
which allows the programmer to treat an operating 
system like a device with a few control ports. 

Regards, 

Hollis Frampton Digital Arts Lab 


Ps ge 30 


Dr. Dobb's Journal of Computar Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

25 













Converter! 
Listing | 


0000 ************************************************ 
0001 * * 
0002 * CPCON.ASM: AN ALS-8 TO CP/M FILE CONVERTER * 
0003 * * 

000A ************************************************ 
0005 * 

0006 * CONSTANTS 


0007 

* 




0008 

CP. s 

EQU 

0DH 


0009 

CTRLZ: 

ECU 

1 AH 

;CP/M EOF 

00 10 

ESC: 

EQU 

1BH 

/'PANIC BUTTON 

001 1 

ETX: 

EQU 

3 


00 12 

FILL: 

EQU 

0 

/'DUMMY BYTE FOR * * CASE 

00 13 

LF: 

EQU 

0AH 


00 1 4 

QUOTE: 

EQU 

27H 

/'ASCII <’> 

001 5 

TAB: 

EQU 

09H 

/'ASCII <HT> 

0016 

* 




0017 

* SOLOS/CUTER 

EQUATES 


0018 

* 




00 19 

BLOCK: 

EQU 

0C823H 


0020 

FNUMF: 

EQU 

0C854H 


0021 

HTYPE: 

EQU 

0C822H 

ITYPE BYTE IN SOLOS TAPE HEADER 

0022 

LOADR: 

EQU 

0C825H 


0023 

SINP: 

ECU 

0C01FH 

5 SOLOS SYSTEM INPUT DRIVER 

0024 

THEAD: 

EQU 

0C81CH 


0025 

UNIT1: 

EQU 

80H 


0026 

VTAPE: 

EQU 

0C77FH 


0027 

* 




0028 

* ALS- 

8 ECUATES 


0029 

* 




0030 

BOFP: 

EQU 

0D005H 

/•BEGINNING-OF-FILE POINTER 

003 1 

EOF: 

EQU 

0 I H 

/ALS-8 END-OF-FILE MARK 

0032 

EOFP: 

EQU 

BOFP+2 

;END-OF-FILE POINTER 

0033 

EORMS: 

ECU 

0E060H 

5ALS-8 SIGN-ON ENTRY PT 

0034 

FILE: 

EQU 

0E5B0H 

;RETURNS CURRENT FILE PARMS 

0035 

FNAME: 

ECU 

0D000H 

/•CURPENT FILE NAME 

0036 

VDM: 

EQU 

0FE77H 

;ALS-8 CPT OUTPUT DRIVER 

0037 

0038 

* 

ORG 

1 00H 

/•PUT IT VHEPE YOU WANT IT 

0039 

* 




0040 

CPCON: 

LXI 

H/0 

/'CLEAR TO RECEIVE... 

004 1 


DAD 

SP 

;...CALLING SP 

0042 


SHLD 

SYSSP 

/•SAVE IT 

0043 


LXI 

SP/STACK /-FOPCE PROGRAM STACK 

0044 


LHLD 

BOFP 

;get stapt of file ptr 

0045 


MOV 

A/M 

;get fipst char 

0046 


CPI 

EOF 

/•FILE EMPTY? 

0047 


JZ 

ERROR 

;AB0RT 4 REPOPT 

0048 


STA 

CCBYT 

;else save character count byte 

0049 


SHLD 

LI NAD 

;start addp of current line 

00 50 


SHLD 

DEST 

/•DEST FOP NEW SOURCE FILE 

0051 


CALL 

GTSRC 

/‘FIND START OF NEXT SOURCE LINE 

0052 

BEGIN: 

MVI 

B/CTRLZ 

/•BLANK SCPEEN 

0053 


CALL 

VDM 


0054 


LXI 

H/MSSG2 

/•POINT TO MESSAGE 

0055 


CALL 

VDPRT 

/4 SIGN ON 

0056 

INPUT: 

CALL 

SINP 

t LOOK FOR KEY PRESSED 

0057 


JZ 

INPUT 

/•NONE/LOOK AGAIN 

0058 


CPI 

ESC 

/•RETURN TO ALS-8? 

0059 


JZ 

RETRN 

;back to system 

0060 


CPI 

•T* 

/•TEXT? 

0061 


JZ 

PTFOR 

/•GO FORMAT PURE TEXT FILE 

0062 


CPI 

•A* 

/•ASSEMBLY LANGUAGE FILE? 

0063 


JZ 

ASFOR 

/'A DIFFERENT KETTLE OF FISH 

0064 

0065 

* 

JMP 

BEGIN 

;else operatop error 


0066 

PTFOF: LHLD 

SOURC 

z*HL = SOURCE FILE PTR 

0067 

XCHCi 

. 

IDE = SOURCE FILE PTR 

0068 

LHLI) 

DEST 

JHL = DEST FILE PTR 

0069 

LDAX 

D 

/'GET SOURCE CHAP 

0070 

CPI 

• . • 

/‘POSSIBLE TEXT "LINE HOLDER"? 

0071 

JNZ 

PTFRI 

/•NO/IT’S A NORMAL LINE 

0072 

I NX 

D 

;POINT TO NEXT SOURCE CHAP 

0073 

LDAX 

D 

/•AND FETCH IT 

0074 

CFI 

• . * 

/•PROBABLE ELLIPSIS? 

0075 

JZ 

PTFF0 

IFIP.ST dot was not a LINE holder 

0076 

MVI 

Mz * * 

;SUBSTITUTE BLANK FOR DOT 

0077 

I NX 

H 

;BUMP DEST PTR 

0078 

JMP 

PTFP1 


0079 

PTFPP: DCX 

D 

;REWIND TO START OF NORMAL LINE 

0080 

PTFRI: CALL 

MVRM1 

IMOVE TEXT LINE 

0081 

CALL 

GTNXT 

;CHECK FOR NEXT LINE 

0082 

JZ 

PTDON 

;eof encountered 

0083 

CALL 

GTSRC 

;UPDATE SOURCE PTR 

0084 

JMP 

PTFOR 

/•PROCESS NEXT LINE 

0085 

PTD0N: MVI 

A/ *T* 

;"TEXT" FILE TYPE 

0086 

STA 

HTYPE 

;INSERT IN TAPE HEADER 

0087 

CALL 

NDFIL 

;ENDFILE 4 FILL BLOCK 

0088 

JMF 

FINIS 

/•DISPLAY 4 SAVE 

0089 

* 



0090 

ASFOP: LHLD 

BOFP 

;HL = START OF SOURCE FILE 

009 1 

ASFP0: MOV 

A/M 

;get a char 

0092 

ASFPI: CPI 

EOF 

/•DONE WITH FIRST PASS? 

0093 

JZ 

ASFP2 

;YES/ BEGIN FORMATTING 

0094 

CPI 

QUOTE 

;test for start of • * case 

0095 

JNZ 

ASMP1 

;not a quoted byte 

0096 

I NX 

H 

/•POINT TO QUOTED BYTE 

0097 

MOV 

A/M 

J GET IT 

0098 

CPI 

• • 

,*IS IT A BLANK? 

0099 

JNZ 

ASMOR 

/•SOMETHING ELSE/ MOVE PAST 

0100 

I NX 

H 

/•POINT TO POSSIBLE ENDQUOTE 

0101 

MOV 

A/M 

;FETCH IT... 

0102 

CPI 

QUOTE 

J...4 TEST 

0103 

JNZ 

ASFR1 

/'NOT A VALID • • CASE 

0104 

DCX 

H 

/'YES/ POINT TO QUOTED BLANK 

0105 

MVI 

M/FILL 

/'INSTALL TEMPORARY DUMMY 

0106 

ASMOR: I NX 

H 

/'POINT TO CLOSING CUOTE 

0107 

ASMR1: I NX 

H 

;POINT TO NEXT CHAR... 

0108 

JMF 

ASFR0 

;...4 GO TEST IT 

0109 

ASFR2: LHLD 

SOURC 

;PT TO SOURCE BLOCK 

01 10 

MOD 

A/M 

/•GET FIRST SOURCE CHAP 

01 1 1 

CPI 

• * • 

;IS IT ALS-8 REMARK? 

01 12 

JNZ 

TSTLB 

;NO/MUST BE A LABEL 

01 13 

CALL 

MVREM 

J MOVE THE REMARK INTACT 

01 14 

CALL 

GTNXT 

;UPDATE FORMAL SOURCE LINE ADDR 

01 1 5 

JZ 

NOMOR 

/'EOF FLAG RETURNED 

01 16 

CALL 

GTSRC 

/•UPDATE PHYSICAL SOURCE LINE A DDR 

01 17 

JMP 

ASFR2 

;look at next line 

01 18 

TSTLB: LHLD 

SOURC 

;get ptr to physical source LINE 

01 19 

MOV 

A/M 

/•GET FIRST CHAR 

0120 

CPI 

• • 

I ALPHA HERE FOR LABEL 

0121 

JZ 

DOOPC 

;N0 LABEL/ FIND OPCODE 

0122 

CALL 

MVLAB 

/•MOVE THE LABEL 

0123 

DOOPC: CALL 

MKTAB 

/•FORCE CP/M FORMATTER 

0124 

CALL 

MOVOC 

/•NOV MOVE OPCODE FIELD 

0125 

JZ 

NDLIN 

/'PREMATURE EOL 

0126 

CALL 

MKTAB 

/•INSERT TAB AFTER OPCODE FIELD 

0127 

CALL 

MOVOP 

/'MOVE OPERAND FIELD 

0128 

JZ 

NDLIN 

/•PREMATURE EOL 

0129 

CALL 

MKTAB 

/'INSERT TAB AFTER OPERAND FIELD 

0130 

CALL 

FNDCF 

/'FIND COMMENT FIELD 

0131 

JZ 

NDLIN 

/•COMMENT NOT PRESENT/ EOL 

0132 

CALL 

MOVCF 

/'MOVE COMMENT FIELD 

0133 

* 



0134 

NDLIN: CALL 

GTNXT 

5LINE FINISHED/TEST FOR NEXT 

0135 

JZ 

NOMOR 

JEOF ENCOUNTERED 

0136 

CALL 

GTSRC 

JCOMPUTE PHYSICAL SOURCE PTR 

0137 

JMP 

ASFR2 

/'PROCESS NEXT LINE 

0138 

NOMOR: MV: 

A/ 'A' 

/•ASSEMBLY LANGUAGE FILETYPE 

0139 

STA 

HTYPE 

/•INSTALL IN SOLOS HEADER 

0140 

CALL 

NDF IL 

5MARK EOF 4 FILL BLOCK 

0141 

CALL 

SPFIX 

/'CONVERT DUMMIES TO BLANKS 

0142 

CALL 

LCASE 

JCONVERT COMMENTS TO LOWERCASE 

0143 

FINIS: MVI 

Bz CTRLZ /'BLANK SCREEN 

0144 

CALL 

VDM 



0145 LX I H/MSSG3 

0146 CALL VDPRT 

0147 CALL FILE ;DISPLAY FNAME & NEW PARMS 

0148 CALL TSAVE i ONCE! 

0149 CALL TSAVE S TWICE! 

0150 LX 1 Hz MSSG4 

0151 CALL VDPRT 

0152 YESNO: CALL SINP ITEST FOR INPUT 

0153 JZ YESNO /'NONE/ LOOK AGAIN 

0154 cp: ’y' ;signal to verify file? 

0155 JNZ RETRN /'FUNCTION NOT DESIRED 

0156 CCOPY: LHLD BOFP /'GET PTR TO START OF FILE 
0157 CPCOP: MOV A# M »GET A CHAR 

0158 CPt CTRLZ ;END OF CP/M FILE 

0159 JZ RETP.N ;YES/ RET TO SYSTEM 

0160 CPt TAB JELSE LOOK FOR TAB 

0161 JNZ CPOUT ;no, PUBLISH THE CHAR 

0162 MV [ Bz ’ • /'SUBSTITUTE SPACE FOR TAB 


Number 41 

26 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 





0163 


JMP 

CPOTI 

; DISPLAY IT 

0260 

INX 

H 


0164 

CPOlTTs 

MOV 

B* A 

;SET THE CHAR UP 

0261 

MVI 

M* • • 

J...PSEUDO-OP 

0165 

CPOTI t 

CALL 

VDM 

J SEND TO CRT 

0262 

DCX 

H 

JPOINT TO 'B* 

0166 


I NX 

H 

;bump file ptr 

0263 

DCX 

H 

JPOINT TO * D* 

0167 


JMP 

CPCOP 

;LOOP 4 DO NEXT CHAR 

0264 

XCHG 

. 

J DE = SOURCE PTR* HL = DEST PTR 

0168 

* 




0265 

MVOCF: LDAX 

D 

J GET SOURCE CHAR 

0169 

PETRN: 

LHLD 

SYSSP 

;get back calling sp 

0266 

CPI 

CR 

JEND OF OPCODE AND LINE 

0170 


SPHL 

• 

;RESTORE 

e267 

JNZ 

MVCFl 

J NO EOL* LOOK FOR FIELD DELIM 

0171 


JMP 

EORMS 

;back to caller 

0268 

SHLD 

DEST 

JUPDATE DEST VARIABLE 

0172 

* 




0269 

JMP 

LNDON 

JTERMINATE OPCODE FIELD 

e»73 

EFtF.On* 

LXX 

H# M55G1 


0270 

MVCFl! CPI 

1 * 

JEND OF OPCODE? 

0174 


CALL 

VDPRT 


0271 

JZ 

MVDON 

JTERMINATE OPCODE FIELD 

0175 


CALL 

FILE 

5 SHOW EMPTY FILE PARMS 

0272 

MOV 

M* A 

J PUT CHAR TO DEST FILE 

0176 


JMP 

RETRN 


0273 

INX 

D 

J BUMP SOURCE... 

0177 

* 




0274 

INX 

H 

J...4 DEST PTRS 

0178 

GTSRC: 

LHLD 

LI NAD 

;get ptr to formal line 

0275 

JMP 

MVOCF 

JCONTINUE OPCODE FIELD MOVE 

0179 


LXI 

D# 6 

; FORCE OFFSET 

0276 

* 



0180 


DAD 

D 

; HL a PTR TO PHYSICAL SOURCE LINE 

0277 

MVDON: SHLD 

DEST 

JUPDATE DEST VARIABLE 

0181 


SHLD 

SOURC 

JSAVE IT 

0278 

MVDNl: XCHG 

. 

J HL a NEXT SOURCE ADDR-1 

0182 


RET 



0279 

SHLD 

SOURC 

J SAVE SOURCE PTR 

0183 

* 




0280 

* 



0184 

MVREM: 

MV I 

m* •; • 

;CP/M REMARK 

0281 

OKRET: MVI 

A, -1 

JMAKE DEFINITE NON-ZERO 

0185 


XCH6 

• 

;DE » PTR TO SOUPCE 

0282 

ORA 

A 

JCLEAR ZERO FLAG FOR NO EOL 

0186 


LHLD 

DEST 

;HL * PACKED SOURCE DESTINATION 

0283 

RET 



0187 

* 




0284 

* 



0188 

MVRM1 : 

LDAX 

D 

J GET SOURCE CHAR 

0285 

LNDON: LHLD 

DEST 

J GET DEST PTR 

0189 


CPI 

CR 

JEOL MARK? 

0286 

LNDN1 : DCX 

H 

JPOINT TO LAST PACKED CHAR 

0190 


JZ 

MRDON 

; REMARK LINE MOVED 

0287 

MOV 

A*M 

J GET IT 

0191 


MOV 

MjA 

JMOVE CHAR TO DEST 

0288 

CPI 

TAB 

J CP/M FORMATTER? 

0192 


INX 

D 

;bump source... 

0289 

JNZ 

TRMIN 

JNO*APPEND CRLF 4 UPDATE 

0193 


I NX 

H 

;.. .4 DEST PTRS 

0290 

JMP 

LNDN 1 

JYES*BACK UP 

0194 


JMP 

MVRM1 

; CONTINUE MOVE 

0291 

TPMIN: INX 

H 

JPOINT TO TAB 

0195 

MRDONj 

MV I 

M* CR 

;CP/M END OF. .. 

0292 

TPMN0 : MVI 

M* CR 

JAPPEND CP/M... 

0196 


INX 

H 

;BUMP DEST PTR 

0293 

INX 

H 

J . . .LINE. .. 

0197 


MV I 

M*LF 

J . . .LINE MARKERS 

0294 

MVI 

M*LF 

J . . .TERMINATOR 

0198 


INX 

H 

;bump for next avail dest 

029 5 

INX 

H 

JUPDATE DEST PTP 

0199 


SHLD 

DEST 

JUPDATE POINTER VARIABLE 

0296 

SHLD 

DEST 

JUPDATE DEST VARIABLE 

0200 


RET 



0297 

XRA 

A 

J SET Z FLAG FOR "NO OPERAND" RET 

020 1 

* 




0298 

RET 



0202 

GTNXT : 

LHLD 

LI NAD 

;GET PTR TO LAST FORMAL LINE 

0299 

* 



0203 


MV I 

D*0 

; CLEAR HIGH OFFSET ADDR 

0300 

MOVOP : LHLD 

SOUPC 

J HL = NEXT SOUPCE PTR 

0204 


LDA 

CCBYT 

;get low ordep offset 

0301 

XCHG 


J DE = SOUPCE PTR 

0205 


MOV 

E« A 

JINSTALL PAGE ADDR 

0302 

LHLD 

DEST 

J HL = FILE DEST PTR 

0206 


DAD 

D 

J MAKE NEW FORMAL LINE ADDR 

0303 

MV0P1 : LDAX 

D 

J GET SOURCE CHAR 

0207 


MOV 

A*M 

;GET FIRST CHAR OF NEW LINE 

0304 

CPI 

CF. 

JPPEMATUPE EOL? 

0208 


CPI 

EOF 

;IS IT ALS-8 END OF FILE 

0305 

JZ 

LNDON 

J NO OPEFAND FIELD FOUND 

0209 


RZ 


jyes* ret with z flag set 

0306 

CPI 

' * 

JFI ELD DELIMITER? 

0210 


SHLD 

LINAD 

; UPDATE FORMAL LINE PTR 

0307 

JNZ 

MV0P2 

J WE HAVE AN OFEPAND 

021 1 


STA 

CCBYT 

;SAVE CHAR COUNT BY”E 

0308 

INX 

D 

JELSE CONTINUE... 

0212 


RET 



0309 

JMP 

MV0P1 

J... SEARCH FOP. OPERAND 

0213 

* 




0310 

MV0P2 : CPI 

• . * 

JALS-8 DUMMY OPERAND? 

0214 

MVLAB: 

XCHG 

. 

;de = SOURCE PTP 

031 1 

JNZ 

TRUOP 

JNO* GENUINE OPERAND 

0215 


LHLD 

DEST 

;HL = NEXT AVAIL DEST PTR 

0312 

INX 

D 

JPOINT AFTER DUMMY OPERAND 

0216 

MVLB 1: 

LDAX 

D 

;get source chap. 

0313 

JMP 

MVDON 

JUPDATE 4 RET 

0217 


CPI 

• » 

;ALS-8 END OF LABEL'' 

0314 

TRUOP: PUSH 

PSV 

J SAVE THE CHAP 

0218 


JZ 

MLDON 


0315 

LDA 

ASCSV 

J GET ASCII STRING FLAG 

02 19 


CPI 

* * ' 

; INTEL END OF LABEL'' 

03 16 

CPI 

- 1 

JFFH IF ASCI I STRING 

0220 


JZ 

MLDON 


0317 

JZ 

ASTMV 

J YES* DELIMIT 4 MOVE STRING 

0221 


MOV 

M* A 

JMOVE THE CHAR 

0318 

POP 

PSV 

JRETRIEVE THE CHAP 

0222 


INX 

D 

J BUMP SOURCE... 

0319 

TRUP1 : MOV 

M* A 

JELSE MOVE CHAR TO DEST 

0223 


INX 

H 

J .. .DEST PTRS 

0320 

INX 

D 

J BUMP SOURCE PTR 

0224 


JMP 

MVLB 1 

JCONTINUE MOVE 

0321 

LDAX 

D 

J GET SOURCE CHAP 

0225 

MLDON ! 

MV I 

M* * : • 

J FORCE INTEL DELIMITER 

0322 

CFI 

CR 

JLINE DELIMITER? 

0226 


INX 

H 

J BUMP DEST PTP 

0323 

JNZ 

TP.UP2 

JNO EOL* POSSIBLE FIELD DELIMITER 

0227 


SHLD 

DEST 

JUPDATE DESTINATION PTR 

0324 

INX 

H 

J BUMP DEST PTR 

0228 


INX 

D 

J DE = PTR TO SOUPCE AFTER LABEL 

0325 

SHLD 

DEST 

JUPDATE DEST VARIABLE 

0229 


XCHG 

. 

J HL = SOURCE PTR 

0326 

JMP 

LNDON 


0230 


SHLD 

SOURC 


0327 

TRUP2: CPI 

• ' 

J FIELD DELIMITER? 

0231 


RET 



0328 

JZ 

OPDON 

J YES* MOVE IS FINISHED 

0232 

* 




0329 

INX 

H 

JNO*BUMP DEST PTR 

0233 

MKTAB: 

LHLD 

DEST 

J HL = DEST FILE PTP 

0330 

JMP 

TRUP1 

JMOVE NEXT CHAP 

0234 


MVI 

M* TAB 

JFORCE CP/M FORMATTER 

0331 

ASTMV: POP 

PSV 

JRETRIEVE SAVED CHAR 

0235 


INX 

H 

J BUMP FOR NEXT DEST PTR 

0332 

MOV 

B* A 

J SAVE STPING DELIMITER 

0236 


SHLD 

DEST 

JUPDATE VARIABLE 

0333 

CALL 

CFDEL 

JDELIMITER HOUSEKEEPING 

0237 


RET 



0334 

ASMV1: LDAX 

D 

J GET STRING CHAR 

0238 

* 




0335 

CFI 

CR 

JANOMALOUS RIGHT DELIMITER? 

0239 

M0V0C: 

LHLD 

SOURC 

J HL = DEST FILE PTR 

0336 

JNZ 

ASMV2 

JNO* CHECK FOP NORMAL DELIMITER 

0240 


XCHG 


J DE = SOURCE PTR 

0337 

CALL 

CPDEL 

JUPDATE TARGET FILE 

024 1 


LHLD 

DEST 

J HL = DEST PTR 

0338 

XRA 

A 

J MAKE A ZERO 

0242 

MV0C1 : 

LDAX 

D 

J GET POSS OPCODE CHAR 

0339 

STA 

ASCSV 

JNO ASSUMPTIONS ABOUT NEXT LINE 

0243 


CPI 

• * 

JSPACE DELIMITER? 

0340 

JMP 

TRMN0 

JPREMATURE EOL = STRING DELIMITER 

0244 


JNZ 

TSTAS 

JNO* look for asc pseudo 

034 1 

ASMV2: CMP 

B 

JRIGHT STRING DELIMITER? 

0245 


INX 

D 

J BUMP SOURCE PTP 

0342 

JZ 

ASDON 

JSTRING IS MOVED 

0246 


JMP 

MV0C1 

J KEEP LOOKING FOR OPCODE 

0343 

MOV 

M* A 

JELSE MOVE CHAR DOWN 

0247 

TSTAS : 

CPI 

•A* 

JPOSSIBLE ASC PSEUDO? 

0344 

INX 

D 

J BUMP SOURCE PTR 

0248 


JNZ 

MVOCF 

J NO* GO MOVE OPCODE r I ELD 

0345 

INX 

H 

J BUMP DEST PTP 

0249 


INX 

D 

JPT TO NEXT CHAR 

0346 

JMP 

ASMV1 

JCONTINUE STRING MOVE 

0250 


LDAX 

D 

J GET IT 

0347 

ASDON: XRA 

A 

J MAKE ZERO 

0251 


CPI 

•s* 

J TEST 2ND OPCODE CHAP 

0348 

STA 

ASCSV 

JCLEAR OPERAND SWITCH 

0252 


DCX 

D 

J BACK UP IN EITHER 3ASE 

0349 

CALL 

CPDEL 

J DO RIGHT DELIMITER 

0253 


JNZ 

MVOCF 

JFALSE ALARM 

0350 

LDAX 

D 

J GET CHAR AFTER OPERAND 

0254 


MVI 

A* - 1 

J MAKE DEFINITE NON-ZERO 

0351 

CPI 

CR 

JPREMATURE EOL? 

0255 


STA 

ASCSV 

JOPERAND WILL BE ASCII STRING 

03 52 

JNZ 

ASDN1 

J NOT YET 

0256 


XCHG 

• 

J HL > "A”* DE > DEST 

0353 

SHLD 

DEST 

JUPDATE DEST VARIABLE 

0257 


MVI 

M* 'D* 

J WE ARE MAKING... 

0354 

JMP 

LNDON 

J NOTHING AFTER STRING CONSTANT 

02 58 


INX 

H 


0355 

ASDN1: SHLD 

DEST 

JUPDATE DEST VARIABLE 

02 59 


MVI 

M* *B* 

J . . .A PADDED "DB".•. 

0356 

JMP 

MVDNl 

JUPDATE 4 RET 


Pag*! 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

27 



0357 

0PD0N: 

I NX 

H 

;BUMP DEST PTR 

0454 

UCTST: 

CPI 

•A' 

;LOVER LIMIT 

0358 


JMP 

MVDON 

;UPDATE 4 RET 

.0455 


JC 

NOTUC 

/•OUT OF BOUNDS 

0359 

* 




0456 


CPI 

•Z’ + l 

;UPPER LIMIT 

0360 

CPDEL: 

MV I 

M/GUOTE 

/FORCE CP/M STRING DELIMITER 

0457 


JC 

YESUC 

;VI THIN RANGE 

036 1 


I NX 

H 

/‘BUMP DEST PTP 

0458 

NOTUC: 

XRA 

A 

/•SET Z FOR INVALID RET 

0362 


I NX 

D 

;bump source ptr 

0459 

YESUC: 

ORA 

A 

/* Z RESET ON VALID RET 

0363 


RET 



0460 


RET 

. 


0362i 

* 




046 1 

* 




0365 

FNDCF s 

LHLD 

SOUP.C 

;get source ptr 

0462 

TSAVE: 

MV I 

A/UNIT1 ;load unit/speed byte 

0366 

FDCF1: 

MOV 

A* M 

;get source char 

0463 


STA 

FNUMF 

/‘UPDATE SOLOS VARIABLE 

0367 


CPI 

CR 

JEND OF LINE AFTER OPERAND? 

0464 


LXI 

H/FNAME /’POINT TO CURRENT FILE NAME 

0368 


JZ 

LNDON 

/•COMMENT FIELD ABSENT 

0465 


LXI 

D/THEAD J4 SOLOS HEADP BYTE 

0369 


CPI 

* * 

/•FIELD DELIMITER? 

0466 


MV I 

B / 5 

/•ONLY 5 ASCII CHARS ALLOWED 

0370 


JNZ 

TSTCF 

/•COMMENT FIELD FOUND/TEST FOR EMPTY 

0467 

MORE: 

MOV 

A/M 

/•SHOVEL THEM INTO SOLOS HEADP 

037! 


I NX 

H 

/•BUMP SOURCE PTR 

0468 


STAX 

D 


0372 


JMP 

FDCF1 

/•CONTINUE SEARCH FOR COMMENT 

0469 


DCR 

B 


0373 

TSTCF: 

CPI 

•; * 

/•COMMENT DELIMITER? 

0470 


JZ 

SAVFL 

/•EXECUTE THE SAVE 

0374 


JZ 

TSCFl 

/•VE MAY HAVE A COMMENT 

0471 


I NX 

H 

/•ELSE HACK AVAY 

0375 


CPI 

• * • 

/'THE OTHER WAY TO DELIMIT A COMMENT? 

0472 


I NX 

D 


0376 


JNZ 

OKCOM 

JVE DEFINITELY HAVE A COMMENT 

0473 


JMP 

MORE 


0377 

TSCF1* 

I NX 

H 

/•POINT TO CHAR AFTEP SEMICOLON 

0474 

* 




0378 


MOV 

A* M 

/‘LOAD IT 

0475 

SAVFL: 

CAL- 

SPRAM 

/•DO SOME HOUSEKEEPING 

03 79 


CPI 

CP. 

/COMMENT FIELD EMPTY? 

0476 


LDA 

FNUMF 

/•GET UNIT 4 SPEED BYTE 

0380 


JZ 

LNDON 

/•YES 

0477 


LXI 

H/THEAD /-POINT TO SOLOS HEADP 

0381 

* 




0478 


CAL- 

VTAPE 

/•DUMP 256 BYTE BLOCK(S) TO TAPE 

0382 

0KC0M: 

SHLD 

SOURC 

/•UPDATE SOURCE PTR VARIABLE 

0479 


RET 

. 

/•END OF TRANSMISSION 

0383 


LHLD 

DEST 

JHL = DEST PTP 

0480 

* 




0384 


MV I 

m, *; • 

/•FORCE CP/M COMMENT DELIMITER 

0481 

SPRAM: 

LHLD 

BOFP 

/•ALS-8 > SOLOS HEADER 

0385 


I NX 

H 

/‘BUMP DESTINATION PTP 

0482 


SHLD 

LOADR 


0386 


SHLD 

DEST 

/‘UPDATE DEST PTR VARIABLE 

0483 


PUSH 

H 

;SAVE FOR THE MOMENT 

0387 


JMP 

OKRET 

/•SET FLAG FOR "COMMENT PRESENT" 

0484 


LHLD 

EOFP 

JEND > HL 

0388 

* 




0485 


XTHL 

. 

JSVAP TOP OF STACK 

0389 

MOVCF: 

LHLD 

SOURC 

/•GET SOURCE FILE PTR 

0486 


MOV 

A/L 

/•COMPUTE BLOCK SIZE 

0390 


XCHG 

. 

/•DE = SOURCE FILE PTR 

0487 


CMA 



0391 


LHLD 

DEST 

z*HL = DEST FILE PTR 

0488 


MOV 

L/A 


0392 


JMP 

MVRM1 

/•MOVE COMMENT FIELD DOWN 

0489 


MOV 

A/H 


0393 

♦ 




0490 


CMA 



0394 

NDFIL: 

LHLD 

DEST 

/•HL = DEST PTP 

0491 


MOV 

H/A 


0395 

NDFL11 

MV I 

M/CTRLZ 

/•FORCE CP/M END OF FILE MARK 

0492 


I NX 

H 


0396 


MOV 

A/L 

;get ls addr byte 

0493 


POP 

D 

JGET START 

0397 


CPI 

0FFH 

;IS BLOCK FULL? 

0494 


DAD 

D 

JADD OFFSET 

0398 


JZ 

NDFL2 

JBLOCK FILL COMPLETE 

0495 


I NX 

H 

JINCLUDE EOF 

0399 


I NX 

H 

/•ELSE BUMP POINTER 

0496 


SHLD 

BLOCK 

JSHOVEL IT INTO HEADER 

0400 


JMP 

NDFL1 

/•LOOP A FILL WITH CP/M ENDFILE MARKS 

049 7 


RET 



040 1 

NDFL2: 

SHLD 

EOFP 

/•UPDATE FOR DISPLAY A TAPE SAVE 

0498 

* 




0402 


RET 

• 


0499 

* CRT 

MESSAGE 

HANDLER 

0403 

* 




0500 

* 




0404 

SPFIX* 

LHLD 

BOFP 

;HL » START OF TARGET FILE 

050 1 

VDPP.T: 

MOV 

A/M 

JGET CHAR FROM BUFFER 

0405 

SPFX0X 

MOV 

A/M 

/‘FETCH A CHAR 

0502 


CPI 

ETX 

JIZZIT THE END? 

0406 


CPI 

CTRLZ 

JCP/M ENDFILE ENCOUNTERED? 

0503 


RZ 

. 

JSURE ENOUGH 

0407 


RZ 

• 

/•PASS COMPLETE 

0504 


MOV 

B/A 

JMAIS NON/SET IT UP! 

0408 


CPI 

FILL 

MS IT A DUMMY CHAR? 

0505 


CALL 

VDM 

J 4 VIDEO IT 

0409 


JNZ 

SPMOR 

/‘NO/ KEEP MOVING 

0506 


I NX 

H 

J 4 ADJUDICATE THE INDEX 

04 10 


MV I 

M/ • * 

/•SUBSTITUTE BLANK FOR DUMMY 

0507 


JMP 

VDPRT 

J 4 OBTAIN ANOTHER 

041 1 

SPMOR: 

I NX 

H 

/•BUMP FILE PTR 

0508 

* 




0412 


JMP 

SPFX0 

/•LOOP A SEARCH 

0509 

* CONSOLE MESSAGE AREA 

0413 

* 




0510 

* 




04 1 4 

LCASE: 

LHLD 

BOFP 

;HL * STAPT OF FILE 

051 1 

MSSG1: 

DB 

CR 


0415 

LCAS1: 

MOV 

A/M 

;get A CHAR 

0512 


ASC 

#F ILE 

EMPTY# 

04 16 


CPI 

CTRLZ 

;ARE VE DONE? 

0513 


DB 

CR 


0417 


RZ 

. 

/•YES 

0514 


DB 

ETX 


04 18 


CPI 

*; * 

MS IT A REMARK LINE? 

0515 

* 




0419 


JZ 

NEVLN 

;yes/ ignore a look for next 

0516 

MSSG2: 

DB 

CR 


0420 


CALL 

GETCF 

/•ELSE LOOK FOR A COMMENT FIELD 

0517 


ASC 

#TYPE: 

: "A" FOR ASSEMBLY LANGUAGE FILE# 

0421 


JZ 

LCAS1 

/•NONE FOUND 

0518 


DB 

CP. 


0422 

LOWER: 

MOV 

A/M 

;get a comment char 

0519 


ASC 

# 

"T" FOR TEXT FILE# 

0423 


CPI 

LF 

/•ARE VE DONE YET? 

0520 


DB 

CR 


0424 


JNZ 

L0VR1 

/•NO/CONTINUE CONVERSION 

0521 


ASC 

# 

ESC TO RETURN TO SYSTEM# 

0425 


I NX 

H 

/*HL = POSS NEV LINE 

0522 


DB 

CR 


0426 


JMP 

LCAS1 


0523 


DB 

ETX 


0427 

L0WR1: 

CALL 

UCTST 

/•TEST FOR UPPEP CASE 

0524 

* 




0428 


JZ 

NXTUC 

/•NOT UC/TEST NEXT CHAR 

0525 

MSSG3: 

ASC 

#SAVING CP/M FILE:# 

0429 


ADI 

20H 

/•ELSE BIAS UP 

0526 


DB 

ETX 


0430 


MOV 

M/A 

/•REINSTALL IN FILE 

0527 

* 




0431 

NXTUC: 

I NX 

H 

JBUMP FILE PTR 

0528 

MSSG4: 

DB 

CR 


0432 


JMP 

LOVER 

/•LOOP TO NEXT CHAR 

0529 


DB 

CR 


0433 

* 




0530 


ASC 

#VEPIFY? < Y/N)# 

0434 

NEVLN: 

I NX 

H 

JPT TO NEXT CHAR 

0531 


DB 

CR 


0435 


MOV 

A/M 

/•GET IT 

0532 


DB 

CR 


0436 


CPI 

LF 

/•HAVE VE FOUND EOL? 

0533 


DB 

ETX 


0437 


JNZ 

NEVLN 

/•NO/ LOOP A SEARCH 

0534 

* 




0438 


I NX 

H 

/•POINT TO START OF NEV LINE 

0535 

* PROGRAM GLOBAL APEA 

0439 


JMP 

LCAS1 

/•GO PROCESS IT 

0536 

* 




0440 

* 




0537 

ASCSV: 

DB 

0 

/•ASCII STRING SWITCH 

0441 

GETCF: 

I NX 

H 

/•POINT TO NEXT CHAR 

0538 

CCBYT: 

DS 

I 

/‘CHARACTER COUNT BYTE 

0442 


MOV 

A/M 

/•GET IT 

0539 

DEST: 

DS 

2 

J DEST FILE PTR VARIABLE 

0443 


CPI 

LF 

;eol reached? 

0540 

LINAD: 

DS 

2 

JCURRENT FORMAL LINE PTP 

0444 


JZ 

CFABS 

/•COMMENT FIELD ABSENT/ SET FLAG 

0541 

SOURC: 

DS 

2 

/•SOURCE FILE PTR VAPIABLE 

0445 


CPI 

'; * 

/•START OF COMMENT FIELD 

0542 

SYSSP: 

DS 

2 

JSTORE CALLING SP HERE 

0446 


JNZ 

GETCF 

/‘NOT YET/ KEEP LOOKING 

0543 


DS 

24 

/•THIS IS THE STACK 

0447 


I NX 

H 

/•POINT TO FI PST CHAR IN COMMENT FIELD 

0544 

STACK: 

ECU 

S 


0448 


ORA 

A 

/•CLEAR ZERO FLAG FOP COMMENT PRESENT 

0545 

* 




0449 


RET 

. 


0546 


END 



0450 

CFABS: 

I NX 

H 

/•POINT TO POSSIBLE NEV LINE 

0547 

* 




0451 


XRA 

A 

JSET ZERO FLAG FOP. FIELD NOT FOUND 






0452 


RET 

. 








0453 * 

Number 41 

28 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Pago 33 



E 


3 



P/m ©mid) 



Pogrom C©mPQDbiiiity 

BY JIM WARNER 

Chemistry Board of Studies 
Natural Sciences II 
University of California 

Santa Cruz, CA 95064 t^=^= -— ===== , 1 -aa 


Disk operating systems—CP/M by Digital Research (D.R.) 
for 8080’s and CDOS by Cromemco for Z80’s -have occasion¬ 
ally been called “virtually identical” (DDJ # 35). Cromemco’s 
Users Bulletin (Dec. 1978) makes more specific claims: 

.. CDOS was designed to be upwards CP/M-compat- 
ible... This means that most programs written for 
CP/M (versions upto [sic] and including 1.33) will run 
without modification under CDOS. This also means that 
programs written for CDOS will not generally run under 
CP/M.” 

Cromemco’s CDOS and CP/M share identical disk directory 
structures. In both operating systems, machin e language pro¬ 
grams are loaded and commence execution at 100H. The pro¬ 
grams, termed ‘transients,’ make calls upon the operating 
system for I/O operations through a single entry point (05H) 
which is independent of the amount of memory in the host 
computer. A JMP at the entry address passes control to the 
operating system, resident in high memory. 

Both CP/M and CDOS decode I/O requests from transient 
programs according to a function number passed in the C- 
register. CP/M provides codes 1 to 27 for access to disk files, 
the console, printer and other I/O devices. CDOS, patterned 
after CP/M, has adopted all of CP/M’s function codes. The 
principal difference between the operating systems is that 
Cromemco has included 14 additional codes not possessed 
by CP/M. CP/M is not protected against out of range func¬ 
tion calls and the certain result of an illegal call is a crash. 

Another difference is that function codes which open (15) 
and close (16) disk files and search the disk directory (17,18) 
return with registers pointing to the file name differently 
arranged if the operation was successful. More important, 
however, is that the returned value for an unsuccessful opera¬ 
tion is the same for CDOS and CP/M. The difference is 
important only for programs which read the directory as data 
(e.g., to prepare an alphabetized directory listing). 

CP/M 1.4 contains three undocumented function codes 
included in neither CDOS nor earlier CP/M versions. Two of 
these are used to set (28) and monitor (29) read -only status 
of disk drives. The nature of the last (30) is unknown to me. 
The codes are used by some of the utility pro-ams distributed 
by D.R. as part of the CP/M package. 

Finally, CP/M’s “jump vector” table can be used in 
programs that need direct access to I/O drivers. Such programs 

Page 34 


include track-at-a-time disk copiers, direct disk editors, and 
utilities such as PASTOCPM (DDJ, page 12, No. 37) which 
read files from non-CP/M structured diskettes. This table is 
the interface between CP/M’s system independent portion 
(BDOS) supplied by D.R. and the I/O routines (BIOS) supplied 
by the system configurer. The description of the table and 
the responsibilities of the I/O routines can be found in D.R.’s 
CP/M System Alteration Guide. 

The address of the jump vector table depends on the 
amount of memory allocated to CP/M and unfortunately D.R. 
has not specified how transient programs should locate it. As a 
result many programs from the CP/M Users Group which 
worked under CP/M 1.3 require modification to function with 
CP/M 1.4. It is a safe bet that these programs are not CDOS 
compatible. 

From the CP/M perspective it seems an unmanageable task 
to sort through 14 function numbers and treat them all as 
exceptions to the normal operating system. Some of these 
codes provide intricate (and dangerous) direct disk access. 
Others provide features unrelated to I/O such as integer multi¬ 
ply and divide routines. Happily, many excellent programs for 
Z80’s distributed by Cromemco are made serviceable with 
CP/M on treating only 2 of the 14 additional CDOS function 
codes. 

The first is READ CONSOLE WITHOUT ECHO (128). The 
result, a single character with the parity bit reset, is returned in 
the accumulator. A complicating feature of CP/M makes it 
necessary to bypass CP/M’s INTEROGATE CONSOLE 
STATUS (11) function. This is required because this function 
actually reads a character if one is available and saves it where 
READ CONSOLE WITHOUT ECHO would be unable to find 
it. 

The second important function code is FORMAT STRING 
TO FILE CONTROL BLOCK (134). HL points to the source 
string, while DE indicates where the file control block is to 
be set up. This procedure must pad the name and extension 
in the file name with the proper number of spaces while 
excising the period between them. The optional drive 
designator at the head of the string must be decoded and 
lower case letters must be converted to upper case. 

One of the CP/M function codes must be given special 
treatment. It is necessary to restore the accumulator after 
a WRITE CONSOLE (2) function call. If this is not done 
EDIT will not print control characters. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

29 
















An implementation of these modifications to the CP/M 
run time environment is presented in FILTER. Programs we 
have successfully run under our filtered CP/M include 
Cromemco’s relocating macro assembler (ASMB 02.15), linker 
(LINK), editor (EDIT 00.09), 8080 to Z-80 assembly language 
mnemonic converter (TRANSLAT V.2.1), machine language 
debugger (DEBUG 00.08) and 16K BASIC 5.0 (in 18.5K!). 

The location and installation of the filter are the final 
concern. The jump instruction at 05H will have to be changed 
to route system function calls through the filter. The address 
field of this jump instruction, however, serves a secondary 
purpose. It is read by many transient programs to find the 
highest memory location that they can use without running 
into the operating system. This feature must be preserved. 

Our solution is to put the filter in the memory page 
immediately below CP/M’s BDOS with the entry jump instruc¬ 
tion suitably modified. Its installation is similar to CP/M’s 
DDT in that FILTER, loaded initially in low memory, boosts 
itself into operating position. FILTER is not a permanent 
modification to CP/M. Rather, as explained in the listing, it 
is made a part of the memory image of the Cromemco 
programs which require it. The location of the installed filter 
will depend on the amount of memory available to CP/M. To 
accommodate variable memory sizes, FILTER contains an 
installation section which configures the actual filter to run 
at the top of the transient program area. 

To implement FILTER you will need to provide a system 
dependent value for the equate IGOR. This determines where 
FILTER will jump if it encounters an untreated CDOS func¬ 
tion code. If you have a ROM monitor program that preserves 
the registers, put its entry address here. Lacking same, setting 
IGOR to zero will force CP/M to reboot. This will destroy 
the evidence (C-register) of the offending function code, 
however. 

If your standard console input routine includes code which 
backs up the cursor and erases characters when you type 
rubout you will probably experience strange behavior in 
BASIC and EDIT. The easiest cure is to include a simple key¬ 
board input routine within FILTER in place of ‘GBYTE: JP 
Z,DUMMY’. If you make this modification be sure to remove 
the four instructions in part I which modify the address field 
of the JP instruction. These instructions are marked with 
*’s in the comment field of the program listing. If you make 
changes that lengthen part III by more than about 18 bytes 
you will also need to change the instructions in part II that 
set the stack pointer below BDOS. Finally, if your basic 
input output system (BIOS) changes the Z-80 index registers, 
you will run into difficulties that we have not fully 
documented. 

Filter does not resolve all differences between CDOS and 
CP/M. One deficiency is that the DIR command in BASIC will 
give meaningless (but harmless) results. The ability of BASIC 
to work with disk files is not, however, in any way impaired. 
It will usually be necessary to hit the ‘esc’ key twice instead of 
once to stop a RUNning BASIC program. BASIC and DEBUG 
contain commands to utilize the programmable timers and 
BAUD rate selection hardware found on Cromemco I/O cards. 
These commands will not work without Cromemco hardware. 

The present Cromemco software license agreement restricts 
the use of their software to a single computer of their 
manufacture. FILTER therefore will be of use primarily to 
owners of Cromemco computers who cannot run CDOS 
because their disk controller was manufactured by another 
company. 

Number 41 

30 


The author is a physical chemist at the University of 
California at Santa Cruz. He is shepherd to a small flock of 
microcomputers used in several laboratories for data 
acquisition and apparatus control in transient spectroscopy, 
molecular dymmics, chemical kinetics and nonlinear 
dynamics. 







Cl 

X - O 1 CO • Q x CO 










OOCEhmEhF-CCOX 


- CO 






OUCOZCX<QCOXEh 


Z X 

a < 

* co < 





0. 

• Eh M o CO Q CX . 


U M 

co 

\0 F-1 • 





o 

* J a CX - 


a Eh 

co z 

* a a 






mcxcouioqcoco 



a o m i-i . 






COCxCOX bC Z F 1 > 


Q Z 

a m 

Cl, Eh 





V 

X- FFOO< JC-h 


CO P 

Q Eh 

Eh 





Cl 

E-r Eh > M c/) Eh 


q a 

D < 

< a a 





c 

Z m C/) 2 Cx - cx 


o 

< a 

2 2 

a 




La 1 

Cx CO Cx CO M Q s 


U Fh 

a 

a E- 1 Eh 

a 





OJ >• Z DO 


CO < 

E- < X 

2j 




Cl 

5C0OEhEh<QZCX 


a 



IX 




c 

Eh QZMC0Z<<a 


z z 

p CO 

b c o 

< 





cx o CX X O 


5 M 

3 Z 


S. 




Cl 

< • U Z O m O a Eh 



Q M 

a c a 





e 

as CO Eh Cx U * Q 


a q 

< 

2 a o 





< 

< X Z U Q 


o CO 

a Eh 2 Fh 

b 




a 

< a Z F- CO ~ - CO 1 


a a 

o 

E- 






uo q-zhxou 


03 

• a 


>* 




< 

Eh O M Q S < - Eh CX 2 


a m 

a 

U C0 Eh 

cu 





m cX Eh 2 D cX EhEh 


d a 

si a 

z a 





z 

a U < b O CO .2 


Q 

m a 

< a a 





a 

Z OIEU W 


< co 

CO Eh 

2 < a 





X 

e> D • Q CX Eh IS M 


co 

a 


* 




t- 

z o a < z a is co 


a a 

. M 

a 

* 



a. 


mu • < x m a- 


o a 

< a 


* 



• « 

co 

xscoa O Eh >h i 


a q 


• o a 




•> 

co 

C CO S • 2 U m Cx Eh - 


a q 

a a 

< M 



co 


CO 

ZZhF’S.ZJO — 


a < 

. Q 

• Eh CO 



o 


-1 

O NS CO 



Eh O 

a u 2 



Q 

a. 


>• a COMSCOW » 



u 

• Z Eh 

r- 


u z 

•. 

CO 

CQ U C/D 2 O Z < — CO 



X 

Eh D 

ON 


M 

a. 

a 

EnEHOa^MWU 








a. 

Eh Q < CO Eh U Z CQ < < 




a > 



Z J 



CO o Cx MS 

X 

NS 

O 1-H 

2 Z O 



CO a 

a. 


C/DCxOOZ <CQM 

O X 


Eh 


in 


Z < 


CO D o CQ 5 CO CO 

u co 


a u 

a 



UUZE 


z 

a o a a 2 o >h 

• 2 


a z 

a u a 



a \ CO 


CO 

C/D EhOQCQmEhZcX 


NS NS 

P D 

o u 



CL Z CX Eh 

• a. 

O H-H h H Cx M * — ' O 

< cx 



a o 

< 


Z O u co 

1. 


CO ^ Fh s X 

CX CO 


< 

a eh a 

Z 


MM >h 

I* 

z 

ho OIOS DU >HCO 

U Eh 


a a o D cq 



Eh < CO 


< 

M-COXCCUIZCZ 

O NS rJ 


y. x h o 

a 


o u 

•« 

cx 

SCXEhOCOEh<S 

CX NS M 


Eh 


O 


Eh Z 

a. 

u 

M Eh ox cx o 







P 


o 

. ZEhCXCOFhOCOZ 

m a m a < 

o o 

1 z 

2 0 2 

z 


Cx Cx 


CC X >H o < c CO O 2E! M 

1 1 1 1 1 

a a 

M 

Eh Eh Eh 

o 




a ® a U SWCX2 fh 





w 


5 



ns o co J'v a co a 





CO 


Eh 


CO 

h zmu<az 2 





IX 


CO 

a. 


COEh<ZUCOCOCOOD 


>H 



a 



• « 

X 

ESU Jm 22 X U 


a x 

< 


> 



•- 

— UCXU<EhEhEh£X 


o X 

a 





r. 



.. u 

tD 3 

"HQ 

* i* i* 



NS ^ NS 1 ®. NS NS NS NS’St NS NS NS NS-NS NS NS NS NS 1 ®. NS ^ NS NS NS NS NS NS NS NS 1 ®. NS 1 ®. NS TSi 
NS is. IS ^ NS IS IS NS IS NS IS IS NS IS- NS IS IS. NS IS NS IS. NS IS. IS. IS NS IS IS IS IS- IS. IS NS NS NS 
NS 1 ®. NS NS NS NSn® NSNS ® NS NS 1 ® NS N® NSNS NS IS ISIS tS.TS.tS.'S.'S.'S.tS. IS 1 ® "0.1S IS IS is 
NS NS IS 1 ® 1 ® NS IS NS NS® IS® NS®® NS IS NS NS IS®. NS 1 ® NS 1 ® NS a®®®®®®®® 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Pago 35 




















O * U 

O 


0 

z ■** 


CO 

u z 

CO 


Eh 

u 

< X 


Z Cm 

02 


M 

u 

z 

M 

0 



2 u 

X 

U 23 


Z U 

02 

32 

CO 

32 CO 

0 

Q 

J < 

z 


0 < 



CO 

U tM O 

CO 

VQ 

CO 

Eh > 

.J 


CQ 

2 


x a 

z 

rH X O 

0 

Cm Eh 

* 

CO 

Q 

w 

0 

Eh 

z 



X < 

•H 

1 X Eh CQ 

0 

A 

* 



t X 

u 

J 

J M 

2 


32 


- 2 u 

u 

X 1 O 


1 

X 

.. a 


D 

X 0 

M 


X u 

X 

< O X X 


< 1 2 



CO 


Eh 

< 

O X CO 



< 

w 

- J X 

z 

M H 

Q 

X 

M 

CO 

CO 

X 

H - 

CO 

Eh 

X 2 

X 

2 2 

u 

U -H 02 

CO 

y 

Q 

CO Z 

< 

CO 

X Z X 


2 

U O 


XEQh 

Cm 

CO II Eh 

Q 

0 


W M 

CL 

Q 

Eh O < 

X 

CO 

M 

Eh 

CO O J 


CL N CO 

0 


CO 

< 



>H U X 

< 

Eh 

f- ^ 


< Z X 

Eh 

CO 

U 

CQ 

CQ 

CO Eh 

X 

X 

CD U 

a 

X 

X < 

X 

U Eh < 

< 

01 Eh 

CO 



►H Z 

CO 

O 

CO 

u 

CO 

co Z 

O 

XXX 

Eh 

< < 

Q 


Eh 

X 0 

Eh 

X 

EO* 



Z M 


X M X u 

CO 

2; 


X 

32 

Eh U 

Z X 


CO w 


O co 

2 : 

X 

X > 

2 

E- II 2 

E- 

Eh 

u 


w CO 

Eh 

XXX 


X J 

Eh X 

z 

£ a z e- 

O 

O >H O 

O 

Z 

HH 

X 

0 < 

CO 

M < 

>< 

CO *H 

X u 

0 

O 2 : O D 

U 

Z U Cm 

z 

u 

2: 

M 

CO- X 2 

CO 

X 2 

< 

N X 

O Eh 

z 

o^u Q. 


1/5 

x 

Z X 
5 W 

3 8 * 

a; 2 : 

u uo 

O • > U 
X < O • 
a • 2 * 
x 

Cm -OX 

O H E- O 

Em 

S Cm E- 
O O Z Z 
E-* 3 - 

E-Q.OO 
O O £ X 
CQ ^ 3 O 


>H 

>h 2 >< 02 

£ £ S O 

2 X S 33 0 

X Q 23 vO M 

SC Q - Q CO 

CQ * U - - N 
TS 1 C<I<ZN<UZ 


« l_| * N M - 

1 32 < - Z 32 < 


« H >J 

< Cm 32 < 


< — Fh < 

* - X X ^ 

— 2 • X X 2 — 

X 00 2T - ^ - m 2 X 

Q X - 23 - -NX - D DM 

—•■QlDQ<<ZIfflQ<^Q 


tM • cmxziw 2 : 

- hH > X • -TS -® q x < 
< (N U X • N VO U CN *—Q Z 


< co- 
32 - I 
TSX 
rvi U X 
» Q U H 
< 'H Q fc 


cm —' •—( 32 

- - - TS X 

XU CO ® O' 

32 CQ 03 D •—i W </> 


c^acaaQaa. 

UT^XEjXUEJ 


32 XX 

CO U U O U 02 U X U X 02 X E- 

XQZQX02ZQZXXO *QZQ<QCLo2ZQ<OQOCiJ 
D4jHju^Hj<^QxujHjuju^HjuxJao: 
F-* 


U CQ U 2 Eh 

OXXZXXXXXQZXX 
JU^HU^U^W JhQK 


U 2 fH U m 

IZ^U Q a X Q Q X ( 

3mQQ 2 z x x a x x x : 

8 I 

Q ( 


Eh 2 

CO CL CQ 

U U U 


IS. ®® ® 

® ®® Cm 

CQ TS- ®® VO TS 

®® ®® CD TS. 

U2<r-cN<wa'N 
CmUCOQUAIQU 


< vo r- cm 

cr TS. TS. TS- 

1 nvQcntjC 1 JTS.c 1 coTS.OOCQ Cm 
D^fN|v[M(N(Nn<H(N< 


CO TS U -h CO TS 
TS.TS.CM TS ®® 

(N n vO Q [J USA vd Q Cm Nh (jr 
hhsUCjcqncjsuC'HQu 


h TS X CQ TS CM TS U 

CM 1 —« CN®vO®CN DO 

xxoocnxcoxcovocNm®<jv 

r'CMcnojCMCMCMcnQ^H^H^HU 


CM VO rH i-H 

TS - ®. ® ® 

TS CQ TSTSTS 

TS. -vf TS CQ ® 

h QinnQn 

(NUSHUU 


r'OTUQ®.cnuivQOTOTOTa'<cQUQCM^CM^ , inr'OOcrvc'<cQQ®cMminvQCOcQUQOJCMCM'«SCN^tinr-OTCQQiM®rHm^fT3*vor'CO< cqcqXcncovqoocqcq 
vovQvDvDi^r s 't s 'r^r^r^r^r~r'r^r^i^‘r^cooooooococococooooocooTOTOv(j'<jv(jTOTO'OTO'OTOT<<<<<<<<<cQC3cQCQcQCQcQCQcQ cqcqcquUuuuu 

rtHHHHHHHHHHHHHHrHHrlHHHHHHiHHHHHHHHrlHHHHHHHHHHHHHHHHHHrlHH'-IHHH HHHHHHHHH 
®®®® ®®®® ®® ®®® ®®®®®®®®® ®®®®® ®®®®®®®®®® ®®® ®®®®®®®® ®® ®®®®®®®® ®®®®®®®®® 


CO X CO 

E- Eh J CO X 

X 02 CQ X cn 

M Eh < K 

cm co co Eh a eh a : 

2 0 a • z z► 
x 2 m x < x x m : 

X < CQ 2 X 2 Cm < 

< 5 X Eh < X C 

Eh Z < Eh 02 O 
CO Eh H Eh CO U Eh 

Z X CO z Z 

M O u M H 


— + + X — Eh CO 2 

VO »-H CM CE X rH < E-^W' 

X ^ 2 Z - 2 —- E- >h2QI 

TS * CL CL TS-— - - CO CQ - * * 

® X U U -vQXXXXXUXXXO*JX: 
rH I —''—320 —• Q X X 2J I ^ X XX^X X' 


U U UUUUUU Q »-* 
32 QQQCiJQQXQ 2 ZZQZZZQQQQQQQC! 
OJJJQJJUJhhhJhhhJJ<JJJJJ 


< Z Eh • 
O CO 02 
CO 02 X 
Z Hh 
h U Cm J 
<J w 
Eh m . Cm 
Z Cm Z 
O O X 
U 2 ! m 32 
O Eh Eh 
- U m 


I X CL Eh 
Z o D 
M o Eh CL 


X 


5 










X 

O 






Q 

CM 

M 

X 

a 

Q 

* 

X 

u 

CO Q 


X 

CM 


D 

a 

co- 

« 

X 

X 

w X 

Eh a 

• M 


Eh 

c 

< 

X 

« 

< 

X 

Eh 

x x 

X 2 

X 

02 

< 


> - 

* 


1 

Eh 23 


u 

Q 

< 

X 

a 

0 <0- 


(0 

< 

CO O 

5 23 

0 - 

0 

CL 

X 

2: - 


X 


X x 

O O 

X * 

u 


X 

Eh 


02 

a 

X 

D 

X X 

X - 


>H 

Eh 

< 

Q ® 

X 

0 

X 

O 

X 


z 

X 


8 C0 X 
32 U 
JXE< 


Cl • CO Q 


X TS 

Eh 



U 


X 

O 

X Q 





Eh U 

X M 

X * p Z 

Eh 

XXX 

CO 



O O 



M 

X X 

M —- 


Eh 


z u 

Eh X 

X CL < 

X 

+ O 




0 x 


X 

F- 

0 C£ 





0 < 


X X 

0 

X 25 X X 




O co 

X 

a 


co O 

E- CO 




u 


< x 0 2: 


X 5 X 




X x 

X 

O 

2 

Z Eh 

O 


— O 


Eh 

£ 23 

EEE\ 


Eh O E- •* 





H 

u 

D 

O co 



O IH 




CO Z CL 


x a x 




X 0 

X 


X 

U X 



X ffl 


X Z 


Z X M u 


H </> t —1 




X E- 

M 

z 


X 



U 




►-H > 


xxx 



0 

Eh 

X 

0 

CO 

0 

Eh O 


X 0 




0 a z 


1 > 1 



z 

X CL 



< 

Eh Q 

< E- 


h- 


X 

a 

E- 2 Z X 


2 0 Z 



X 

l-H 2 

X 

Eh 

Q 

Z 

Eh 


O 


O Q 


X < X 


222 



CO 

X »-3 

0 

u 

U 

X < 

CO >H 


Z >H 


E- S 

1 < 

X O 2 


O O 





a 

z \ 

X 

X 


X 



Eh 

•"3 Eh X Eh 


a •* a 




•» •. 

u 

D 

2 

Eh a 

X Eh 


Eh 


O Eh 

X - 

X X 


co- <0- 






X 

X 

u x 

X u 


X u 



s 



U x 


U 





u 

< > 

0 X 

2 x X 

S 

PH 

CO- 



> > 


W 



® 

X 


a2 < 

WXSOKNX - 

Eh 


VO 

O X O X X 

X 



>-H 

X 

0 

< CO 

Z M 

X 

CO M 

X 

Eh X 

O Sh 

Eh Eh U 

w 

2 a 2 0 x 2 




Eh 

2 

32 

O Q U Z Q 

u w X 

CN Z 2 

X X w < 

« 




Or 

X 

cn 


hH 

U X 

U 


0 


X 


H O H fn 

X 

X X x X X 

X 


L-i 



2 

CQ 

a 

Q 

u a 

Q Eh X • 

Cm ‘-nx 


a 

W tH X X 

co D U if* 


+ 

O 

.. co 

5 < X Z 



< < < Z O 

Eh 








* 

X D Eh Eh 

u x 

D 


D 

2 x a 










+ 

X 

X h CO 

X CO 0 

< X 

O 

X z X 


X X X X 








•k 

O Eh X 23 

X < 

X 

X < 

X 0 0 < 


Eh X O Eh 









X 

u 5 2: 

ux<xx<xau 



X CQ 

Q Q X Cm 

QQQQQDQQ<CLW 

xx<x<xxxuxo 


2 X 

CO X a Eh CL 

DQCL02<OCJOa 
fl. JU>2U(LXCL J 


®®® ® TS TSi ®® IS®®® 

VO rH X ®V0 rH < H in CO O' < rH TS 

® vq vo ®® ® vq r»^J- co o> in r- co 

<N(NinUfMca<nnfnfMnfonNH(j\(N(NHHQ 
CNCNCNCMCNCNXCNCNCNCNCMCNCNCNCNCNrHCNrMCN ®i X 


® VQ ® ® ® kf 

CQ h <jv h < or in 0> < 

in cm rH co ®® co ® 

QQQH(j\ j\hUQQQ 
COQQCNrHOurH-SUO® 


cn in® 

®®® 

in(JVCO®QrHOTrHOV 
Cm Cm CN U Cm U Cm r- 


S®n vOfl'<utM® |, ’ , tinioo'<auLMnvO(J'ULHHHHHHHHinoTcQU[M®ninffi<<<<<<<<<<<<<<<<<<cQuu®(nifinvo 
®®®®®®®®. rH HHHHHHHHHNiNiNtNMNnnrmnmnnfndfifin^'f'fvf^ininininininininininininininininininininiovovO'O'O 

HHHHHHHHHHHHHHHHHHrlrliHHHHHHHHHHHrlHHHHHHHHHHHHHHHHHHHHHHHrHHHHHHHHHrlrlrl 
® ®® ® ®®® ®® ®® ®® ®® ® ® ®® ® ® ®® ® ® ®®® ®®®® ®® ®® ®® ®® ®TS®® ®TSTS® ® ® ®. ®TS ®®®®®® ®.TS ®® ®®®® 


Pago 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

31 


























Changing SPI Formatted 
Programs to CF^M 

Compatible Text 


BY MARKM. ZEIGER 

198-01B 67th Ave. 
Flushing, N.Y. 11365 


Many computer hobbyists who started a few years ago with 
relatively simple equipment probably used assemblers such as 
Processor Tech’s SPI or ALS-8. Now they have ‘graduated’ to 
more sophisticated operating systems, CP/M being the most 
prevalent. Think of all those great source programs still on 
your cassettes that you would love to rewrite to use with 
CP/M. However, who has the time to do all that retyping? 
Computer to the rescue! The following program will change 
source programs written by the SPI executive (as well as pro¬ 
grams written by ALS-8, XEK, and the PDS assemblers to 
name a few) to text acceptable to CP/M assemblers and 
editors. 

The program is quite simple to use. First the SPI file must 
be saved on the CP/M disk. Load the source into RAM at 
100H. Then boot in CP/M and type 

SAVE xx NAME.EXT. 

Next run the change program by typing the command line 
CHANGE NAME1.EXT NAME2. EXT 


the text so that labels, code, and comments are neatly placed 
in columns. The end of the SPI file is denoted by an 01 
which is searched for by MOVEREC. The subroutine RE- 
STORENEG is called only if a line number is located in two 
different records. Any run-time error will abort the program 
with an appropriate message. The CP/M file will not be written 
if there is an error. 



where NAME1 is the name of the SPI source file and NAME2 
will be the name of the CP/M compatible file. Each file may be 
prefixed by a drive designation. For example, the command 

A >CHANGE B:LIST.SP1 LIST.ASM 

will change the file on drive B called LIST.SP1 to a CP/M 
compatible file called LIST.ASM and will write the file on the 
logged-in drive (A). Note that both the source and destination 
file must be specified when running the program or a run-time 
error will occur. 

Much of the program is self-documented. Studying the 
CP/M interfacing guide and the program will help in under¬ 
standing most of the program’s logic. The major subroutine is 
MOVEREC. This routine reads in one record (128 bytes), 
takes out the fine numbers and character count found in 
SPI text, and substitutes a carriage return-line feed for the 
single carriage return in the SPI source. It will also format 
Number 41 

32 


UJ 

X 


o ox - o ► 

O OO IIIDCNOHIOCTIPO X cl t 

rt O m OIHHNNNNHH- X V) 

c 

O =>X> — o - 

cr oo oooooooooo x <f: 

O UJ UJ UJldUJUJLUUJUJUJUJUJ _J O l 


UJ 

in uj u _j 

UJJUUUI- 

r — UJ UJ cc u. 
< u. a. or uj uj 
zzduh-w 
h* ui < > — o 
ujQ-ujoq: j 
uoaijo 



<<<<<< 

oooooo 



X CL UJ 

_j in ,atr 


o —J UI 

a . ui u. — -j < uj 

Z> C_> 3 UJ U Ihh 

O oo cr: cq;:v)ujqij.qujuj 

CO 03 h IJ O Y < h I - 

oo arc —i<ujq:ujujuj-j 
cd {/> Q-Ousaxwoorcfl 


■ ■ i ii i ■ i 

O lAO C71 U- 0(0 J 

O OlA O C) rt H H 

rt OO ooooo 

o oo ooooo 


O CM CM 



o o o 

HOINH 
III! CM ro CM to 

<OQo 

rt HON OOOO 
OOOO rt rt rt rt 
OOOO OOOO 


NNKMOK1 J- CM 

O O O O o o o 

Ktri U Ifc O 1^ 

CD hJ O N O H O 

oooooo < ai <71 

OOOOOO cm U. <_> 

< O O K1 ifi O) O U. O 

O O rt rt rt rt rt rt <M 

rt rt rt rt rt rt rt rt rt 

OOOOOO OOO 


HNKtJUMfiNCOCIOrtNKUiniONOOOIOHNKI^UMONtOOIOHNI'IJ 
rt rt rt rt rt rt rt rt rt rt CM CM CM CM CM CM CM CM CM CM K1 K1 K1 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page' 37 




[> — <>■ 
■03K0: 
> X </></) X < 


■IMDH* 

> eo to < o < 


J — M < 0- - 
: Q. 2 »— X c 


o uj uuj o 

O UJ H b- Z UJ 2 UJ 

CD UJ az 2— X DC — X OCX 

< CC UJ O O -J < UJ _J < UJ < 

>- o co QK-J-JOo »— X o »— h 

O x < O < — o O -j xO — UJ xO — xO 

2 < ►— XQB>UJUKUJ<UJO< ouaz< DUa< 

X OCX X X X J >< t 

- m — < < x x oc cc < a: < m — < x a a. — < x oc — < »- 

.Z>H|-ZZUNUNQUhZ>f-ZUNS>hZUN>l-UJ 

J-JZ WW-OOQt)-JOV)-3Z<0—OO-DZV) — QOZ^OC 


< — to CO >> CO 
OZDDDOOD 
UU<(LD.ZZM 


OH K\H H KMO KM« K\ H K> IO H JO (OHIO IO H K»K>HHK\ K\ K> ^ 

OO OO O NNOOOQ OOOOOOOOO OOOOO OO O 

OOO^ H io O H U)N O WWOONnO lOCOHHU5<UHIfiOU)OtH O O 04 CM O < 00)< 0< 

OO OO OO o < o CM O CM O CM CM O O CO CN O »K»NCMOONNNOON»ON O o CM CM LA O U O O OH 

U)U J HHUJUJ<UJ(MUJl0CMC0U)NK'lOUUU<UJU(MUJCMNI«NUJNCMKMlJNUJCMCMK>KMflOClU<QCMNUJ(MKNQOKlUJNK\OOUJN01 
OO NHML OK\Kcr^OK\r^Oj»CMCMU-OU.K'U.rs.OU-OK\OU.OK\OU.OK\rA^CMHOOOOK\tAcAOr^HHOOOKNHrHOOK\r-»0 

U.HK\lOOt<UU.HjnflN<COQUJrtJN<OONKMOMCOUJHOU)ClUUJHK\iON(00'<QUJrtJ^OOCQOUJll.OKMOOOCn<(nUJoH 
NlOKMOWKNK\K>^jf^J^rfJrfininirtl/\LflU)«)lOU)tOUJU)NNNrsNN«a)flOOOOOCOOOOOOO{JIO>OtO)fflO><7ICn<<<<<<<<CDCD 
K> K% K* K>K% K>lOIOJOK\K>IOWKMOtOlOK\K>K\K>KlK\K\KMO(0»OKMOKWOKMOlOK\KMOKMOK>KUOK»IOK>KMOKMOKlKM<\K\K>KMOWKNrf\(0 
OO ooo o o o o o ooooooooooooooooooooooooooooooooooooooooooooooooo OO 


CMKMftlONCOOl 
CO CO 00 CO CQ 00 CO 
K1 K> KUO (O »0 IO 

o o o o o o o 


Cl O H (M K\ J IA ION #C10HCMlOJUlU)Oo0010H(MK\4lOiOS«OClOHCMKlJI/MCNOOOlOHCMI''JI/llON«C'OHNlOjriniCSaOCIOH CMK\ 
O iM H H H H »-< HH HHCMCNNN(MCMNNNNKUOlOKllOIOlO|OIOl04rjJJJJJJ^JlOlOlOlOlOlOl/UOkOlOlDlflU3lOlOlOU>UJlOU)NC»rxN 


J UUONCOCUP HCM 


X O X 3 

Q xO C 

O X O C 

xO X 

- o - 

JC »4I i 

vi- a- - 
•a — a- u 


"OO *T 
O *■* X t 

c yj o o < 
c a> o * 

OJ 4) u % » 

- WTJ - 
H- (A •— £ 
<0 C 3- 

c a u u- 


3 « VI I 
O *> O— I 
to OC Z O l 


uj o 
X a: 

< 3) 

2 0 -» 

> 00 O CM « 

O X X X 

> z x < co : 


) </3 H JMWkMW IA UJ to to 
>oxocujujo<ujoxoco-ujo 

>OU.OOOOZOOU.OOOO 

x CD U- CC x % CO % xflO U. ce x x 00 

j 00:00 00 oocoo 


) to O to CQ 00 00 00 
lOUJO OOOO 


< — 

CD co m O D- M £ 

OOO JOO. 


) 2 X > > 
> -3 -» X X 


>X0CNh 
O 2 O 2 UJ 
X — O “3 DC 


X u. u. o a. 1 

- o o o cc o : 

►— CO (/> < Z> to CM Q. ( 

: uj 2 o uj o o oc ; 

IW-DCtOO o — • 

- X X 00 x x 00 OC 

o o o o h oc x : 

-J -J UJ 

) — — -j — — -j — a. • 
)>x<>x<a.ix40 i 

-X-JOX-JOO-DQ-. 


u. x > 

U. 3 j— < HCMKl J 

ooo to to OOOO 

CD h- x ^ WWWW 

20 UJ h t/0 to (/> to 

— O 2 to xxxx 


X 

VllfiN < 
OOO 2 
to IO 10 H 
to to to UJ 
XXX -'O 


00 cm j Dm u. K j 

CM O MO IO l£> IO N IO 

OO IAHOKICMOO 

CM O N IO CM fx N CM CM 

OO UlAU.OlNU.lL 

CM O lOlOlOIOMOlO 

kA O O O KO CM UJ ^ IA UJ UJ 

OOOOI I lAVUIJ J J J 

e-SIMSAHO-^-JlAj- CO O CO CM UJ OO KO 

NNCMKICOJUOO ONKMAIAfxOI 

H HHHOHHCNCM CM CM CM CM CM CM CM 

OOOOOOOOO OOOOOOO 


o o o c> o o 
ooaoo on UK 1 U 

IA CM O CO CM rl CO CM O 

< UJ < < UJ < H H CO UJ 

Kl U. u IA U. O CM H O rx 


CM o CM 

OO O 

ao ao o 00 < 

O to O H o 

NKIKUANHUJCONKUANOI 
HCMHOOCMKNOHxCMOOO 


Kl CO OO CO UJ C KiiOOIISUOUJUi O K)ion<(lOUOO 
CD CO CD CQ COt OOOOOOOOOOOOOOOOUJ 
CM CM CM CM CM CN CMCM<M<MCMCXCM<MCMCMCMCMCMCMCMCMCM 
OOOO OC OOOOOOOOOOOOOOOOO 


OO K\ HO HO K\ HO 

OO O OO OO O OO 

U-UlAU.OKlKUAlOKUAU.OlU.KllA 
O LA o u_ uj h cm o h cm o u. U- o cm o 
UJ rlQUJ<UJHOUJHQUJ<UJHOOI 
OHOU.OOHOOHOU.OOHOO 

HKUOOICDUJOlAlOCOffiUJOKUAOOOO 
LUUJUJUJUJUJU.U.U.U.U.ILOOOOO 
CM CM CM CM CM CM CM CM CM CM CM CM KA NA KA KA IA 
OOOOOOOOOOOOOOOOO 


LA OO OO WHO 

o OO OO ooo 

J1<0 IA 4 UlA HK1H O 
OH 00 OHIAOOU-O 00 
lAUIHOUJHOUJ<HH 
U.OHOOHOU.OUJCM 

UONIA»<OONIAO) 
O H H H H H H CM CM CM CM 
KUAKUAKUAKUAKUAKI 
OOOOOOOOOOO 


IJIAlONtoa OHNWJlAlONcoOIOHNIA^IAiflMO 
ICOOOtOCOOOCOOIOIOIOIOIOIOIOIOIOIOOOOOOOOO 


Page 38 


Dr. Dobb’s Journal of Computer Calisthenics 81 Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

33 






At****************************************************** 


CPM-Pen / 

PcnCPM 


BY ROD HALLEN 

Road Runner Ranch 
P.0. Box 73 
Tombstone, AZ 85638 

The following letter written by Rod Hallen to Jim Gagne 
is a fitting introduction to the listings which follow. 

Dear Dr. Gagne, 

In March I wrote to thank you for your Electric Pencil to 
CPM routine (DDJ #33). I have found this to be one of my 
most used programs. Thanks Again. 

Recently I acquired Digital Research’s “MAC” macro 
assembler and was looking for a project to use it on. That’s 
how I learn the ins and outs of any software that I add to 
my library. I decided to see if I could simplify and speed 
up your program. The enclosed PRN listings are the result. 

The limited length of PEN-CPM and CPM-PEN are due to 
the macro routines which handle all disk I/O. Have you tried 
“MAC”? If not, it is well worth the price. Both of these pro¬ 
grams were written in less than 3 hours time; an easy after¬ 
noon’s work. 

I wrote these as two separate programs since 95 per cent 
of my conversions are from Pencil to CPM. I write my as¬ 
sembly listings on the Pencil, convert to CPM, and test. If 
something isn’t right (most of the time!), I reload the PCL 
file into Pencil and try again. I have also eliminated tab 
handling in PEN-CPM and line length considerations in both. 
I only use these programs for assembly language listings and 
never use a line longer than 72 characters. 

You mentioned in your DDJ article that you were attempt¬ 
ing to change the disk read and write to 512 byte blocks. 
This is extremeley simple with “MAC.” Note the 1024 at the 
end of the INFILE and OUTFILE lines in the programs. 
This is the number of bytes read or written at one time. The 
only limit on this is the amount of memory that you have 
available for buffers. Almost everything that your program 


acccomplishes is handled automatically by the routines in the 
SEQIO (SEQuential I/O) libarary which comes with “MAC.” 

I’ve added one routine to SEQIO. LIB. That is MESS 
which is my message printer. It is described in PEN-CPM.DOC. 

These two programs have accomplished many things for 
me. They have cut down on disk activity, reduced the con¬ 
version time, and eliminated a bug I couldn’t get out of 
PENCPM. They have also made me aware of the capabilities 
of macro assembling. 

The bug usually left garbage at the end of an assembly 
language listing that had been converted from Pencil to CPM. 
This garbage consisted of the last few lines of the listing re¬ 
peated one or more times. This didn’t, however, affect assem¬ 
bly because my assemblers stop at the first END OP code. 

As proof of the increase in conversion speed, PEN-CPM 
takes exactly half as much time as PENCPM. The same is 
true in the opposite direction. I have one question about 
PENCPM. You save the old stack pointer and set up a new SP, 
which I think is a good idea for any program that will use the 
stack extensively, and then restore the old stack at the end. 
However, then you call for a CP/M warm start which restores 
the old stack pointer again. Why not a simple RET at the end? 
This returns to CP/M without disk activity and is quicker. 

I am sending a copy of this letter and the enclosed pro¬ 
grams to DDJ for possible publication. I am also sending a 
disk copy of both source and command files to the CP/M 
Users’ Group for inclusion in one of their library disks. If 
you do not have “MAC” and you would like a copy of the 
command files, please send me a soft-sectored 8” diskette 
and $5 and I will record them for you. I find it necesssary 
to charge for this service since programming and writing are 
my only income. 

Sincerely, 

Rod Hallen 


Number 41 

34 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 








w 


CA H H 

O 


o —• 0-0 

2 


X Z 2 U 

X 


H X X O 

cn 


X Z H 3 2 2 


H 

2 U -• J X X 

Q -• 

XX O O CA 

<x 


O U W O 

o 

Q 

XX H W 

-1 

55 

H O O 00 X X 



W Z H 2 Ul O 


CA 

OHCAHZX 


a 

H 

TRIC 1 

, CR 

z w 

I O l 

-« o 

W l 

o 2 

-1 1 

X X 

w 

X H 

- w 

O + H 

O CA 

H - U 

<x 

% J 

HZ Z 

u X x 

CA O X O 

J J X 

-< u — 

— . o 

q H H H 

X X o 

J 2 Z -• 

o 

oo-.cn 

Z *Z 

o o o 

^ X o 

X J X X 

X O -i 

o 

o *cn 


x x x x 
O O w 
U4<Ih 
OHHU 
<1 0) CO 2 

x a: 

0 3 3 2 
H U U X 
(J1ZZU 


X H -.go 

is a. (A (A x 2 

(MHO O X H 

20020 N 0 U 



■d t. p 


01 

• a me 

X 

x> * 

• X — 

cn 


-- AP 

2 

O 4= 

a— x -d 


■p p 

a - H -d o* m 
d 3 -CL 

B 



H H 

3 u 

CA CA 

CO 

CQ CD 03 

§ 

* cn 2 »d ►o 

X X 

a a 

a 

Q p a 

w 


(A (A (A — CM 

3 3 0 (A (A 

w a. w u 

“° ZU *5-S 

d d cm 


X i x 

4 X X 
P 4 X 
i. P - 

M • C • 

- > >» e 

c m d 

S o c 
otJ « 
CL C — 

I 4 4 — 
X£ Eb. 
CL P E 
O o J 
•d O O i 
L C CL : 
O d 

u. . 4 • 
= J £ 

x 4 U d 

* a cl c 

p >» . 4 
c p 4 — 
>* 4 £ - 

■d x « x ■ 

5 -: 

£ E u. I 

8 V S 

o • -d a. • 

p — E * ' 

u x d m 

• c — • 

fc S • X 

o a. xi a. 
u i o 
x - i 

2&-3 

H = 3 CL 


X 4 4 ai 

> m — 
• « d - 


X v • - 
X o £ d 
. c — c 
• *> - 
E « • tr 
<*E- 

C O O L 

• -d ui o 

- 4 — >> 
U. w E 
s 4 


w d — • 

L • o >»p 
• 4 C. 3 u- C 

— — — — * 
— jq d x p 

<*■ £ a d c ui 

• P4 — 

OQ m (. c -d 

« W • >) - 41 


O O - ♦> 41 

M l J 

<3 o 4 4 4 

Ul d L L — 

(A E L 
W o 4 
• = I O x: . 
£UQ -PI 


M» E > 

2 



CA 

a 

X 

o o - 

— do 

X 

4 . W 



X 

X 

X -1 Q 

X c 

o z 

£« 4 


? 




p 4 cr 

P 

P 

4 

H 

c 



— C 

in 

d X 

o* 





c — — 

C - 

>» X 

d 




O 

— X p 

o £ 

X C X 

M 

X 

■d 


CA 


■— a 

- X 

Ul 

J 

4 


x cn 

• J u 

P L 

o 

4 


M 


X <9> O 

-03 

— « p -d x 

E 

X 

d 


« *Q 

— x 

TJ 4 

C P 


o 



q o m 


<*• P M 
d d o 
-do p 

• • 

p 4 E 4 

L £ 4 l_ 

• p m d 

> -p 

C L 4 4 

o O JZ 4 
UU.PL> 


4 4 4 3 J 

as -p *d 
o* c — = 
c — — d x t 

-400X1 
3 -p O-X: X 

o — M X I 

— a* w i 

— — 4 4 

o O CP O' I 

<*- 4 4 (A l 

£ M M (A 

• P 4 4 W I 

£ — 4 4 X ' 

H 3 E E = j 


© © CO CM (A 

9 9 IS is is 

9 x in in n 2 a 

(M H O O 9 X © 
UQ4U(MiO«C) 
©0©©MU00 

ma9©dr-©o 

©©HHHHNH 

(ACACACACACACACA 

SSSSEQlSlS 





is + ® 



is 

Q © O 


o 


(S 

IS d- IS 


X CM 

co in 

m 

© IS d 

© 

H © 

© © 

o 

O X IS 

CM 

m co 

CO (0 

© 

co co d 

d 

is IS 

IS 01 

IS 

is IS IS 

9 




4444444444444 ******** 


* 0/0 

e 


▼ 

44 


CO 

(A 

O © 

h m 

CO 

(A 

u 

-J H M 

— 2 <t 

X X 

X O © W 

h X N Z 

CL © O 
O J — H © 

I —' CA I s - 

Uhffld 

3 SSSS" 

CL 2 a. —• h >* 
l J X J 
X (AU> 3 
a. z — a. (A »d 

O 2 X O H 

X H O © 
I HO X CM 

Ul ~ O 
O -I O CO 
H W 


J X 

4 O H . 
>• — X 3 X 

ooo o o 

as a x :c 

XdUHI- 

j x a) - :d 

as 33 ' 1 

as o m o ui 
u i m j :c 
z o i- 

8 0 H Cl) 

z o 

ca z a: u 
d as o o 
o >* 

u u. <t cn :s 

ffl X u o 

(A (A I-* 
>HHOm 

2 (A a. ia 
— a: 

_ > o :c 
x m - a. ik 
2 m ca i j 
as o z j il 

g I 25 ! , 

as as h o iJ 


. 

^ O J 
X o 
o . g a. 

2 x <x x 

U <t s 
CA X = 

ui m >• u 
as . m 
j x 

J (A 

<t o z > 

H *— Ul OS 
-•0X3 
OU I J 
—• (A X 4C 
a a. 
q o J 

x z = J 

H <t - 

— 3 

3 as to 
QhU 


X H 

Z O 

-• O UI 

o 

2 £ $ 

O O CA 

3 X X 


: H H c- 
I 3 

' X H X UI 
> Z UI Z 
—• ui 

I J O J 
» X —• H 
.OX X 

£ WO 
x x 


» H X 
) Ul X X CA 
) O O - — 


2 m 

WHO Ul 

X —• CA H H 

On (A O — O 

5S 5 ^ H X 

•-« O X X Z H <X 

X X H <X U — X 

% u -• X X o 

OH O W U 

(A - OQ X X H 
H Z H O O X 
X (A OWUZHW 
-• — O (A O —* CA Z 


I H X - X 
WHO X 
I J 3 <C Ul O 
• X X H X 
> X H CA O O 
; O 3 H H 

i o o q cn 

J ui z 

H U O X X 
J Z CA 3 
[—•OHQH 
1 X J W Z U 

) X O O 2 X 


X - 

© Z 


X 


© W X 

2 X © Cf 

S 

9 q » 


H 

© 

O X X Z X X 

H H O C 

9 W 

* X □ X 

X 

© 

w 

X Z 202 X 

x 3 x a 

—• © 

I © o© 

z 

o 

X 

<r0-4PQ90© 

U O O 2 c- 


X CM X (A 
HCAHQ 
3 W 3 J 
<C O X O O 


ai: 

X Z 2 X 1 


-1 

c 

3 

—1 

X 

© 

-1 

J © -. 

q - 

5 © x i 

o 

O 

— q - 

J — 

X 

H 

w 

2 2 H —• - — J2X2X 

2 J © Z 


5 '2 

X 

2 

x 2 a 

cx 

z 

© 

w 

xhwxnxnx M 2 q Z H X 

X 2 W -• 

38 


© © o 

o 

X 

-IOC 

0 J 


o 

X 

XWOO^O^O •-DOJ-.W'd 

x o x X 


444444444444444444444 


9 COCO 




© 

© CM 

© © © © CM 

© 

© 

9 9 9 




9 

9 9 

9 9 9 9 9 

9 

9 

9 © in 




if 

2 © 2 © © 

m x m m 2 

X 

© 

9 © O 




O 

— — 9X9 

©HO OX 

N 

CD 

— © CM — 




X CM 

U2 U 2 W 

2 O 2 O CM © 

X O 

2 © © 

CM © CM © 




2 © 

XO X 0 X 

O O © « © O 

2 O 

CM X O 

9 © d r- 

2 

9 

W 

© N 2 

QXCMdA- 

© O X CM © © 

© 2 o m 

© © 2 

9 9 9 9 

9 

X 

W 

XXX 

XX 9 9 9 

999--- 

— — - CM 

© © © 

— — 4 — — 



CM 

(M (M CM 

CM CM W © © 

© © © © © © 

© w w © © w w 

9 9 9 9 

9 

9 

9 

9 9 9 

99 9 9 9 

999999 

9999999 


P age 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

35 










********************* 


^gr 

• u. r 


X 

& 

I 

S 

a. 


i -s^ss 

rS9£S 

I. -I r 0) •-• 3 

: ai 33 * 

» a: u ui q ui 

I b. I BJI 

0 S O H 
H (0 
Z O 

| N CO Z Z b. 

ItnDO! o o 
: -« o > 

> Ub.«U)Z 
•>•01 i ui o 
-J co co ~ 

□ >(-HO(0 
1 ’-j J CO « flu CO 

vO > P £ 

! CM £ CQ . 0. 2 

;co co u 

iOZJQ. 
> X o «t 



> 

1 5 

UI 

bl 

rJ 

-! Ol. 

= 1 
Z £ 

o 

s 

(0 

bl 

u. 

r- 

H 

P bl 
0. -I 

-J W 

O 3 

^ b! 

£ & 
CL CL 

£ 

> 

1- 

2 *H 
*H U. 

£ b. 

►H £ 

g g 


O O 

-i Si a. 

M fal 


£ Q 

<t p 

tn cn 

H 

§ 


£ 3 


o 

g 



*■ 

CM 

ta 


wq3h 

3l&3 


u 

-J 

H 

u. 

H 

8 






UI UI 

J -J 




H 

HI - 


Z 

b. ¥» 




bl bl 

O 

J . 

O -J 

CL 

Hi U. 

<X Hi 


O -J 

cn z b. 


z . 

(0 □ 

D 

2 z 

bl H H 


0. u 

r .as p 

H Z 


bl rn 0- 

0) O Z 

U z 

ZJO P 

•h Q 

H. O 

O *H o. p 

Qhi- 

z * 

•H U. H O 

J<tz 

p - 

H X *h £ 

O O Hi 

o . 

UI H U CL O 

o o 

bl 


ID 411. . 

if* W O O 

OP t- H 

u o q co 

JU1Z 
HU O X X 
Z CO p 

•h O H Q H 
Z J UI Z UI 

2 u o 2 z 


hcli - a, 

w CL U <t 1. u 

*. 8 ll B *SS 

H 8 0800.40 a. 


-1 .J 

l- M *-• J n w , j a, 

B&s&S3S;55 


CM U. CO 

co h q 


g J0 - 

“gg 

UI <t <t 
O H H 
<X CO CO 

0 3 3 
HUM 
CO Z Z 


£ 

CM * 


6 

S 


- u. - u. - a. 


ui 

§ 

- Q 


H 

0- 

H 


9 

* O 


o u 
z • > 

H .& 

3r° 

> <X I 
zx i 
o z l 

U O V 
- u. - 

uT £ uT 

J \ _I 

g&s 


(fl H C 





to £ - 

J X H 

H 1 - 



bl h 3 

: a- ui 

P bl 

(0 (0 

non 

£ b. - 

J co z 

Z X 

Q Q 

Q Q Q 




CO 

(0 

01 


n 

(V 




■a 


c» 

SJ 

<a 

UI 

Q O 

tO 

<x 

u 

to 

■a 


5 fi 

u. 

Si 

II 

b. 

UI 


Up 

CM 

UJ 

o 

n 

b. 

u 

b. U 

U 

(0 

U 

u 


•a 

vD 


® ui •DO'cauecotgoin 

u. ui h.bbu.soScis 

^ CM CMCMCMCMCOCOCOOCO 

«» si saassaaci a 


4; O' O' 

O' 


CM b. (J 

0 


Ulifl N 40 

U b. 

SI CM 

si -H m n n 

n m 

4 4) 

CO CO CO (0 co 

(0 CO 

CO CO 

SI SI SI SI SI 

SI SI 

9 SI 


CO 
UI 

'§39 

CO u. o 

* CM CO 

« s <x 

909 

§?§ 

CM H 51 
<E U UI 
CO CO CO 

999 


CO 

z 

UI 

CM U, 

CO u. 

.a-a.. 


01 

(S 

tr 

s 


* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 


I- to UI > 

u z oc n n a' <; 
viuotioozom 
o—iir^totoujCK: 

JOC<IDIOLUK 

utuuJXZZOSui 


§ 

I 


■C3 

d> 

,g 

c 

a 


o 


CD 


Q. 

O 

a. 


co 

a. 

o 

Q- 


ONIAlOOtMltU j- 
rtNOHNOlOOCl 
OHtfONNOI^M 
ooooooooo 


x < z u. 

z z o P 

< U. Z CQ 

-JO z z 

co UJ UJ — 



H IO - U. «J W 
OO JOB O 

wwo<; a 
W V) -J ui c u 

I I O Z W N 


UlOU-OlD»Q JL < 
N<U.«ONtAHIT O 
WKM^ONNKHOO O* 
OOOOOOOOO o 


< 3 < 

% V) % 

co o a. j j 

> 0- CL O > H 

O O O O O UJ 

Z a. a. < z o' 


3 uj P O Z 
WWOD3 


CO to 
uj o 
o a 
% co 


CO-I-I 

P > X < > X < 


I Z Z Z CM P 

U- O O O-HO 
U. Z Z Z % % 

OZCMZfHZXOO 

UJ UJ UJ 

Q.NO.NO-NOXL 

0P0-30-3ZX-JC 


UJ UJ UJ UJ UJ UJ UJ 
HCNOmOtf OlAOlfiONO 
0<0<0<0<0<0<0< 
(OMI/)V)l/)V)V)V)l/)l/)V)V)V)V) 
OOCOCOtOU)COCOCOtO«^iOCOCOUd 


o 


OOP 


a 


a 


X<X<X<X<X<X<K< 
—JO—JO—JO-JO-JO-JO-JO 


UJ H 

Wl- UJ 

O CO to t/) I/O 
-J UJ O UJ o 
O O O Z Q 
% %03 % co 


O O O 


> X 



« > 
u z 


< UJ 

O Z 


P H > 
co uj < 

J— to CO Wl to 

Z O UJ o x 

a. o z o H 

»® x CO (/} 

o o 

-I -JO—I 

- 1 -l-JIH 

XXZA.UJ 

Z O Z O -I CO z 


UJ 

z 

UJ 

H 

z 

3 



UJ 

CO 

O 


o 


UJ 

o 

< 

to 

</) 

UJ 



z<<»neopz — 

*-OZZO<CDOU- 

MZhXflhl-hh 

JUJBUJOIOOBUJB 

oooujozzzzto3 


o»oanocDuJioo<io 

NNIi.OOlflOOOHH 


oooooooooo 


JNNUJ X U. Z Z 


</> 1UO O UJC3 </> flop V- 
o j ax>t/)3Hto- 

QUZZOMUJPUIZ 

CDOUUJZXZOZ3 


NHHMU.9I 

QUootOO 


m 

UJ 

tn r-t o ho »o jo ^ 

o o o o o o o o 

in<^intnjoiou.(7iNU.Hi/t 

OHJOHNOU.H.OU.OO 

LAUJHQUJHQU< 1 JJ<UJ< 

U-0»HOOrHOU.OU-OU.O 



o o 

HO J 
Q » J 
HUH 
UJOH 


£X 1 

o 


N N/»N JN 

O o o o o o o 

to in o in CO in CM 
O CM CM CM K\ CM m 
rH O rH O rH O rH 
rH O rH O rH O rH 


CN J CM ^ (N ^ 

o o o o o o o 

IA U IA 00 I/1IA IA 
CJIANNNCTIN 
O rH o rH o fH O 
O rH O rH O rH O 



OlAkAQ IA 
rH CM O O O 

uj h o uj oai 
O rH o O o O 


O O CM 

O O O 

OlAQlA* 

O O o o o 
UJ O UJ O < 01 (71 
O O O O CM u_ o 


< CO O O UJ U. 
fOjOJOjOJO JO 

o o o o o o 


O<lO0lUUJHjMO0ICOUJOlAN0l 

OOOOOOOQOQOOUIUIUJUJ 

IOJAJOJOJOJAJOJOIOKHOJOKMOJAJO 

oooooooooooooooo 


O OOJAIO0IOU.NIAOO1OUJHJ 
UJ UJU.U-U-ZU.U.OOOOOrHrH 
K> JOJOJOjOlOJOJOJitftfrf^J 
O OOOOOOOOOOOOOO 


NWOUH J 
rH rH rH rH CM CM 


O O O O O O 


IAN< OU.NJA 
CM CM CM «M CM IO PA K> 


ooooooo o 


JA 4 IA(ON«O 0 >OHNJA^lAU)NOOO)OHNJA^IAlOSOOOtOHNIA 4 lA(ONOOOLOHCMIAJlAlflN» 01 O H N JA J lA Ifi J^ OO 01 O H M 
OOS>eS«eO»OOOIO 101 O)O) 0 l 0 l 0 l 0 )OtOOOOOOOOOOHHHHHHHHHHNNNNNNNNNNJAAIAKMAIAIAIAIAK 14«4 
rH rH rH rH rH rH rH rH «H rt rH H rt rt rH rHrHCMCMCMCMCMCMCMCMCMCMCMCMCMCM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM >4 CMCMCMCM(MCM(MCMCMCMCM 


> 

lO 


IAKMAHU.NJA JCMO 
OHU.HNIAO J7CQ t) 
OOJA J7 JANNHJAIA 
OOOOOOOOOO 


— UJ UJ 

U. rH to O Z 

UJZZ<IA- 
X CO OOU7UJ 
7- O Z Z V) 00 3 
(/) J Z Z UJ bO UJ 
< O uj uj z X Z 


U. I- 
Z UJ 
LU c/} Cd 
CL UJ < 
O Z 7- 


HNQCOIAO5 0IHQH 
JsHUJONIAIAUJOCM 
JO JJA J JtNJANOH 
OOOOOOOOOO 


Number 41 

36 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 












PASTIMES 
AND 

PLEASURES 

BY CHARLES WETHERELL 


The Programmer’s Book of Rules 

This month I would like to laud a singularly courageous 
act by a friend of mine. George Ledin, Jr. and his brother 
Victor have just published A Programmer ’s Book of Rules 
(Lifelong Learning Publications, 1979. $7.95). Before I tell 
you why I think George is so brave, let me describe the book. 
Then we shall anoint the hero. 

Handbook and Sourcebook 

The most striking thing about Rules is its layout. On the 
left of each double page are large boxes with a programming 
rule in big black type; for example: 

Nest Loops Sparingly. 

Often there will be short subsidiary rules and references 
to the source of the rule. On the right hand page there is an 
explanation box for each rule box. The explanation is usually 
English text, but it may contain a short program example, 
an input sample, or an output fragment. The explanations 
provide the reasons for the rules. 

The book is broken into three major sections—one each 
for requirements analysis, coding style, anil programming. 
The sections fall into chapters; with each chapter comes a 
bibliography giving exact sources for each rule in the chapter. 
At the end of the book there is a collected bibliography 
divided into useful topics. There is also a complete index of 
authors and an index of subject headings. Rules is valuable 
for its bibliographies alone. 

When you first hold a copy of Rules, you will probably 
want to read it straight through—two hours will do nicely. 
Then you may well want to argue the rules with your friends. 
Finally you will probably want to write your own Book of 

© 1979, Charles Wetherell 

Page 42 


Rules. In fact, I predict that many readers will rip the spine 
off Rules, hole-punch the pages, put the resulting handbook 
in a loose-leaf binder, and start adding rules of their own. 
George and Victor surely would approve. Rules not only sug¬ 
gests keeping historical notebooks, but the authors promise 
to revise Rules from time to time and ask their reader’s help. 
So keep those cards and letters coming, folks. 

Where Angels Fear To Tread 

What makes the Ledins so heroic? On the day I received 
my copy of Rules, an acquaintance dropped into my office. 
He picked up the book, riffled the pages, glanced at a few 
rules, tossed it down, and said, “That can’t be right; at least 
75% of the rales are all wet.” I fear that Rules is going to re¬ 
ceive the same reaction from many old-timers (perhaps 
even from some of the quoted rule-makers). But such quick 
criticism is beside the point; let me explain why. 

First, every programmer needs discipline—discipline in the 
monkish sense of a rule of fife. (By the way, George Ledin is a 
professor at University of San Francisco, an eminent Catholic 
school. Make of that what you will.) Almost any rule is better 
than no rale at all. In fact, my master rule (or meta-rule, 
if you will) is 

If you did something before and you have to 
do it again, Do It The Same Way. 

In other words, make rules and stick to them. 

Second, George and Victor didn’t make the rules up them¬ 
selves. They distilled the experience of many other expert pro¬ 
grammers. If you don’t believe the explanation for a rule, they 
point you right to the original source, chapter and verse. You 
can go read the rulemaker’s arguments and decide for yourself. 
One of the most important rules is “Learn From Experience, 
Yours And Others’ ”. Rules helps you do that. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia. Box E, Menlo Park. CA 94025 


Number 41 

37 



Third, no rule is an absolute — neither “ Brush after every 
meal” nor “Thou shalt not steal.” Programming rules are very 
susceptible to exception. Criticism like the example at the 
beginning of this section is very likely based on experience of 
exceptions, but that doesn’t mean the rules are all wrong. 
Judgment in application is needed. For example, I agree 
wholeheartedly with the book’s rule “Avoid FORTRAN arith¬ 
metic IF,” but. .. when I write a binary search, it is the 
perfect control structure. When you acquire the judgment 
and experience, you too can break the rules. 

So I fear the Ledin’s will receive much criticism and cen¬ 
sure. But they have done a service and they must be praised. I 
have had a file of similar rules for five years and I have been 
afraid to print. Not they. 



Hair Splitting And Head Shrinking 

So that George’s head doesn’t swell too big from all this 
praise, I am now going to engage in a bit of criticism. Of 
course, the Preface says comments are welcomed. So George 
will now be noble for several paragraphs and take his licks 
without flinching. 

Rules contains a lot of material on control structures. Yet I 
missed an overriding rule — one that says clean control has 
clean mathematical structure. Similarly, in the section on de¬ 
bugging and testing there is no mention that the goal is to 
write programs that are so clear and obvious that it is evident 
on their face they contain no errors. In a very important sense, 
debugging and testing are a waste of time; if your program 
were correct from the start, you wouldn’t need to kill bugs. 
While I think the mathematical theory of programming is no¬ 
where near developed enough to cope with large practical 
programs, programmers must always keep the ideal of the 
perfect program in mind. Rules does not emphasize this ideal 
enough. 

There are a few rules I believe must have slipped by when 
George wasn’t looking. “Minimize compilation time” is one 
such. Whatever for? Even very small computers have quite fast 
compilers nowadays, and anyway, who cares how long the 
compiler takes? Run-time, Si! Compile-time, No! 

On the same quibble level. Rules suggests first that 
comments should explain the why and wherefore of each 
logical section of coding and that the code itself should 
express the actions necessary to achieve the object. Then Rules 
says one line of comment to 10 or 20 lines of code. I should 
have thought one to one was a much better ratio. Surely 5% 
comments are far too few. By the way, I do agree that a para¬ 
graph of comments should precede a paragraph of code; the 
two should generally not be mixed. 


Throughout Rules, the Ledin’s urge that clarity not be 
sacrificed to efficiency. They also recognize that sometimes 
improved efficiency is necessary. But nowhere can I find a 
mention of the way efficiency is best gained — wholesale 
replacement of algorithms and data structures by better ones. 
I am reminded of a friend who spent much effort delicately 
hand-coding an assembly language sort routine to extract 
every last microsecond of speed. No doubt he developed the 
fastest possible sort - using his algorithm. But along came a 
graduate student who coded a well-known better algorithm in 
ordinary FORTRAN. A factor of 3 speed-up and the new 
algorithm only used 40% of the data space. Finally, the new 
algorithm was simpler and cleaner. It often works that way. 
Speed and elegance go hand in hand because both depend on 
deep insight into the problem to be solved. So do follow 
Rules’ precept to read the literature when you want more 
efficiency. 

Hobbyists and Rules 

In spite of the criticisms, I still think that Dr. Dobb’s 
readers will find Rules profitable. My guess is that most of you 
are hobbyists and, even if involved with computers profession¬ 
ally, are not trained programmers. So you are probably having 
to leam all the painful lessons of programming for yourselves. 
Rules condenses much experience into palatable droplets of 
wisdom; it would be foolish to turn down such a healthy 
draught. Perhaps not all the ingredients will help you grow 
into better programmers, but like Mama’s chicken soup, can it 
hurt? 



Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Munlo Park, CA 94025 


Number 41 

38 


Pa09 43 
























CARRY FLAG STILL W AVES 


Dear Suzanne: 


We wouldn’t want you not to have an 8080 pusher-popper 
routine to kick around anymore, so I would like to make this 
comment on the code submitted by John Bockelmann in DDJ 
#38. May I be the umpteenth programmer to point out it 
will always return with the carry flag cleared!! The DAD 
instruction used to get the old SP modifies the carry flag, 
and when DADing to 00, it will clear it. I don’t have an op¬ 
timum solution, but here is an idea of how we handle the 
problem in our Fast! tm software: 


SHLD HLREG 
PUSH PSW 

LXI H,2 
DAD SP 
SHLD OLDSP 
POP PSW 
LXI SP, NEWSP 


;save HL in RAM 
?ave CARRY flag 

;this uses 1 level of the old stack 

,the 2 makes up for the PSCH PSW 

•JHL = true stack 

;store old pointer in RAM 

get it back 

?et new stack 


Now the registers can be pushed in any order. 'Vhat to do after 
that depends on whether this is a subroutine, part of inline 
code or whatever. Obviously, the code is not reentrant, re¬ 
quires RAM and is cumbersome. I am offering it as a stimulus 
to your readers to find a better way and to keep the ol’ 
pusher-popper controversy going. 

Sincerely, Brown Dog Engineering 

Orv Balcom Box 427 

Lomita, CA 90717 


CP/M MACRO ASSEM 

2.0 

*001 

SAUE A 

RESTORE MACHINE STATUS 




TITLE 

'SAUE A 

RESTORE MACHINE STATUS' 



THIS 

ROUTINE 

WILL SAUE ALL REGISTERS IN THE 8080 AND INITIALIZE 



THE STACK POINTER TO 

A LOCAL STACK. 

0000 

E3 

>AUE: 

XTHL 


JSAUE HAL 

0001 

D5 


PUSH 

D 

;SAUE DAE 

0002 

C3 


PUSH 

B 

JSAUE BAC 

0003 

F5 


PUSH 

PSW 

JSAUE ACCUMULATOR A FLAGS 

0004 

EB 


XCHG 


JPUT RETURN ADDRESS IN DAE 

0005 

210O00 


LXI 

H, 0 

JGET AND SAUE THE CONTENTS OF THE STACK POINTER 

0008 

39 


DAD 

SP 


0009 

222000 


SHLD 

SPH0LD 


000C 

314200 


LXI 

SP•LCLSTK {INITIALIZE THE LOCAL STACK 

000F 

EB 


XCHG 



0010 

E9 


PCHL 


JPUT RETURN ADDRESS IN HAL AND GO THERE 



THIS 

ROUTINE 

RESTORES THE MACHINE STATE USING THE SAUED 



STACK POINTER ADDRESS "SPH0LD", AND THEN RETURNS TO THE CALLING 



PROGRAM. 



0011 

2A2000 

?ESTR: 

LHLD 

SPH0LD 

JPUT SAUED STACK POINTER ADDRESS IN HAL 

0014 

F9 


SPHL 


{TRANSFER IT TO THE STACK POINTER 

0013 

FI 


POP 

PSW 

{RESTORE ACCUMULATOR A FLAGS 

0016 Cl 


POP 

B 

{RESTORE BAC 

0017 

D1 


POP 

D 

JRESTORE DAE 

0013 

El 


POP 

H 

{RESTORE HAL 

0019 

C9 


RET 


{RETURN TO THE MAIN PROGRAM 


THE FOLLOWING SUBROUTINE DEMONSTRATES THE USAGE OF THE TWO 
SUBROUTINES SHOWN ABODE. THE MAIN PROGRAM CALLS THE ROUTINE CALLED 
"LCLSUB". "LCLSUB" THEN CALLS "SAUE" TO PRESERUE THE MACHINE STATE 
AT THE TIME THAT IT IS CALLED. WHEN ••LCLSUB” HAS COMPLETED 
PROCESSING, IT THEN JUMPS TO "RESTR" TO RESTORE THE MACHINE 
STATE AND RETURN TO THE CALLING PROGRAM. 


AN’/ LOCAL ROUTINE 


001A 

CD0000 

LCLSUB: 

CALL 

SAUE 

JSAUE THE MACHINE STATE 

{PERFORM ANY PROCESSING REQUIRED AT THIS 






{POINT. 

001D 

C31100 


JMP 

RESTR 

{LOCAL PROCESSING COMPLETE - RETURN TO CALLING 
{PROGRAM WITH THE MACHINE STATE RESTORED 




MAIN 

SYSTEM STACK HOLD AREA A LOCAL STACK 

0020 

0000 

SPHOLD: 

DW 

0 

{MAIN PROGRAM STACK ADDRESS HOLD AREA 

0022 



DS 

32 

{RESERUE 32 BYTES OF STACK 

0042 

a 

LCLSTK 

EQU 

* 

{AND TAG THE TOP OF THE STACK 

0042 



END 




JULIAN DATE 


QUARREL WITH DAD 

Dear DDJ: 

1 take exception to the routines submitted by M. John 
Bockelmann (DDJ #38) in the the “DAD SP” instruction 
found in the save routine will modify the setting of the carry 
flag before it is saved. Enclosed is a modified version of the 
routines that will cure the problem. 

I enjoy your publication very much and consider it to be 
the best software journal for microprocessor programmers 
available today. 

Sincerely, 3660 London Road 

Chester P. Quinn Chamblee, Georgia 30341 


Dr. Dobb’s: 

The letter by Jack Dekok in DDJ #39 reminded me that 
The Government, in its usual wisdom, has managed to con¬ 
fuse things. Julian date is a precisely defined astronomical 
term. According to the Explanatory Supplement to the 
American Ephemeris and Almanac, the Julian Day Number 
is the number of days since Noon, January 1, 4713 B.C. 
(Julian proleptic calendar). The Julian Date at any instant 
is the Julian day number, followed by the decimal fraction 
of the day elapsed since the preceding noon. Julian dates are 
always referred to as Greenwich Mean Time or Universal 
Time. Noon was chosen as the time a new date starts be¬ 
cause the Greenwich astronomers did not like to have then- 
date change in the middle of their night-time observations. 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 

39 










As Mr. Dekok says, Julian dates are much more convenient 
to use than conventional Gregorian calendar dates for the com¬ 
putation of intervals in days. This letter is being written at 
about 8 pm EDT, 25 September 1979 or JD2444142.5. It is 
easy to find that 1 January 1984 (JD2445700.5) will be 
upon us in only 1558 days. Unlike the governmental version 
(which is better called the Annual Day Number, or simply 
the Day number) the true Julian date does not require remem¬ 
bering which years are leap years. There are several good 
formulae for conversion of JD to calendar date and vice versa. 
A useful reference is Matrix Magazine Issue #3 (published by 
Michael and Margaret Erlewine, 1041 North Main Street, 
Ann Arbor MI 48104). Astronomers will find JD especially 
useful in generating positions of the Sun, Moon, and the 
planets with series expansions from the Explanatory Supple¬ 
ment. Matrix has also published useful formulae for such 
purposes. 

I have no idea why the government created its own “Julian 
date.” I suspect it was a case of someone who vaguely re¬ 
membered AST 1 Lab ... but not too well. If anyone knows 
more about the origins of the error, I would appreciate hearing 
from them . 

Sincerely, Astronomical Time Mechanisms 

John P. Oliver P.O. Box 12248, University Station 

Gainesville, FL 32604 



ADDITIONAL NORTHSTAR DOS PATCHES 


Dear DDJ, 


I would like to make some additions to Mr. A.M. Banks’ 
Northstar DOS patches (DDJ #39, page 43). The changes to 
be made are as follows: 


WAS: 2601 FE01 

2603 C2 11 26 
2611 CD 0C 27 
29F3 C3 14 26 
29F6 06 07 
29F8 CD 04 27 


CHANGE TO: 25DB FE02 

25 DD CA EE 29 
25EB CDF6 29 
29F3 C3EE25 
29F3 C3EE25 
29F6 0E 07 


Also to incorporate the ‘GOTO’ data change : 


217AFE01 217A FEXX 

217CC2 89 21 217C D2 89 21 


The ‘XX’ can be any number since I use different type 
numbers for electric pencil files, proc. tech, music files, and 
other BASIC files such as tiny BASIC. The reason for ‘FE 02 
CA EE 29’ is that type 2 files use byte number 13 for the 
number of active blocks in a BASIC program. A BASIC state¬ 
ment such as l A = CALL(8229.1)’ will display the directory 
from a BASIC program. 

Thanks again for the magazine and keep up the good work. 

Sincerely, PO Box 384 

Jim Gammell Berwick PA 18603 



STRING ARRAYS IN NORTHSTAR BASIC 

Dear DDJ: 

This letter is in reply to a remark made in passing in ore of 
the book reviews in the September 1979 issue of Dr. Dobb’s 
Journal. At the end of the first paragraph in the second review 
on page 43, the remark was “Did you ever try to figure out 
how to handle string arrays in Northstar BASIC?” Well, I have, 
so I thought I would share these routines. 

These examples are just to illustrate my approach; the 
details will probably have to be changed in an individual 
program, but they can be used as starting points. The idea is 
to store all of the string entries consecutively in a single tong 
string variable and use an associated numeric array for pointers 
to the end of each string element. 

The arrays ran be set up by routine #1. If the program 
requires a string array with fixed data, the same loop can use 
READ/DATA statements instead of the INPUT statement. 
If the total number of entries is not known in advance, use a 
loop controlled by IF/THEN statements to check for an 
ending signal (sin input of END, QUIT or something similar). 

The required string element can be accessed by using the 
expression A$(N-1)+1 ,A(N)), with N being the number 
of the entry. This works because A(N - 1) is the pointer to the 
last character of the entry ahead of the required entry, so 
A(N- 1) + 1 points to the first character and A(N) points to 
the last character of the required entry. Note that for the first 
entry, N=1 so A(N - 1) = A(0), this must be zero. Of course, 
it is automatically set to zero when the array is dimensioned, 
but it is a good idea to keep this requirement in mind anyway. 

If this expression is required repeatedly (it probably 
will be) it is simpler to use a defined function such as DEF 
FNA$(N) = A$(A(N-1)+1 ,A(N)). This can be called 
by expressions such as PRINT FNA$(N) or T$ = FNA$(N). 

It is rather more difficult to dynamically alter the array 
string, but the defined function, shown as routine #2, will do 
it. This can be called by expressions such as X = FNA(T$,N), 
where T$ is the new string to be inserted and N is the number 
of the entry to be replaced. If the number of entries (N9 in 
this example) is unknown or otherwise not readily available, 
the pointer array can be set up with an extra entry at the 
end which is set to zero or negative. Then the FOR/NEXT 
loop and line 140 can be replaced with IF /THEN statements 
to check for this end marker in the pointer array. 

I want to emphasize that these examples are intended 
strictly as starling points. Depending on the requirements 
in your program, they may have to be extended greatly. 
They do work in Northstar BASIC, but I don’t know how 
much they need to be changed for other BASICs which may 
also require a similar approach to simulate string arrays. Also, 
I haven’t shown the obvious additional requirements, such as 
properly dimensioning everything first. 

Compared to a BASIC which directly handles string arrays, 
these routines are somewhat inconvenient and inefficient, but 
they do work. So now you can go ahead and copy those 
programs that you haven’t copied before because they used 
string arrays! Good luck, and have fun! 


Number 41 

40 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, M 3nlo Park, CA 94025 


Page 45 


A little further explanation may be helpful to those who 
are not familiar with the way the string functions are used in 
Northstar BASIC. First, dimensioning a string does not set up 
an array of strings, but sets up a single string. The specified 
dimension is the maximum length of this string. Substrings 
are invoked by either 1 or 2 subscripts, as in A$(2,5) or 
A$(4). The first example results in the second through the 
fifth characters of A$, and the second example results in the 
fourth through the last characters of A$. 11118 same format 
cm be used in assignment statements also. For example, 
assume A$ is ABCDEFG, the statement A$(3,5) = “123” 
results in A$ now being AB123FG. 

Sincerely, 2232 Alameda Avenue 

Larry Hudson Ventura, CA 93003 

Hudson adds the following information in a note: “Until I 
got my Altair I had no experience or training with computers. 
Even after I got it, everything I have learned has been from 
books and my own playing around with it. BASIC is the only 
high-level language I am familiar with, but I do most of my 
programming in 8080 assembly language. I men wrote my own 
assembler, also the editor I am using to write this letter. ” 

ROUTINE 111 

1(0 A(=""\REM - set the array string to a null string 

110 FOR 1=1 TO N 

120 INPUT Tl 

130 A*-fl*+T*\A(I)=LEN(A*) 

140 NEXT I 

ROUTINE 112 

100 DEF FNA(T*,N) 

110 U=LEN(T$)+A(N-1)-A(N)\REM - ^difference btun old X new 

120 IF N=1 THEN 130 ELSE 140XREH - special handling for 1st 
130 A$=Tt+A((A(N)+1)\60T0 170 

140 IF N=NV THEN 150 ELSE H0\REH - spcl handling for last 
150 A»=A»(1,A(N-1))+T»\G0T0 170 

140 A*=A * < 1 ,A(N-1 ))+T*+AKA(N)+1 INRErt - insert new string 

170 FOR I=N TO N9XREN - N?=nunber of entries 
180 A<I)=A(I)+D\REM - update pointer array 

190 NEXT INRETURN 0 
200 FNEND 



A CORRECTION TO KRAY’S TABLE 

Dear Suzanne: 

Your letter dated September 10 re the error in the Machine 
Language Program Displacement Table (DDJ #38) reached 
me a few days ago via my home address in Australia and I 
have just received a copy of the September issue of DDJ. In 
fact a second error has crept into the same paragraph. But 
they were not the fault of the Table. The Table gives correct 
results every time if the directions are followed properly. 

The two errors in the paragraph beginning “Besides calcu¬ 
lating program displacements...” baffle me. The article was 
checked God knows how many times after successive drafts 
were typed. But I must have slipped up in the final draft which 
I mailed to you. I haven’t a copy of the typescript with me 



in Canada but I seem to recall inserting the word “(hex)” 
in the final version to make it clearer, which suggests the error 
got into the penultimate version which followed a thorough 
check of the hexadecimal arithmetic using a TI hex calculator 
by a colleague who owns one. Anyway, that offending para¬ 
graph, for which I must shoulder the blame, should contain 
37B9 in place of 27B9 and in the last line 9 rather than 19 
(hex) bytes. Here is a corrected version of the offending para¬ 
graph: 

Besides calculating program displacements the table is 
useful for determining the length of program segments, sub¬ 
routines, etc. For example, can a program extending from 
37B9 to 3C63 be relocated in a gap between 0FA2 and 1455? 
Using the table we find that the program is 4AA bytes in 
length and the gap is found to be of 4B3 bytes, so it will fit 
with 4B3-4AA equals 9 (hex) bytes to spare. 

Yours sincerely, Visiting Scientist, 

Colin Keay, Planetary Sciences Section 


Dr. Dabb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 41 


41 


Page 46 












SAVE AN UNALTERED 8080 

Editor: 

Here is a routine that saves the state of an 8080, yet leaves 
it unaltered. As I mentioned in my last letter, such a routine 
might be useful in a debugger or break-point monitor where 
the current machine state must be obtained in a non-de¬ 
structive manner. 

Cheers, P.O. Box 1057 

Jon Bokelman Menlo Park, CA 94025 



0FG 

ROM 

Jany ROM or RAM address 

SAVE: 

SELL 

SAFHL 

Jsave HL reg 


STA 

SATA 

Jsave contents of accumulator 


LXI 

H,8000H 

Juse HL to reflect status of flag 1 


JM 

TSTZ 

{test S flag bit. Jump If 1 


M0F 

H,L 

JH=0 means S=0 

TST2 : 

JNZ 

TSTP 

Jtest Z flag bit. Jump If 0 


MVI 

L, 40H 

JL*40H means Z*1 

TSTP: 

JP0 

TSTC 

Jtest P flag bit. Jump If 0 


INX 

H 

JL*04H means P*1 


INX 

H 



INX 

H 

J(INX alters no flags) 


INX 

H 


TSTC : 

JNC 

TSTH 

Jtest C flag bit. Jump If 0 


INX 

H 

JL=01H means C*1 

;at this point H and L 

contain the 'testable' flag bits 

J the N 

and H 

flag bits 

are obtained by deductive logic 

TSTH : 

MFI 

A,240 

Jvalue to test N and H flag bits 


DA A 


Jexecute DAA and see what happens 


ANI 

82H 

Jmask the significant result bits 


RAL 


Jjuggle to correct position 


PAL 




RAL 



{accumulator 

now contains N and H flag bits 


ORA 

L 

Jadd C, Z and P flag bits 


ORA 

H 

Jadd S flag bit 


STA 

SAFF 

Jsave reconstructed flag register 

Jail flags saved, now save other registers 


LXI 

H, 0 

Jget all zeros- 


DAD 

SP 

J to get SP register 


LXI 

SP,SAFI 

1 J(assume Interrupts disabled) 


POP 

PSV 

{restore PSW 


PUSH 

PSW 

Jand resave to fix bits 5, 3 and 1 


PUSH 

B 

Jsave BC register pair 


PUSH 

D 

Jsave DE register pair 


PUSH 

H 

Jsave SP register (from DAD above) 


SPHL 


Jrestore original SP contents 


LHLD 

SAFHL 

Jrestore original HL contents 

Jail regs saved, machine state unaltered 

»continue In- 

-line code 

or return 


0RG 

RAM 

Jany RAM address 

SAfSP: 

DS 

2 

Jsaved SP 

SATDE: 

DS 

2 

Jsaved DE 

SAFBC: 

DS 

2 

Jsaved BC 

SAFF: 

DS 

1 

Jsaved Flags 

SAFA: 

DS 

1 

Jsaved Accumulator 

SAFHL 

DS 

2 

Jsaved HL 


BASIC AIN’T THAT SLOW 

Dear Suzanne: 

In the October issue of Dr. Dobb’s ( #39) on page 30 there 
is an article by David Morganstein regarding using OSI BASIC 
with a modem. The statement was that BASIC is too slow to 
keep up with even 300 baud. This is not true. Declaring any 
numbers used in the first few lines of the program will help 
to speed things up somewhat. However rather than using 
PEEK to check the status use WAIT. Example: 

10 P = 64512:M = 127:R = 13 


Putting this rou tine in the beginning of the program should 
also help. There are several routines in OSI BASIC that by 
doing one or two POKES allows you to write a string to 
memory rather thiin the CRT. By combining these features, 
BASIC can receive, store and print without missing any char¬ 
acters at greater than 300 baud. This is not to say that this 
would be preferable to assembler, only that it is possible. 

Yours truly, 

L. Barker Chicago, Illinois 

INSTALLING A “PHANTOM-DESELECT” 

Dear Editor, 

I recently found it necessary to install a “phantom-de- 
select” on one of the excellent GODBOUT ECONORAM II 
boards. The following circuit has worked well, with no pro¬ 
blems. 

1. Cut trace from pin 6 of IC5. 

2. Cement a 74L800 (on its back) to the board next to 
IC11. (It fits nicely on the ECONORAM II logo). 

3. Connect as follows: 



Board now works with Tarbell floppy-disk controller. 


Sincerely Newberry Microsystems 

Steve Newberry 24225 Summerhill 

Los Altos, CA 94022 


800 REMEMBER TO INITIALIZE VARIABLES 
810 Q$ = ” ” 

900 WAITP,1 

910 X = PEEK (P + 1) ANDM 

920 IFX = RTHEN?: RETURN 

930 IFF = 1 THEN?CHR$(X); 

940 Q$ = Q$ + CHR$ (X) 

950 GOTO900 


Number 41 

42 


Dr. Dobb's Journal of Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 





© David Dameron 1979 


43 







Dr. Dobb s louRNALof 

COMPUTER 

^Calisthenics Orthodontia 

Running Light Without Overbyte 


Number 42 


February 1980 


Volume 5, Issue 2 


A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 


TI 9900: Fully Reentrant Formatter Operating Under TIPMX 5 

Norman V. Walters 

A Table Driven Assembler On CP/ M 18 

Darrel J. Van Buer 

Feature Enhancements for the ADM-3A 15 

John Wakerly 

A User Interface to Apple-II Renumbering 26 

Dewitt S. Brown 

Converting Binary to Decimal 32 

Dennis Allison 

USCD PASCAL Terminal Parameters 34 

Ronald G. Parsons 

A Microprocessor-Assisted Graphics System 38 

Griffith Hamlin and Thomas Crockett 


... and, as always, even more 






«/////«////// 


E>QQ1 


TI 9900 


/ill] 


XTV 


nr/iww 


H 


FULLY REENTRANT FORMATTER 
OPERATING UNDER 
TIPMX 


BY NORMAN V. WALTERS 

Software Engineer 
R&D Department 
Fairfield Industries, Inc. 
Houston, TX 77042 



Our company felt the need for a program that would allow 
assembly language programs operating in a real-time environ¬ 
ment to display information to and request inputs from the 
user. The end result has been a powerful tool that is used in a 
large portion of our ongoing efforts. The code has been 
debugged over a period of six months in actual usage by a 
number of different users and should present no major 
“gotchas” to the unwary user. 

There are five externally referenced routines that FRMTR 
calls during its execution. They are the following: B$RAM, 
CIO$$, ENTSM, PANIC, and RIOS. Since these called routines 
would vary from system to system, they are not given, but are 
instead described for the user to write for his or her own 

application. 

BSRAM is the separator for stack and relative addressing. 
CIO$$ is the character I/O routine. The character to be input 
will be in the most significant byte of R7. The routine will 
input a character to the most significant byte of R7. The 
inputs and outputs are always ASCII. R7 should be the only 
register to change and then only on input. ENTSM is the work¬ 
space and stack allocator. PANIC generates an error message 


for the selected output device. The message does not depend 
on the formatter for generation of the message since it is 
showing an internal error of the formatter. If the user does not 
wish to generate this routine, the formatter code may be 
changed to 

B @ERR9 

and the user can designate ERR9 as an internal error. RIOS is 
the cursor I/O routine. 

The system used for editing and assembly of this program 
was a TI 990/4 'vith dual floppies and 810 line printer. The 
program was debugged on TI 9900/ 101’s with one or two 
Micropolis mini-floppies, 833ASR with dual cassettes, 

ADM-1A terminal and SCI line printer. 

The code could probably be maximized in some areas, but 
we wished to get an operating program in use without 
incessant polishing. The following documentation is the full 
documentation I wrote to accompany the program. I hope 
that the combination of the documentation and the copious 
comments in the listing will enable you to understand FRMTR 
fully. 


Number 42 

46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 5 




TIPMX FULLY REENTRANT FORMATTING ROUTINE 


Tfiis routine processes and performs nine (9) different functions at 
the present time. Eight (8) opcodes are used, 0 through 7. The 4 
most significant bits (BO-3) are used to designate the opcodes thus 
aLlowing room for further opcodes if needed. The 12 least signifi¬ 
cant bits (B4-15) are used for instructions in a particular opcode. 


CURABS - Outputs a command to position the cursor at Row (line) Y 
and Column X relative to cursor home (upper left-hand corner of CRT). 
Cursor home is Row 0, Column 0. The subroutine uses the following 
registers for the following values: 


REGISTER 


VALUE 


R6 ROW (LINE) 

R7 COLUMN 


OPCODE FUNCTIO N 

0 1. END FORMATTING ROUTINE IF 12 LSB-0 

2. FILL N COLUMNS WITH SPECIFIED 
CHARACTER. 

1 PRINT (OUTPUT) INTEGER. 

2 POSITION CURSOR ABSOLUTE (RELATIVE TO 
HOME POSITION). 

3 INPUT (READ) INTEGER. 

4 POSITION CURSOR RELATIVE TO LAST 
POSITION OF CURSOR. 

5 INPUT/OUTPUT STRING. 

6 1. REPEAT FOLLOWING FORMAT N TIMES. 

2. END FORMAT REPEAT 

7 LINE FEED CARRIAGE RETURN OR SPECIALFUNCTION 


CURREL - Outputs a command to position the cursor to Row (line) Y 
and Column X relative to the cursors present position. This 
subroutine uses the cursor read command to determine the present 
position of the cursor, therefore it can not be used with CRT's not 
having this command capability. The ADM-3A does not have this 
capability, the ADM-1 does. The subroutine uses the same registers 
and their values as the CURABS subroutine. 


FORMAT OF LUNS FOR CALLING SEQUENCE 

LUNS is used to designate the input and output devices to be used 
with the formatting routine. It will be consist of two bytes. The 
first byte will be the input device, the second byte will be the 
output device. 


For ease of use, the formatting instructions have been effectively 
microcoded, the user does not have to work with bits. 


C ALLING SEQUENCE OF FRMTR 

LI Rll,FRMTR 

BLWP RIO 

DATA OPLST,FMTLST,LUNS 

JMP ERR 


NUMERICAL BASE 


The routine is initialized to base 10. The base is changed by N or D 
fields (do not use both in the same formatting command) in format 
1 or 3. That base will then be used until it is changed again. 


NESTING OF FORMAT LOOPS 


EXIT FROM FORMATTER WHEN ERROR IS DETECTED 


Formatter will return control to the calling program with three data 
items supplied to the calling routine. R0 will return the error 
code which will designate the portion of the formatter that detected 
the error (see following table), Rl will contain the OPLIST address, 
and R2 will contain the FMTLST address. 


R0 VALUE 


ERROR AREA 


1 

2 

3 

4 

5 

6 

7 

8 
9 

10 


INVALID OPCODE 

REPEAT NESTING ERROR 

INPUT CHARACTER SYNTAX ERROR 

REPEAT VALUE MORE THAN MAXIMUM ALLOWED 

OUTPUT CHARACTER SUBROUTINE 

INPUT CHARACTER SUBROUTINE 

CURSOR POSITION OUTPUT ROUTINE 

CURSOR POSITION INPUT ROUTINE 

RESERVED (NOT PRESENTLY USED) 

ESCAPE SYMBOL DETECTED 


Nests up to eight (8) deep (determined by MAX in equate section) are 
permitted. Opcode six (6) is used to start and erd a loop. Each 
loop MUST have a SEPARATE end repeat format, i.e. there must be as 
many end repeat opcodes as there are begin repeat opcodes. 

DE FINITIONS OF CALLED FORMATTER SUBROUTINES 

INCHAR - Reads a single ASCII character into the left-hand (BO-7) 
byte of R7. 


OC HAR - Outputs a single ASCII character from the left-hand (BO-7) 
Byte of R7. 


BI SBAS - Converts binary numbers to digital ASCII strings in base 2,8, 
17, or 16. Determines the sign of the number and stores a plus (+) or 
minus (-) ASCII character at the start of the string. The subroutine 
uses the following registers for the following values: 


REGISTER 


VALUE 


R5 WIDTH OF OUTPUT (NUMBER OF DIGITS) 

INCLUDING SIGN IF ANY 
R6 ADDRESS OF BINARY NUMBER 

R7 BASE (2,8,10,16) 


NEEDED EQUATES FOR FORMATTER MICROCODE 


The user will need to include in the calling routine the following 
equates: 


B 

EQU 

>20 


CRLF 

EQU 

>7000 

OPCODE 7 

D 

EQU 

>40 


ENDFRM 

EQU 

>0 


ENDREP 

EQU 

>6000 


F 

EQU 

>800 


I 

EQU 

>20 


INPUT 

EQU 

>3000 

OPCODE 3 

L 

EQU 

>80 


MOVE 

EQU 

>4000 

OPCODE 4 

N 

EQU 

>80 


P 

EQU 

>800 


PRINT 

EQU 

>1000 

OPCODE 1 

R 

EQU 

>80 


ROW 

EQU 

>780 


REPEAT 

EQU 

>6000 

OPCODE 6 

S 

EQU 

>400 


SET 

EQU 

>2000 

OPCODE 2 

STRING 

EQU 

>5000 

OPCODE 5 

T 

EQU 

>400 


TAB 

EQU 

>0 

OPCODE 0 

Y 

EQU 

>100 


Z 

EQU 

>800 



The maximum width of a number is dictated by the base and the fact 
that only one word (2 bytes) of binary are considered. If the number 
is a signed number,the maximum width is reduced by one to allow for 
the sign. 

At the end of the subroutine, the registers will have the following 
values: 


EXAMPLE OF PROGRAM USING FORMATTER 

Appendix A contains a test program that uses microcode to test 
Opcode 0 (TAB), 1 (PRINT), 2 (SET), 3 (INPUT), 4 (MOVE), 5 (STRING), 
6 (REPEAT), and 7 (CRLF). 

PROVISION FOR GETTING OPLIST, FMTLST, AND LUN ADDRESSES FROM STACK 


REGISTFR 


VALUE 


R5 WIDTH (SHOULD ALWAYS BE POSITIVE) 
R6 ADDRESS OF START OF ASCII STRING 
R7 STATUS 0=GOOD l=ERROR 


If any of these pointers are to be gotten from the stack, the calling 
sequence for the formatter as shown on page 1 would be modified by 
adding +1 to the pointer that will be obtained from stack. 

EXAMPLE: It is desired to obtain OPLST and LUNS from the stack and 

FMTLST from DSEG. 


BASBIN - Converts ASCII digital strings (base 2,8,10, or 16) with 
or without signs (+ or -) into a binary word (2 byt:es) . The 
subroutine uses the following registers for the following values: 

REGISTER VALUE 


LI Rll,FRMTR 

BLWP R10 

DATA OPLST+1,FMTLST,LUNS+1 
JMP ERR 


R5 WIDTH OF STRING INCLUDING SIGN 

(+ or -) IF ANY 

R6 ADDRESS OF START OF ASCII STRING 

R7 CONVERSION BASE (2,8,10,16) 

The subroutine rejects any width that would result in a binary 
number too large to be contained in one word (2 bytes). 

At the end of the subroutine, the registers have the following 
values: 


IF USER INPUTS TOO MANY DIGITS FOR ONE NUMBER 

The formatter examines the length of the input number. If the 
maximum allowed is exceeded, the first character that exceeds 
the maximum is examined. If the character is an allowed terminator 
(i.e., COMMA, CR, SLASH, COLON, or PERIOD), the formatter will take 
a normal exit and process the next format. If the character is not 
a terminator, the formatter will wait until an allowed terminator is 
input. It will not accept any further numbers. 

IF STRING LFNGTH EXCEEDS FORMAT MAXIMUM 


REGISTER 


VALUE 


R5 WIDTH (LESS 1 IF A SIGN WAS IN STRING) 

R6 ADDRESS OF BINARY WORD 

R7 STATUS 0=GOOD l=ERROR 


If the maximum is exceeded, the first character that exceeds the 
maximum is examined. If the character is an allowed terminator 
(i.e., CR, ESCAPE, or NULL), the formatter will take a normal exit 
and process the next format. If the character is not a terminator, 
the formatter will exit and remainder of string will be ignored. 


Pacje 6 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

47 





o 

(U 

Q 

O 

U 

Q-i 

O 





Number 42 

48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 7 







Page 8 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

49 


















Number 42 

50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 9 
















































IDENTIFICATION: OPCODE 4 SET CURSOR TO RELATIVE POSITION 




Paine 10 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

51 






















The microcode for OPCODE 






tn 

•H 

in 



s 






Number 42 

52 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page I11 

































EXAMPLE PROGRAM CALLING FORMATTER 




Page 12 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

53 




























OOO(0UOfflU.in^O-0N 
O o O O- -0 CO O O O O O Q 0^ 
o IT- o o o o o o o o o o o 

o o co ooooooomoo 


u. D CO CO 

Q CL Z _J .. 

Z Z DU — —• IT* CK »■ . 

lu u. — _i o o: cc cc cc cr co co 3 


o 

z o 
- z 

CL CL CL 


O 0-1 OJ O CO O <1 UJ 05 o <t o 

't CJ O CO O O O O O O O CJ o 

o o O O O O O o O O O — — 

o o O O O O O O O O CJ o o 


•D ud 

o o 

UD 

o o 
0? 
o o 

CO CJ 
O -I 

o o 


t» CO 

# O HI 

CD -J Z -I 

Ci ij O t I- CC III 

o co - —< co hi i— a 

~~ -~ ~ ~ <0 »- 


lC — 

_ CL Z u vi —’ -i v ijj 

ouj'-'.jza.QccrirQ; 


o ^ 
o o 


CO N o - 
o o - - 
o o o o 


0 <tf OOO-uCONOOJOO 
O O - -I CO o O O O O O CD o o 
c o o o o o o o o o o o CO 
NOOOO-hOOOOOOOO 


M 

, ~ CC * I- o 

H. * h- Z Z Z 

—i >— si • i-i co ct cq 

cl z cc o cc - co c- y- <r 

oujiL*-iZa.tt:Q:Q:a:cocoi-M 

HI UJ HJ : 


OOOOOOOO 

o o o o o o o o 


UD ^ 

o o 

CO 

n co 


o o o 

O O 

o o o 

If <• O' 

CJ N O' h. 05 

O O 05 

o o *0 <t >0 

O o o 

o o o o o 

o o o 

o o o o o 


CO ~ 

UD 

o o 
o o 


—• O (K CO 
<1 N O' O 
o o o - 
o o o o 


2 £ £! !P >? .1 & lr ’ ( ^ ^ r '- H> N <1 CO O'. 0) N 10 10 

5 <t 0.1 N O 10 C'Mt ^ co UD lO o 0 O' U'l >0 0- O N N 

OOOOOOOOOO O O C- O O —• O O O —i Cj 

OOOOOOOOOO oooo5 oooo o O o 


• • o C l o o o o o o o 0 O o 

00 0 00050000 o o * - 

o <1 o oo o o o O <1 o o o 


f— H J— ■-« 

Cl CO W <Z o 

CC -j CC HI Hi z 

Q t UJ > M 0- q: 

Z E O O O CJ <■ UJ h- 

JHjH*-.Ea.ocQ:Q:oca:coh-> 

5 Q s 


N co O' o ~-i O (N 05 

C l CJ 10 IN IO 

o o O O o o o o 

o o O O O o o o 


^ N IT' <1 OJ If! N 05 CO O' 

OJ -I CN OJ 0 CJ Cl (0 O'! 

O o o o o O o o o 

OOOOOOOOOO 


E f- b- CD #» 

CCH.-I 05 CL Q )- W « y- h- ¥» 

H. LL IT * -IKI-DKZ 05 Hi CQ CO Z -I 

_l QLJh-iT J- E ~ Cl UJ 20 Q_j _ 

CC Z Z Z CC E CX Z Z O o DO O Q_ QD CO 

CDC_iQHJHJuiUJIlLlI , ‘- j ' j, - j -- • — 


HI 

O - CL 
HI 


i_i _i ll ui-» ^ hi whh i— t— i— <r <r 

HM -J JE z Z o CL CL 0- CC CC CC CC ir CO CO CO CC CO co 05 I— |— 


O - C J C*5 0 O - C J «t UD 05 

05 05 05 05 ~ CJ CJ 05 05 CJ 

O O o O »- -I — o O -H 

o o o o o o o o o O O 


C' «- CJ 05 <* 

Z c CD CD O 

-< 7. Z Z Z _ 

KOCCcCCCtCt: CDCQ 

uj >— h- -dc 


. <1 

) HI l 

:• x _i; 


HI I- z 
CC i-i E 

05 D 
HI O _M 
CD CL O 
<1 O Ij 

*-* hj •: 
oc y— - 

CC D 05 y 
<z _i - ; 
o o ► 

05 3 C 
> CD C' C 
CD <1 CC 


: d - 

< HI x 

i z •- 

: CD Q 
«H 05 HJ *-• <t 
J 05 CC 


05 I-I ► 

u > c 

E UJ 
— CC < 


Cl t— o UD D 


HI . 


I- z o 

*-* E <Z 
CO D CL 
O _l CO 
- CL o 
> O O x 

* UD HI ro HJ 

I— - I 
•l-D'fH 

: z j - z i- 

* *-• o 
: cc co : 

. CL CD •: 

CL i 


« > 

Q UJ 
<1 CC C 
CC LL l 


<r - 

E Cl 
: LC Cl 


E UJ HI CD 


* y- 6 

* <1 Cl 


e cc : 
o hj •: 

CC CD 

h E ; 


UJ CC OC -I CD z * 

z o o z y 

O Ll 05 Z U'l > 
-I CC E CC < 

CO I- D D i— o •: 

z <r _i co i- t 

D HJ O 

CL HI (J J- Cl l 


Cl HJ 
■ Z HJ 'D 

i i o cd <r 

1 3 — <1 05 HI 

05 05 CO CD 
CD cc 05 HI -5 
' z UJ HI E 05 

I - D E if. 

: i z i- 

I- C* I- D 

I O D CL 

; CO Cl I- 


D HJ I— + I— Q *-• 


_ __ _ <e <r 

: LL UJ CO O -I 3 HJ HJ 
■ DCL J 

: hi 


XODOUIjJ o C 


Q Q O D D 
<L Z CO 3 O CL 

CC HI CD o Z 

<1 CC -I 


CO 3 I- 
CD o Z' 
<L CC C' 


UJ 


h Oh z 

O H 05 O I- 
O CC O CO 
UI ^1 UJ cc 
UJ ZlL 05 - 
> UJ u. 
<1 


E 05 



cd <r h- 

<Ih HJ 

I— + CO 

+ 005 + 


<i <L <r <i <r <i 

i- i- i- i- y~ y- 

<i <r <i <r <t <i 

ClUDD Cl Cl 


HJ I- 

cc z 

+ U* 

<• cc 


<r <i 

y— \- 
<r <i 

UI Q 


<r ci 
y- y- 
<r <r 


<r <r <r 


<r cl ci 
ci ci a 


- HI 


CJ 

05 05 


05 D> E - C J 05 t f + 
+ CC CD CD CD UJ UJ HJ UJ 

OJLLZZZJJJJ 
** UICCCClCCDCDCDlD 

+ »-.Zh-j-i-<r<r<r<i 
I- UJ 05 05 CO I— I— I— I— 


UJ HJ 
-J -J 
111 CD 
<1 Cl 


HI HJ L 
_J -I - 
CD CD c 
<r <i < 


■ <1 05 o 

• -I - C J 
+ + + 
I HI HI UJ 
I —I —I —I 

i CD CD III 

: <i <i <r 


HI HJ UJ 
-J _J -J 
CD ill CD 
<i ci <r 


05 O 
0J 05 

+ + <* 
HI HI CD 
-I -J z 
CD CD CC ■ 

<r <i *- 

• • - 05 ' 


<ii-<r<i<r<i<r<i<r<r<r <i<i<i<r<r<r<rc<i<i<i<i<i<i 

I - Xh- J— h-h-J— h-h-h-J— h~J— L— J— I— J— I— h-l— I— I - h-l— h- . 

" "QQuDQQDDQQQuQai 


5Lil<I<I<I<r<I<ILy.vi 
uhQDuQDuuQD 


> ^ CJ 05 UD >0 N '55 eh <r CD O Q HJ H lL H 
>00000000oo o oo o o oo o 
JOOOOOOOOOOOOOOOW CO o 

\ A A A A A A A A A A A A A A A A A <5 ^ 

c<r<r<r<r<i<r<i<r<i<i<r<r<i<r<c<x<t q 

- I- I- I- I- I- h- I- I- h- h- I- I- I- f- I- I- h- 05 z 05 O 

c <t ? <r <r <i <r <r <i <t <i <i <r <r <i <c <i <i co iu 05 z 

JDDQQQDQQOOQQQQDQQIDQCDIU 


05 I- 


O' <1 UD *■« HJ «t 

<y 05 05 o ~ ft o 

hUDON O 0 05 

O O o OJ o —I »-« 

O OJ >0 05 <1 o 

OJ CJ CJ CJ CJ CJ CJ 

O O o o O o o 

O O o o o o o 

> 0 O CJ 05 UD O N •: 
JyliNNC'NNNC'Nr 

:• o o o o o o o o o < 

:• o o o o o o o o o < 


- o o o 

05 O OO 

<1^-1 >0 CJ 

O CJ *»- V5 

05 05 05 05 

O o o o 

O O' o o 


<r ud 

CJ <* CO 
O o O'. 


05 <1 O 
05 05 05 

O O o 


■ £ £ £ ? U W O CJ <t >0 05 <L CJ UJ <1 ^ ^ UJ ^ O 05 o OJ 05 UD >0 On 05 O'. <i m O a HJ lL Ll lL 

ui i 4 * J CJ O O —• •jOC , OOH»<HMr«»<^i»<QOOOO«t'fO'tOoOOOOOOOOOOOOOO '-5 O 

' ^ — z 1 ^ ^ ^ ^ ^ ^ -• ^ ^ ^ -• O 0000000000000000 05 0' 

>0000000000000000 


O O O o o o < 


5 ^ ^ ^ 'P ? k:' ^ 2 £i ? ^ ^ S y y ^ * o c cd o 05 ud << o cj -0 © <1 u uj o cj ^ <1 co <1 o hi o cj cj < 

u ** 5: ■<-' O' O' N £ N I s * N O' CO CO 0.' CO CC' Oj 05 05 O' 0- 0 0 0 0 0 0 0 CD Q O O O O O O ^ O C J CJ CJ *>5 < 

O O O- o O o o o O O o o o O O o o O O o o o o O o O O o o O O T - 

o o o o o o o o o O o o o O o O o O o c - — ~ - - - = - - - - 


o o o o c> 

CJ 05 UD >|J N 


• CJ 05 UD <• N 05 0 O CJ CO «t UD <5 K 05 O- O C J 05 ^ UD <i 0- >Ti O' O 

1 05 05 CO O.i 05 05 CO 05 05 O'- O' 0- i>. 0 i' 0 it. i> r?-. o O O r\ o O O' C* O *-• ^ «-i «-< »h 

• O o O o O O o o o O O O o O o o O o ^ -^1 ”-1 ^1 -| -H _ 

:• o o o o o o o o o o o o o o o o o o o o o O O O O o o o o o O o o o o o 


>OOOOOOOOOOOOOOOOCOOOOOOOO 

<?. O — CJ 05 liD <1 SCO CO H CJ 05 UD >0 O' 05 0 O C J 05 

-I CJ CJ CJ CJ cj Cj CJ CJ cj CJ 05 05 05 05 05 05 05 CO 05 05 

o o O O o o O o o o o o o o o o o o o o o o o O o o 


Number 42 

54 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 13 





-ft ★ 


North Star Disk 


* 


STOIC 


* 


Our November-December issue was barely in the mail when 
I was tracked down on the telephone by a fellow named Bob 
Fleming. “I've got some bad news for you,’’ he said. “That 
STOIC program you’ve just published looks exactly like the 
original STOIC program written by Jon Sachs a couple of 
years ago in a joint Harvard-MIT engineering group. ” 

I obtained a copy of Sachs’ program and quickly ascer¬ 
tained that Fleming was right: it was almost word-for-word 
the same program. I called John Sachs, now at Data General in 
Massachusetts. He told me that he developed the program in 
1978 at the Harvard-MIT Health Science and Technology 
Division’s Biomedical Engineering Center. He said the program 
was available for anyone to use as long as credit for it re¬ 
mained with the Center. 

B. W. Lee, the author of the piece which appeared in DDJ, 
said, by way of explanation, that the later installments would 
have been quite different than the first. That may, or may not, 
be true, but we still felt, in all fairness, that Mr. Lee should 
have attributed credit to Harvard-MIT and not signed his name 
to work which he did not create. The fact that Mr. Lee was 
charging a fairly significant amount of money to distribute 
STOIC on tape has just about killed our interest in publishing 
anything in the future for which the reader will have to pay 
m ore than copying and mailing costs. 

We have withdrawn the future installments of Mr. Lee’s 
STOIC article. Instead, we are including information here on 
ordering STOIC on tape direct from the Biomedical Engineer¬ 
ing Center. 

We apologize to any reader who has been inconvenienced 
by this unfortunate situation. 

Procedure for Obtaining Copies of STOIC 

An industry-standard magnetic tape (9-track, 800 BPI) 
containing the STOIC program listings along with written 
descriptions will be supplied upon request. /Vn index of 8080 
STOIC programs and the description of tliis magnetic tape 
follow: 


STOIC TAPE DIRECTORY 


M 


PROG 

NUMBER DESCRIPTION 


☆ 




0 STOIC BOOTSTRAP 

1 STOIC KERNEL 

2 BASIC STOIC DEFINITIONS - 

3 FILE SYSTEM ^ 

4 TEXT EDITOR 

5 FLOATING POINT PACKAGE (4 Vi PLACE ACCURACY) 

6 MISCELLANEOUS DEFINITIONS 

7 FAST FOURIER TRANSFORM (FLOATING POINT) 

8 LINE DRAWER AND GRAPHICS PACKAGE (DEVICE DE¬ 

PENDENT) 

9 INTERRUPT HANDLER (SYSTEM DEPENDENT) 


10 FIXED POINT SIN.COS 

11 RADIX EXCHANGE SORT 

12 DOUBLE PRECISION ARITHMETIC PACKAGE 

13 STOIC WRITE-UP PART 1 

14 STOIC WRITE-UP PART 2 

15 STOIC ASSEMBLER WRITE-UP 

16 STOIC KERNEL WRITE-UP 

17 STOIC FILE SYSTEM WRITE-UP 

18 STOIC EDITOR WRITE-UP 

19 STOIC FLOATING POINT PACKAGE WRITE-UP 

20 STOIC INTERRUPT HANDLER WRITE-UP 

21 STOIC BOOTSTRAP WRITE-UP 

22 STOIC INTIAL LOAD INSTRUCTIONS 

TAPE FORMAT 

NO LABEL jj 

9 TRACK, ODD PARITY, 800 BPI 
FIXED SIZE BLOCKS: 2640 BYTES (DECIMAL) 

EACH BLOCK IS 20 132 CHARACTER LINE IMAGES (ASCII) 
LINES ARE BLANK FILLED WITH NO CARRIAGE RETURNS 
TABS ARE NOT CONVERTED TO SPACES 
LINES CONSISTING OF A FORM FEED FOLLOWED BY 131 
BLANKS SEPARATE PAGES 

INDIVIDUAL PROGRAMS ARE SEPARATED BY A LINE 
CONTAINING THE STRING “***EOF***’\ 

ALL PROGRAMS ARE IN A SINGLE FILE 
TWO COPIES OF THE FILE ARE INCLUDED ON THE TAPE. 
SEPARATED BY HARDWARE EOF AND TERMINATED BY 
TWO EOF’S. 



PROCEDURE: 


1) MAKE LISTINGS OF ALL PROGRAMS AND WRITE-UPS 

2) READ ALL WRITE-UPS 

3) FOLLOW THE DIRECTIONS IN THE INITIAL LOAD IN¬ 
STRUCTIONS TO MODIFY PROGRAMS FOR YOUR SYSTEM 


THE TAPE CONSISTS OF APPROXIMATELY 9000 (DECIMAL) 
LINES OF TEXT (PER FILE). 

WRITE-UPS 


STOIC.WU 

STOIC 1 

STOIC 2 

ED.WU 

BOOT.WU 

PAPER 

MODS 

FP.WU 

FS.WU 

RCV.WU 

LETTER 1 

COMPARISON 

KERNEL 

PROM.WU 

INTERRUPT .WU 

CODE 

SYSGEN.WU 


DESCRIPTION OF HOW TO GET STOIC 

RUNNING ON A NEW MACHINE 

STOIC WRITE-UP PART 1 

STOIC WRITE-UP PART 2 

TEXT EDITOR WRITE-UP 44 

BOOTSTRAP WRITE-UP 

MANUSCRIPT OF STOIC PAPER 

LIST OF ALL SOFTWARE REVISIONS 

FLOATING POINT PACKAGE WRITE-UP 

FILE SYSTEM WRITE-UP 

RCV WRITE-UP 

DISTRIBUTION LETTER 

8080 SIGNED AND UNSIGNED COMPARISONS 

KERNEL WRITE-UP 

PROM BURNING PROGRAM WRITE-UP 

INTERRUPT HANDLER WRITE-UP 

ASSEMBLER WRITE-UP 

INSTRUCTIONS FOR GENERATING A NEW 

BOOTSTRAP FILE AND RUNNING THE 

COMPRESSOR 


Requests should include a brief description of the 
anticipated use of the STOIC programming system and should 
include a blank tape and self-addressed, stamped mailing 
container for its return. Address requests to: 

Stephen K. Bums, Technical Director 
Biomedical Engineering Center 
for Clinical Instrumentation 
MIT; Room 20-A 119 
Cambridge, Mass .02139 


Page 14 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

55 



F€ATUR€ €NHANC€M€NTS 

for ADM'OA 

By John Wakerly 

Dept, of Electrical Engineering 
Computer Systems Lab 
Stanford University 
Stanford, CA 94305 

© 1979, by John F. Wakerly 

A couple of months ago I picked up a maintenance manual 
for my Lear Siegler ADM-3A terminal. Among the SSI and 
silliness in the hand-drawn schematics, I discovered some nice 
ways to add some very useful features. 

Automatic Repeat 

The most useful addition is automatic repeat for every key: 
hold down the key long enough, and it starts repeating. Figure 
1 shows the schematic for the modification. It requires one 
extra chip, a CD4093 quad CMOS Schmitt trigger NAND, to 
be added to the board. When I modified my terminal, I found 
it convenient to glue this chip in place upside-down on top of 
the 74LS00 at location K16 of the ADM-3A circuit board. 

The modification also uses a spare 74LS04 inverter already 
present in the terminal; the existing trace going to pin 1 of this 
chip must be cut as shown in Figure 2. By the way, if you 
can’t identify pin 1 of an IC, then you shouldn’t be doing 
these modifications. 



The few additional components and wires may be soldered 
in place between the CD4093, the 74LS04, and nearby 
locations. Ground may be picked up from the foil that runs 
along the peripheiy of the circuit board or from pin 7 of the 
74LS04; +5 is avidlable at pin 14 of the 74LS04. Be sure to 
install the diode in the correct direction; the band on the 
diode corresponds to the straight line in the diode symbol. 
Also, the 4.7 capacitor should be a tantalum or electrolytic, 
and the end marked “+” should be connected to the diode- 
resistor junction as shown. The circuit may be tested off-line 
with the terminal in half-duplex mode (set the HDX/FDX 
switch to HDX). 

Op eration of the circuit is straightforward. The existing 
signal KEYDATA is low whenever any key is depressed, high 
otherwise. This signal is buffered through a spare 74LS04 
inverter at location LI 6. The 74LS04 drives an RC network 
through a diode; any switching diode may be used. The voltage 
across the capacitor is sensed by the CD4093 Schmitt-trigger 
NAND, whose output is tied in parallel with the ADM - 
3A repeat key. 


Number 42 

56 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E Menlo Park, CA 94305 


Page 15 






cut here 




1 



1 



[= 

—_ 


c 


□ 

c 


□ 

c 


□ 

[I 

L16 

□ 

c 

B5 

□ connect 

c 


□ 

c 


V 

□ 


□ 

c 



c 


□ 

c 


=i 4 

c 


□ 

c 


cut here 

Figure 2 Trace cut at LI6. 

Figure 3 Trace cut at B5. 


Normally, KEYDATA is high, the 74LS04 output is low, 
holding the capacitor discharged through the diode, and the 
CD4093 o utput is high. When any key is depressed, 
KEYDATA goes low, raising the output of the 74LS04 high, 
which allows the capacitor to charge through the resistor. If 
the key is held down long enough, the input switching 
threshold of the CD4093 will be crossed and its output will go 
low, mimicking the effect of holding down the repeat key. 
When the key is released, the capacitor immediately discharges 
through the diode and the 74LS04 low output, causing the 
repeat function to be released. 

Some notes on this circuit are in order for serious logic 
designers. You may ask, why not get rid of the 74LS04 and 
just use t he W outpu t of the 74LS151, which is the comple¬ 
ment of KEYDATA? The problem is that Y is obtained 
internally in the 74LS15 1 by inverting W. If we used W, we 
would glitch KEYDATA for the rest of the terminal because 
of tJie nonstandard voltages that would be developed every 
time we discharged the capacitor througi W. Another 
question: why not use another section of the CD4093 instead 
of the spare 74LS04? Answer: the CD4093 doesn’t have 
enough low-state drive to quickly discharge the capacitor. 
Finally, why not use another spare 74LS04 instead of the 
CD4093? Answer: CMOS is required for its high input 
impedance (5M ohms or more) to allow the 80K-ohm resistor 
to determine the effective time constant; LSTTL input impe¬ 
dance is only about 20K ohms. A Schmitt trigger is required 
because of the slow input signal rise time. 

The length of time a key must be held down before it starts 
to repeat is determined by the RC time constant. As a rel¬ 
atively fast typist, I found an 80K resistor and 4.7 uf capacitor 
to gi ve an appropriate delay, about 400 milliseconds. More 
heavy -handed t pists will want to increase these values to 
prevent unwantc d key repetitions; doubling either component 
value doubles th t delay. 

Caps Lock 

The next mo lification is to eliminate a useless feature and 
replace it with a useful one. If you really have found a use for 
the keyboard-lock feature of the ADM-3 A, read no further. 
Otherwise, eliminate it by cutting the trace coming into the 
74LS11 at location B5, pin 10, and connecting pins 10 and 11 
of tliis IC together, as shown in Figure 3. 


Now the KBLOCK signal can be used to enable and disable 
lower case characters. As shown in Figure 4, simply connect a 
wire from pin 9 of the 74LS113 at loca tion BIO t o pin 13 of 
the 74LS10 at location L10. This puts KBLOCK in parallel 
with the LC EN switch on the front panel. Then set the LC EN 
switch to the UC posi tion, and the internal DISABLE/ 
KBLOCK switch to the KBLOCK position. Now when you 
turn on the terminal, it will come up in uppercase only. When¬ 
ever the terminal receives a control-O, lower case will be 
enabled; receiving a control-N will return it to uppercase only. 
If you connect to pin 8 instead of 9 of the 74LS113, then the 
functions of control-N and control-0 are reversed and the 
terminal will power-up to lowercase only. Setting the LC EN 
switch to LC EN unconditionally selects lower case. As before, 
these functions may be tested off-line with the terminal in 
half-duplex mode. 


If your computer doesn’t echo control characters when 
they are typed from the keyboard, you may want to provide 
some special system commands to enable and disable lower 
case. For example, I modified my computer’s CRT I/O driver 
so that whenever it receives a NULL from the terminal 
(control-*® or control-space on the ADM-3A), it toggles an 
internal upper/lower mode flag and sends the appropriate 
control code to the terminal to put it in that mode. Further¬ 
more, I automatically select uppercase-only when exiting to 
my ROM monitor, and enable lower case when entering the 
disk operating system. 



Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

57 




31 Extra Flavors of Printing Characters 


If you have an ADM-3A with the lower case option, you 
may notice that sometimes at power-up there are strange 
characters on the screen you can never generate yourself. 
Well, it turns out that the optional lower case ROM for the 
terminal has 64 characters in it, of which 32 are the normal 
lower-case character set. The other 32 characters correspond 
to the 32 ASCII control codes, 00 through IF hex; 31 of these 
are printing characters, including some underlined letters and 
numbers, various arrows, a bell, and strange symbols. The 
terminal never stores these codes in the refresh memory when 
they are received from the computer; it simply performs the 
action, if any, required by the control code (clear screen, move 
cursor, etc.). Thus, the only time you see these characters is 
when they somehow get into the refresh memory at power up. 
What we need, then, is a way for the computer to tell the 
terminal to go ahead and store these codes. 

As wired at the factory, the ADM-3A looks only at the 
low-order 7 bits of each received character, even if an 8-bit 
character is received. We can make use of the eighth bit to 
make the extra characters available. If the eighth bit is a 0, we 
treat a character between 00 and IF hex as a normal control 
character; if it is a 1, we ignore the control function and store 
the character in the refresh memory instead. All this takes is 
one spare AND gate at location H5. As shown in Figure 5, cut 
the output trace from pin 10 of the 74LS02 at H3 and input 
trace from pin 10 of the 74LS25 at HI. Then install four new 
wires to make the circuit shown in Figure 6. 

Continued on p. 25 



Figure 6 Extra-character circuit. 



Number 42 

58 


Dr Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 17 



I 

IA Table-Driven Assembler 


I 

BY DARREL J. VAN BUER 

1522 Brockton Avenue #5 
Los Angeles, CA 90025 

Darrel J. Van Buer is studying for a Ph.D. in CS at UCLA. 
He is a senior computer programmer analyst at SDC. 

This article describes a table driven assembler I recently 
constructed to help with my investigation of the new one chip 
microcomputers. At present, my interest is in the Intel 8748 
computer and the related Intel 8741 Universal Peripheral 
Interface, both with user programmable EPROMs. With the 
continued proliferation of new microprocessors, especially 
low end processors too small for resident utilities, I felt the 
best approach was a table driven cross-assembler. Since my 
main system is an 8085-based system running CP/M, I had a 
large choice of source languages for the assembler. I used 
ML,-80 for several reasons, including availability, efficiency 
and structured programming features. ML-80 is a structured 
assembler/compiler written in 1975 to combine the advantages 
of assembler level machine control with a good set of control 
structures to produce readable and efficient code. I wrote it 
as a table driven compiler to make it easier to modify for use 
with other 8-bit machines. In particular, all components of 
an operation code except immediate operands are determined 
by table lookup alone. The target machines far the assembler 
listed here are the Intel 8748/8048/8035 and 8741/8041. 

General Features of the Assembler 

The assembler provides as basic features for all versions 
line parsing, symbol table management and expression evalua¬ 
tion. The line parser defines a source line as a series of fields 
separated by blanks and tabs and terminated by CR6LF. 
The first field is an optional label starting in column one, 
not over 6 characters long, optionally followed by a colon. 
The second field is an operation code not over 5 characters. 
The third field is an optional list of operands separated by 
commas. The fourth field treats the rest of the line as com¬ 
ments. Note that, for some operations, some of the optional 
fields may actually be required. To allow for longer labels 
and operations requires changing the declarations for OP, 
LABELL, LABELTAB and adjusting the loop counters in 
PARSELINE and GETNAMEVAL. The expiession evaluator 
recognizes labels, numbers and *$’ for the current value of the 
location counter (i.e., the address of the inslruction contain¬ 
ing $). Numbers may be in decimal, hexadecimal, octal or bi¬ 
nary, denoted by a suffix of D, H, O, or B respectively. A 
number with no suffix is decimal. The first character of 
numbers must always be digits to distinguish them from 
labels. The expression evaluator also recognizes the operation 
symbols V, *>’ and “<’ for plus, minus, low byte and 
high byte respectively. When used as unary operations, the 


On CP/M 


first operand is zero. Low byte is the less significant byte of 
the following value and high byte is the more significant 
byte. For example, >01234H is 34H and <01234H is 12H. 

Customizing the Assembler 

The behavior of the assembler is controlled by two main 
tables and two case statements (one in each pass). The first 
table in the listing is the operand table from label RR1 
through RR31. This table is coded using macros RENTRY, 
RERROR, RNULL and RGO. The second table is in the 
declaration of OTAB immediately after the operand table. 
This table, constructed with the macro OENTRY, describes 
the operation codes for the assembler. Each entry in this table 
gives an operation code, e.g., ‘ORG’, the base value for this 
operation, e.g., ’0‘, and names a starting point in the operand 
table, e.g., ‘RR30’. Each operation is applied to a serial search 
of this table for an exact match (both length and contents), 
the operation value is saved and the operand pointer is used to 
start the search for operands. The operand table is serially 
searched from the starting point given by the operation table. 
The operand table contains several kinds of entries, some of 
which exist to make the table shorter by sharing portions. 
Entries created by the macro RENTRY result in comparison 
of the start of the operand field with the table entry. An 
RENTRY consists of match string, e.g. ‘PI, #’, an operation 
correction value, e.g., ‘49’ meaning 49H, which is added to the 
opcode to produce the correct value for this operand, and 
a type code, e.g. ‘LIM]’, which drives the case clauses for 
operand format in the assembler. These types are generated 
by macros which expand to small numbers. The types which 
are currently defined are error, immediate byte follows, same 
page branches, full memory call/jump, pseudo operation and 
operand complete. The actual meaning of a type is defined 
by the case statements in PASS1 and PASS2 described below. 

Entries created by the macro RNULL are for operations 
which have no operands. An entry or type RNULL is identical 
to RENTRY with null match string. Since the search is for a 
match on the first few characters of an operand, if one op¬ 
erand form is a prefix of another for the same operation 
(say P and P3) the longer one should come first, otherwise 
both P and P3 would match with P. 

Entries created by the macro RGO are used to share parts 
of the operand lists. An RGO entry gives an opcode correction 
value and names another part of the operand table. When the 
table lookup routines encounter an RGO entry, the search 


Page 18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

59 





switches to the named part of the table after adding the cor¬ 
rection value to the opcode. This correction allows for differ¬ 
ences in the spacing of different opcodes. For example, the 
table entry RR4 ends with [RGO ‘60’ ‘LRR3]’] because 
most of the possible operands for ADD are the same as for 
XCH, saving 10 entries. RR3 is part of another space saving 
technique. RR3 is an internal label or the declaration for RR1 
(and RR2), thus, if the search falls through the entry efter 
RR2, the effect is the same as LRGO ‘0’ ‘LRR3] ’ ] without 
the overhead. RGO allows several variants to join since only 
one can fall through, and also allows other variants by using 
opcode corrections. 

The last type of entry is generated by the RERROR macro. 
This macro signals that the operand field does not contain 
a valid entry. Note that every path through the operand table 
must end with RERROR or RNULL. 

PASS1 Case Statement 

This assembler is a traditional two pass assembler which 
resolves label values on the first pass and generates code on 
the second pass. These two passes are embodied in the pro¬ 
cedures PASS1 and PASS2. In each of these procedures, a 
case statement is driven by the results of the operand table 
search. In pass one, the case alternatives do processing to 
resolve all labels. The basic function of pass one defines all 
labels as the current value of the location counter (the location 
counter is the assembler’s analog of the processor’s program 
counter). The main function of the case statement is to in¬ 
crement the location counter by the length of each instruction. 
The second function is to provide special processing for 
pseudo operations. Pseudo operation processing is driven by 
a second case statement. The driving value for this case state¬ 
ment is the opcode value since pseudo operations don’t 
generate an operation in the usual sense. The case for EQU 
modifies the definition of its label to the value of the expres¬ 
sion. The case for ORG resets the location counter to its 
expression. The DS case increments the location counter by 
the value of the expression. 

PASS2 Case Statement 

The main action in pass two is code generation by the dif¬ 
ferent cases with appropriate location counter adjustment 
(normally done by EMIT1, the subroutine which emits a byte 
of code), again with special processing in a second case 
statement for pseudo-operations. The calls to MAGNITUDE- 
ERROR are made when a two byte value is to be emitted in 
one byte but is not the sign extension of the single byte. 

8741/8748 Assembler Notes 

The language currently recognized by the assembler is the 
union of the operations for the Intel 8741 and 8748, and the 
appropriate Intel User’s Manuals are the primary reference 
on valid formats and operands. The operations are divided 
into four types for this assembler. 

Type 1. This type is for operations with a single immediate 
operand data byte, for example ADD A, #5. 

Type 2. This type is for the short conditional jump instruc¬ 
tions which are limited to destinations on the same page (256 
byte block) as the next instruction, for example DJNZ Rl, 
LOOP. 


Type 3. Tliis type is for call and jump in which three 
address bits are part of the opcode and the remainder of the 
address is in a second byte. 

Type 4. Tliis is a dummy type for pseudo operations. 


These are 




ORG 

expression 

;set location counter to ex¬ 
pression 

label 

EQU 

expression 

jequate label to expression 

Llab] 

DS 

expression 

p-eserve expression bytes 

Llab] 

DB 

expression 

;define byte with value ex¬ 
pression 


PRINT 

ON 

;list assembly to printer 


PRINT 

OFF 

pio listing (except errors) 


Most of these are standard pseudo operations. The PRINT 
pseudo operation immediately affects the listing, making it 
possible to list only parts of an assembly. The initial state of 
the assembler is PRINT ON. 

Type 5. This case is for simple opcodes with operands 
included within a single byte, for example MOV A, @R1. 

Miscellaneous Considerations 

As compiled here, the assembler is limited to 255 labels 
by the table size declaration, but the search strategy is general 
enough for any length table. To simplify I/O, the assembler 
also presently uses the fact that there is only IK of EPROM 
in an Intel 8748/8741, and first generates an in-memory array 
of the result and fianlly writes a binary file of the result. 
For larger memories, such as an 8080, EMIT1 needs to be 
revised to write to an output file, in a format such as Intel 
hex. Since I wrote this on my CP/M system, the I/O used is 
specific to CP/M but has been carefully encapsulated in only 
a few subroutines. Procedure GETFC returns successive char¬ 
acters from the input file, and thus is responsible for reading 
disk sectors and dribbling the contents out one character at 
a time. Procedures PRINTALINE and PRMSG call CP/M 
BDOS to type characters on the console. PRINTALINE 
lists lines of formatted assembly output, while PRMSG types 
error messages. The procedures ZTFCB, OPENR and OPEN- 
HEX also perform CP/M specific functions. These procedures 
all assume the existence of a CP/M initialized file control 
block which CP/M has parsed the required file name from the 
command invoking the assembler. For another DOS, it may be 
necessary to do this parsing separately, and change the format 
assumptions made by these routines. ZTFCB initializes a file 
control block piior to opening. OPENR opens a file control 
block to read the source file, and is called twice, once for 
each pass. OPENHEX creates a new file with suffix SCC and 
writes the memory image buffer of the assembled code out in 
binary format. Outside of these routines, the assembler makes 
no assumptions about the file structures available except that 
it is a sequence of bytes which can be read twice. Conversion 
to another DOS should be fairly easy, and conversion to a 
non-disk system should also be feasible. 

Program Availa bility 

The ML-80 compiler is part of the CP/M users group col¬ 
lection, and so is available from them. The PL/M source 
for ML-80 is available from the Intel Users’ Group. As an 
alternative, for $10 I will provide an 8 inch, single density 
IBM format CP/M diskette which contains ML-80 and the 
source for the assembler in this article. 


Number 42 
60 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 19 



f I 



ZUIZZZZZZZZZZZZXXZZCxJU^M- 

! *—» - - - - Z 

l-_---------------- Cx) 

- f- ................ ot-O*--'- 

OCiCOCT'<CQUQ[ilU J ®<7'<fflUQ[iJIi,<<CQCO •“ 
0'0<<<<<*t<<maiCDCDlIlCQCQCQOOOO* - 
J - - OOOOOOOOOOOOOOOO - - - - CM •“ 

r ................ voc 

- - - .... a 

<«...... ..........<<q h 4 k o 

- .<<<<(<<<<«•%«*««« - - - 
> W3 ............... -O »- O *- «< - 

-Hc/;io»-f\jm3'tr»sot~o*-CMrn=rir*vot-'KK«K - 
EVlIl.lEKKKKCCKBKKKEKKKEtttlill^H' 
. C 

Cl 

•XXXXXXXXXXXXXXXXXXXXXXXC 
OC a. EKCECeEKCEEKKlCElCCCCIEEa:* 
'HHHHHHHHf-HHHHHHHHHf-'HHHS-* 

czzzzzzzzzzzzzzzzzzzzzzzc 

) r.) f»; f.} r,} r. i r. ^ r.- ) f,] r.i r.i r.^ f.- | r. ) r,] r t ^ r. ^ r.j r.x r. ^ r. ^ r.i ^ 

CCEZCCCKXZCCICEKCCKEIEEKEEKCCQ 


CJ —< '“I 

—< Z - • •—• «—I Z Z Z Z Z Z Z — 

• Ur -1 ZZUUUUUU Cl]"-' 

-*> Cl] Cx] •—! —I I—l i —i —l I—« —< r—' 




- - UUuu. 




oc a . c 

■—» f- Cxi l 

w a; v 

<Ou-. . 


a; H x x r-i 

’ C' Z E (C - 

a, Cxj E—I . 


x x x x x x x 

a: E K K K « E 

h t- h h h h t- 

z z z z z z z 

Cx] Cx] Cx] Cx] Cx] Cx] Cx] 

CEEEEEK 


Z E E O C 


-« ■—i «E *—. m 

CM H H CM 


ZZ r—> 

Cx] Cx] Z «E - r-irinr 

-Cx] DC . 

-- m < E E E I 

V.-- —IQSCQOQCQC 

- CDu 

in in z - >_<•-.• 

cx] cx. z cx] m - - 

O O Cx] —I CM CO .... 

-- - - - - <C ffl u < 

♦ <y> o o o < 

< W W inw - - - ” - 

r a m - c- o - - - - ■ 

a < Q z os.... 

- J - CJ - <- C\l fOJ l 

Cl. • H h •* EEEEI 

X-S--^X . 

E ■—> 05 

HX 1 —'XxasHxxxx; 
z E - EEOZEEEE1 

■■h^hhKlxlhhhhf 
z-^zzasaszzzz: 

Cl] *- Cx] Cx] Cx] ._> Cx] Cx] Cx] Cx] C 

E E E—-EEEEI 


Cx] r—' - r-1 25 

' - r-i Z Cx] 

- r-. z Cx] 


Cx] f-i r- 

i—I z s 

. Cl] c 


CO - - - 


— 10 3 
^ a. co a. 

<—> _i a. o 


- *- o »- « 


< X X c 
: DC 05 c 
] C—• t—* c 


Jl-II-I l_l !_l <E u 


CEE 

-> Cx] 

' cc ^ 
«•—> < 


E h X 

o z ac 

K Ci] h 

ac ac z 

Cx] >_i Cx] 


a ■ 


- - r-' X - 

> JE 

x x ac _j h x 

E E O D Z E 
hhEZUH 
Z Z CE E 05 Z 
Cx] Cx] Cx] i_i i_i Cx] 
05 ac 35 —- —- cc 

<5 < i_l 

f- H 

gg 

o *- 

m on 
05 ac 
05 K 

Cx] Cx) 
ac 05 
< < 

J _] 

cj cj 

Cx] Cx] 

Q Q 


O J 
ac < 
05 > 
Cx] a. 
cc o 


CC 1—1 


8 

a ;■ 

- a 

a > 

a i 


' 05 X >—• 


in 


Cx] a. 


- Cx] - . 


Q . . . . u - 

. -> r—, r-, r—, r—« 




- CO >—* 

J - 3 
a. - _] 
0.-0. 
O o. 
i—• Cx] O 

x x « 

»- H O 


-J - -JZZZZZZi.- 

■> -I—I CCCx]Cx]Cx)Cx]Cx]Cx]CxlCi]Cj 
£ 3T O <—t ■—< >—* *—* 1 —' — 1 — • —i — 
O M .......... 


,2 5 


Z —“• • 
Cx] Z Z 
>—• Cx] Ci] 


z z ;_ 

z + Cx] Cx] Cx] Ci] 

Cx] _1 —I LJ l_l 

u_, Q - . . . 


- CO 
X Cx] 

x -J a, 
O O ac a. x 

05 05 h a. h 

CJ O r—• Z O 
< < - Cx) CO 
O 2E r X CO x 

CO ‘— 1 O CO O J 

3 : ® x ac o. 

'—i - -] «c a, 

X r-’ - a. O 

=r - cm as q, x 

O- --o O DC J 

CO - o: E-r _] 

r «c os o z r> 

to r e u a u z 

PROCESS 

Cx] o o o o o o 

a. E 05 E 05 05 05 
X CJ CJ CJ CJ CJ CJ 

RS2SSSS 


■ C <O'-000'<CQC'QCx][ii 

- . - OOOOC’OOO 

+ PO+ -------- 

■ J 

- 05 - OEEO'-tMfnai^vOt- 
)X<»iXaja)EEa5Ea;o5Q5E 

I • <* «c «« «c «c «« <« «: «*;<(<..- 


- r-i - - - O = 


m - . m vo r— 


—i 1 —i z CJ i—i 
... Z Cx] _] z 
^ Cx] 1 —I X Cx] 

- in - 


on - 

-OSS--- 

«. e o. m \o 
->—• - a. cl. 
< - : 

- «E «E 


-3 0 - in e - 
CJ — t— CO t- 
i_i cr> - - cm 

... <s - 

r- - Q 

- - a in'O t- - cx. - o 




Z - Cx) 
Cx] —i >_i 

•—> z - 

. Cx] 


- 00 *“ < - 


a. a. a, a. .. o - o Cx, » <c 


!SS -- -- n 


- - CJ ' - 


Z f—» . Cx] r- 

Cx] Z r—. i_i S 


'5, S“ 


< - 
cc o 
m - 


— f- 

OO O 
(M O 


H •« 


. X XXXXXX>iXXX 

: ac 050505050505 a. 050505 

^ ■—• e— •—• t-* e— t— i— t— e— t- t-t-H 

: - z - zzzzzzz zzz 

) tx] Cx]Cx]CxJCx]Cx]Cx]Cx Cx]Cx]Cx] 

:?EOEEEEEEE 05 05 X 

J »- ftlLJLJLJLJLJLJU.^LJUJ 


<—• X O X 

ac e vO e X x : 

OH- H 05 05 c 

ac z z H H l 

ac cx] o cx] z z : 

Cx] X O 05 Cx] Cx] c 

05 < 05 >—i 05 CC C 


X ' X - 


XXXXQ5JQ5XX X E J H E f 

'EEEEOJHEE 05.0JZO: 

hhhhEDZt'h'-'hEDIxlEI 
'ZZZZQ5ZCx]ZZ — Z 05 Z 05 05 C 
)Cx]Cx]Cx]Cx]Cx]a50SCx]Cx]^Cx]Cx]a5>—>Cx]u 
I 05 E E E E I—J . E E ^ E E '—I '— 05 ' 

' c c ^ < H E 

H h f- E-I <5 


i 05 H 

: o z 

• 05 Cx] 

: 05 ac 

) Cl] L_. 


x x x as h ac H 
05 05 as O Z O z 


• 05 Cx] C 
: DC as t 
I Cx] 1—1 0 


2 2 


Cl] Cx] 
05 05 
< < 
—] _) 
CJ CJ 
Cx] Cx] 

o o 


Cx] Cx] 
CC 05 
< < 
J —1 
CJ CJ 
Cx] Cx] 

a a 


•—•05 •—i _ _ 

XEhXEJHE 

05OZQ5O53ZO 
hEUHEZUE 
ZEEZEEEE 
Cx] Cx] i—• Cx] Cx] i—i.—i Cx] 
05 DC — 05 QC —— 05 

ULJ<ULJ«( <•—I 


Cx] Cx] 
05 05 
< -E 
J J 
CJ CJ 

Cx] Cx] 

a a 


h x 
Z 05 
Cx] E- 
05 Z 


Page 20 


Dr. Dobb's Journal of Conputer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

61 






























Number 42 

62 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Pane 21 






Page: 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

63 







CM w w 


X X 
II 


s3 8~ 

II Q 
_J Z I 
X Cd I 
X X 


X •• + 

«- < _J 

CO X — 


Cd ^ 


Id 


cd o • - co x 

X Cd X X 

=> Cd X CO Cd 

Q X 3 « «* 

cd «*: a - 

U Jld • J 

O O O II J 

x Cd O Cd «t 

x a x a o 


X N ' 

X ~ * 


• X — CM M II 
« U - Q - 0,0 

- '-v m < z o o 

- •“ •• II H «C _) 

' O • X •• Z X ^ Cd Q 
.ONffl-COO c/5 Z 

J m ^ H II b. J < 
Q X / t/1 < W 'i| X 

• z o •• 

< CM •• 


» J < w Cd 

' X X ^ Q CO 

■ X ^ Cx, Z J 

I CM •» W Cd Cd 


•- X II 
+ i 8 


■I o 


■ «»- J ii 


3=2 

J X o 

: ii 

1 J z c 
J X Cd c 

2 w X . 

' ^ H £ 


W X J 


5 — X V >+ 

X Cd o o co 

Q on -j 


- Q J •• ~ 


Cd X ^ x u w ► 


a co 

Z J 
Cd Cd 


Cl CO 

2: -J 
Cl Cd 


Cd — II ( 

Q co Q II 

Z -J Z J . 

Cd Cd Cd X : 


X O w 
hK ii 
Cd X 
O N 


* Q ii 


i a < 

! W *— Cd 

i co co 

. M u. -J 


Cd Cd Cd Cd 


X X 


cd a 

..25 


ft 

z u, 

Cd M 


Number 42 

64 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 23 












Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

65 






I 


I 


o 
o 
a q 


o 

o 

CQ 

^ X 


to co ac 

O O cc 
a a w 
co co u 
t- 

< 

J J u 

^ 35 

O O f- 

5 


CjJ 


2: o 

II CC 1 I '—I o 

< U CQ CQ 

—- N O C_J O 

II U, U, QC 

— —• e-« e-« c*3 


X I ll 


i M 


H <T> CM w 


331 


j j _j 

3 35 

000 


' •- •- w — 

: cc cc x r—< 

■ z 2 z r 

) u u to a, 

1 a. a. a. u 

>000^ 

J 

• _J J J O 

J J J h III 

.<<<00 

I O O C_) o CO 


E- 

< 

cc 

Cz] 


Q 

Cz] Q 
E- Q 
< < 
O 


cc 

Eh 


Q 

Cz] > 

52 

O 


as 

Eh 


Q 
—] 
Cz] 


as 

O 

CL 


CO Q 
CO J 
Cz] Cz] 

as m 

Ok Cl. 
X 

Cz] CC 
O 
Z Cl. 


O 
in o 
* OQ 
CM =** X 
Cl 4* - - 

Cl, -OO 
O <C CC OS 


Eh 

< 


Q 

Cz] Q 

5S 

O 


Q 

Cz] > > 


«C 

o 

z z 

:d o 

as as 

Eh 2 eh 

W o 



CL, 

z 

z 

z 

Cz] 



Cz] 









CL, 

Z 

z 

Eh 

O 

M 

M 

w 

O 


H 

O 







Cz] 

Eh 

O 

w 

M 

00 





05 


2: 

05 


Eh 






CO 




Cz] 

Q 

05 

05 

05 



<c 

< 


Z 





Eh 

Cz] 

Q 

05 

05 

Eh 

Cz] 

O 

O 

O 

_] 


z 

J 

Eh 

M 

Q 

> 

0 


< 

Eh 

Cz] 

O 

O 


NJ 

05 

05 

05 


Cl 


T— 

00 

05 

Q 

O 

0 





05 

05 

X 

M 

05 

05 

05 

O 

in 

Q 

O CO 

Cz] 

CL, 

<C 

z 

s 

Eh 

— 

X 

W 

05 

05 

=T 

Z 

Cz] 

Cz] 

Cz] 

O 


Cz] 

0 

Eh 





CO 

O* 

•=r 

Z 

Cz] 

Cz] 

t- 

O 




Eh 

m 

Z 

Eh CO 






Cl| 


C^~- 

O 



ro 

O 

X 

X 

X 


0 

M 

0Q 

Cz] 





Eh 


30 

O 

X 

X 

Z 

O 

<X 

< 

< 

Cz] 


Cl 

Cz] 

CL, 





Cz] 

X 

2 

O 

< 

< 

00 

Cz] 

Eh 

Eh 

Eh 

53 

0 

Cz] 

53 CM 

X 





Cl X 

< 

00 

Cz] 

Eh 

Eh 

< 

CC 

Z 

Z 

Z 

J 

0 

Q 

d 0 

Eh 





Czil < 

Cz] 

< 

05 

Z 

z 

A 

z 

X 

X 

X 

< 

0 

Z 

< 0 

A 





A 

05 Cz] 

A 

Z 

X 

X 

<t 

CD 

CO 

CO 

C/3 

> 

0 

CD 

> 0 

< 





<3! * 

CQ * 

< 

53 

CO 

00 


Q 

J 

Cz] 


as 

o 

Cl 

Cz] 

O 

as 


CO Q 
CO J 
Cz] Cz] 
CC M 
a- Cl 


Cz] 

a 


05 

O 

05 

3 

Cl 

< 

z 

3 

05 

O 

in 

Q 

O 

Cz] 

O 


Cz] 

O 


Eh 

m 

Z 

Eh 


O M 


CQ 


- _ Cl Cz] 
HDOMDCvl^- 
Z _] O Q _] O O 
X < O Z < O O 


I 


I 


Continued from p. 17 


Now the computer can display the 31 extra characters by 
sending codes 81 through 9F hex to the terminal (code 80 will 
print as a space). All we need now is a way to generate these 
codes from the terminal itself. Again, the terminal normally 
generates only a 7-bit code; bit 8 is set according to the value 
of the BIT8 0/1 switch when sending 8-bit data. As shown in 
Figure 7, we can instead use the otherwise useless HERE IS 
key to set bit 8 from the keyboard. The signal at pin 12 of 
the 74LS04 at location L16 is high whenever HERE IS is 
depressed. Simply connect this signal the UART bit 8 input 
(pin 33 of K5) and set the BIT8 0/1 switch to 1. Now bit 8 
will be set to 1 only when HERE IS is depressed. Thus, 
pressing both CTRL and HERE IS will access the extra 
characters. If you are especially lazy, you can make HERE 
IS automatically invoke the CTRL function also, by con¬ 
necting pin 13 of the 74LS02 at L12 to pin 9 of the 74LS04 
at L16,and grounding pin 6 of the 74LS04 at L18. 

Acknowledgments 

Thanks go to Dennis Allison for suggesting that I make 
these enhancements available to DDT s readers, and for serving 
as a guinea pig for the do-it-yourself instructions given above. 

This article was prepared using my ADM-3A.(note 

the use of the repeat key) and custom word-processing 
software running under Smoke Signal Broadcasting’s DOS68 
disk operating system for the Southwest Tech 6800 computer 
system. 


+5 



Figure 7 Modifications to set bit 8. 


Number 42 
66 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 25 











A User Interface to 




Program 

Renumbering 


BY DEWITTS. BROWN 

1650 9th Ave. S.E. 

Rochester, MN 55901 

In DDJ #23, Steve Wozniak detailed the theory and code 
necessary to renumber BASIC programs on the APPLE-II. 
Although Wozniak’s program was functionally good, I could 
not use it with the interface provided. In this article I would 
like to explain my solution. If you have an APPLE-II com¬ 
puter or are a forgetful, lazy user, read on. 

The Goal 


Modified User Interface 

An early solution to this problem used variables and an 
EXEC file to reduce the typing and remembering necessary. 


Renumber Data Set Range 


>NEWSTART = 150 
>NEWINC = 10 
>RSTART= 100 
>REND= 110 
>EXEC RENUM. RANGE 


Renumber Whole Data Set 


>NEWSTART = 150 
>NEWINC = 10 
>EXEC RENUM .ALL 


Renumber lines 100-110, to start at 150, spaced by 10. 

Original User Interface 

>BLOAD RENUMBER.ASM 

>Poke 2,150 Mod 256 
>Poke 3,150/256 
>Poke 4,10 Mod 256 
>Poke 5,10/256 
>Poke 6,100 Mod 256 
>Poke 7,100/256 
>Poke 8,110 Mod 256 
>Poke 9,110/256 
>CALL 776 

This is too much typing (about 160 keystrokes for this 
example) and too much remembering (the meaning of four 
locations in memory and two call addresses) for forgetful, lazy 
me. 


This approach still requires 60 keystrokes and the remem¬ 
bering of four variable names and two exec file names (because 
meaningful names are used in place of numbers, the memory 
part is easier than the original user interface). 

Ideal User Interface 

Even with the modified user interface, the renumber 
program was too cumbersome to use often. I, therefore, 
decided to create the “ideal user interface” to the renumber 
program. Here are the qualities I set as “ideal.” 

1. Minimal typing required — only the actual input value 
should be entered. 

2. Only one name to remember — that name would be 
meaningful to aid in remembering it. 

3. Where defaults were used, they would be listed — the actual 
default would be selected with a simple “return.” 

4. Some degree of bad typing would be allowed — the user 
could correct mistakes until “return” entered. 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

67 






5. Some degree of error checking would be imple¬ 
mented — numbers too big or non-numeric characters 
should be rejected. 

6. Performance and storage impacts to the program being 
renumbered should be negligible — the renumber program is 
a tool, not a goal. 

Here is the ideal user interface: 


>EXEC RENUM 
Commands in RENUM are 
HIMEM:-27648 
RENUM=-27648 

BLOAD RENUM.ASM.A$9400.L$200 
CALL RENUM 

On a cleared screen, APPLE responds 


( ENTER LINE NUMBER DEFAULT 




NEW START 
NEW INCREMENT 
RANGE START 
RANGE END 
100 -»150 
103-► 160 
106 -> 170 
107-»180 

109 -*• 180 

110 -> 190 


100 

100 

0 

65535 


? 150 (RETURN) 
? 10 (RETURN) 
? 100 (RETURN) 
? 110 (RETURN) 


♦ 


Entered by 


user. 






Subsequent renumbers could be done by typing ‘CALL 
RENUM’ to avoid diskette I/O delay (of course, continuing to 
type ‘EXEC RENUM’ would work as well—just slower). 

This solution requires only 25 keystrokes (15 if all defaults 
taken) and requires the user to remember 1 easily-remembered 
name. Quantitatively, this user interface is 6 times better than 
the original interface. 

Evaluation 

The goals set down for the ideal user interface were met, 
except for the impact on storage. Compared with 190 bytes 
(X’BE’) used originally, 512 bytes (X’200’) are used. Also, 
the original version did not take storage from the program 
area, as this version does. 

My solution is break a very large program into pieces to 
allow room for this version of renumber. The pieces could 
be connected using the ‘chain’ command. This solution en¬ 
courages me to keep program development modular, as 
advocated in structured programming. 

References 

1. Auricchio, Rick. "An Apple-ll Programmer's Guide," The Best of 
MICRO, Volume 1 

2. Synertek. "SY 6500/MCS 6500 Microcomputer Family Program¬ 
ming Manual." Synertek, Santa Clara, CA (May, 1978) 

3. Wozniak, Steve. "Renumbering & Appending BASIC Programs on 
the APPLE-II Computer." Dr. Dobb's Journal of Computer Calis¬ 
thenics & Orthodontia, Number 23 (March, 1978) 

4. Wozniak, Steve. "SWEET16: The 6502 Dream Machine" Byte 
Magazine, (November, 1977) 




a##***###*#***##**#*****# 


a h- si > 


2 ►- 2 1- 

O O 

r. a r a 

UJ cn UJ 

LL CO LU Lu CO 

O 3 J- O 3 


F h Ct I/) Z tO 2 

Z H 3 < M H H H 

2 O X O OCX 


Z Q H- Z a 

UJ UJ UJ 

LU CO O' U- to 


0 3 1-00 


< to 2 3 


o o 

to UJ o to 


OUcOacf-Xacf- 


(fllUHMUlHl>„UJ>-„ 


a t- a ct 


ncoQcecoQcuO 


to UJ to 

CO h— CO 
2 >- UJ >- UJ 


0 Q 30 Q 3 UJQ 3 qcQ 30 l_lQ I _J Q 2 a: 


< o u. a o 


QOXQO<QOUOOQmOQ 


Fo.<a:< 4 aF 4 aU<a:<XJI<J 


a 2 _J 2 _l 2 

a o < o < o o 


I<J( 0 J<I<O>U>UhJ 


to to UJ 
UJ to UJ 2 
N uj to 
H k to H 
J O < 3 


* Z He 


<>o.O 


Z * X UJ to 
o h to t- co *-t 


< UJ t-t 


to UJ -02 

UJ h h UJ N 

x >- o a o 

h- CO a. < 2 


< UI ft. o H 


o 

u. 

3 


< 

o 


O h- LU SO 
0 £ _J 2 -• 
3 *-« »— 
to < •— UJ 
U. 3 UJ 


CO UJ 

« Q 
X O 


ft************************ 


a. * * Z * * 


**Z*#0£ **ac**O*<#<#o*O*O* 


HNrt-tiflUNiOBi 


N to 4 m V) 


N«3C'OHNM'tUl'0N(00'OHNrtvfifl'flN(0C'OHNrt'tifl\flSt00'OHNrt'tifl'flS«09'O 

HHHNNNNNNNNNNrtrtiortMrtrttOrtM't4't't't'r>f<'t<tinioinininii)iflinii)in'0 


so so 


Number 42 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 Page 27 

68 




******************* 


* LU t/> * 


HI UJ 
Z J- 

•-* Z Z UJ 
J UJ < U 

Z oc. z 
J- UJ < 
OC QC U. oc 


2 2 « Q 
111 III h Z 
Z Z W HI 


L) O O O 

v i: v 

XXII 

O (J u o 


I Ul Q « 

* CO O * 

id £ U I 

* 3 * 

* Z (I) * 

* UJ *-* * 

* oc X * 


KOO* 
KiU.H H 


H UJ UJ H 
* U) a * 


* H- * 

* >- < * 

1 m j K 

* 3 * 

* z Z * 

* w 3 * 

* UJ O * 

* oc U * 

* O < * 


J * UJ H * 
_l * I I * 
<*»-•-•* 


* to o * 


Ct * 3 H * 
N * a. 3 * 


2 * UJ on * 


z iu u h m < 

O' Q (J D Z 

3 z <r o 1 - 


H- - OC 

*h X 3 
2 < H- 
Z UJ 


_II— I 

< < >- 3 

*-«*-• co Z X < O - * 

oc H- I 3 UJ a. Z UJ * 

oc *-• »- O Q Z < 0 * 

<tZ3<JZOU._J* 


OC Z O O 

O h< O O 
Z Z -I Z 
O O a: O 


X o 
a z 
UJ UJ 


z z 

UJ oc 
X 3 


UJ < 

to to 


UJ o 

to II 

Z X 


uj o 

UJ 

2 o 


UJ X _l 

I o < 
1 - UJ z 


I— oc Q 
O UJ <x 
Z X X 
UJ H- UJ 

_i a x 

3 

f- u. o 
3 H- 
a. O 


»-« uj O 


* HI Z * 

* Q * 

* <C J- * 

* UJ 3 * 

.♦IQ* 


*33* 


* * * * 


* X H- * 


* < Ul * 

* <J OC * 


oc oc oc oc 

to to to to 


* < ~ * 


* a: H- * 


3 * O •-* * 


* *-• H< * 

* X to * 

* I- 3 * 


oc>-<ac>- 

10 Q Q to z 


uj • UJ 

to x 

3 H- Z 

to < 


to UJ Q 
to < 


************ 


OrtNrt-JlflHJN 

•i-'J-Nj-vJ-Nl-'J-vtsi- 


•t >t >t ^ 

<j\ ct\ <r» 


CO CO CO CO 

vl- vj- vt “J- 


OOOO 

N N N N 


HI O >t Q 


N<£flNUUWU) 


vf ^ «J- st 


ffllHONlflUI«)< 

lOlO't'f'f'tNt'f 

0'0'tT\ty\0'CTvty\<r» 




* * * * 


* * * * 


a. oc cl a: uj uj 

H Ul H UJ a H 


u.^tu.tMu.Nu.rou.fOu.'j-u.'i-u.zu.z 


Z o z Q < 


UJ UJ 
I- H- 
to >- 

o I 


UJUJUJUJUJUJUJUJUIUJUJUJUJUJLjJUJUJ<C 

1-l-H-H-H-J-l-l-l-l-l-J-J-J-^K-H-a.J- 

to>-to>-to>-to>-to>-io>-to>-to>-to I CL. 


H UJ Q UJ H 

oc X oc 3 ac 


I O 
-* UJ 
X oc 


I O | O | O I o 

O Ul H UJ □ Ul 


OC X oc _l oc 


H UJ Ul CL 


* 2 * 

* to UJ * 

* o * 

* o < * 

* J— a. * 

* Z | * 

* *-« O * 

* oc * 

* to UJ * 

* O N * 

* z * 


to UJ to UJ 
tfl H (O H 
Ul to UJ to 

a M K H 

a o a o 

Q UJ Q UJ 

< oc < oc 

u. u. u. u. 

OOOO 

UJ Ul UJ UJ 
H- H- t- 
>>->->• 
co co aa co 
I I I I 

H H o O 


2 0 U. oc 


UJ to H- to 
3 >- »-* 

_l o CO o 
«=C UJ UJ 
> a h oc 
X 

z NO VO 

3 rH a r-t 

Z 1 - Z H- 

M UJ < UJ 
Z UJ UJ 
*-•2 0 2 
Z <0 


_j to co to co 


* to < * 

* * 

* »— a * 


* o. to * 

* I- 3 * 


* 00 * 


* to < * 


0 3 0 3 


< X < _l 

U oc oc 


U M W N f-t 

# oc oc oc oc 


XXX 

!—►—»— 
to to to 


X X 

H- H- 

to to 


XXX 

a 1 — *— 
-J to to 


*oc*oc*oc*ac*ac*oc*ac*Q*Q*a.* 


* <X to * 

* *1 * 

* J- o * 

* 3 UJ * 

* a. oc * 


* u. UJ * 

* Ul H * 

* Q to * 

* H* * 

* O * 

* UJ UJ * 

* to oc * 


M'tiD'iNcJffcOHNM'tifltfNiflCHOHNM-J 

NOM)'J)'J)<DM)M)NNNSNNNNSN«d(O« 0«000 


o r-l C 4 fO 

<NJfO<riO'OKoO(TNOOoo 


K CO O' O 


<t Ifl H) N H) 9i O 


MrOvtlOvOKCOCTNO 


HI lO Ul 't 


o K Ni> Ul 


N NO N H> 

< «J < <0 


CO to K O' 

OOOO 
Nf «t Nt 
0» O' 0> S' 


^ 

O' ffc Oi O' 


Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

69 









********** 


***************** 


i h in a t— 

in in < Lu o 

, m ui N 2 

I O QC I— OC H Ul 

LU a 3 LU 3 _J 

1 ae Q a. H- < 

< : in h h 

I O h m f- 3 

t- U H d 

1 Z LU U. LU Z Z 

H o O a H M 


3 O 

h- a. Q h- 

3 1- Z Z oe Z 

Q. in h M < lu H 

LU Ul Z O 3 Z h- a 

xx»-i2;a.i-«i-NOtn\oQ 

I- ►“ L— Z LU H M H < 

ui i h w o o 
u. + x o in ii.luu.qc 
O h-MUUiOOocOO 
< OC X DC h- U_ 

L— LU U. t-Q ex t- ex 
ex (X O LU Cl ex LU Z lu CX 

< < XU.<LU2ul2lU 
t- X K— O L— O 51 O ►— 

in i- h Lumo.uja.in 

zj o in lu ex n ex »-* 

UICXZ»-*^-00»— UL— O 
X Z LU >■ L- UI LU UI 3 UI 

h~*- , 3*-<cOinexOC*cxcx 


►- Z Z 

ex J 3 L— »-H 

Ui Z CX 

*- ►- < Q U. 

< ex UJ L— Z O 

J <C Z in Ul 

3 X 

Z in J iu uj t— 

3 O O O 

O 2 2 z z Z 

U UJ LU < < LU 

< Z Z CX £X _l 


o h n to m 


U)'DN«)0'OHNM^iflu}Ki0 0'O 
't't'j'i'tmininininiflininmiflu) 
NNNNNNNNNNNNNNNN 


************* 


h N M >J 
lO vD <D VO 
N N N N 


m'i)N(0(noHNfn^inu)Ni0ff>or<NM'tin'nNt0(noHNtn-tin'i)Ni0ff'o 

'DiD'D'n'ONSNNKNNssKioiotoioioioioioiOioo'ffio'ininjiininffiffio 

NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNrt 


h N M >t ifl 

o o o o o 

in m in m tn 


u> to < o u 

NO Ni) \i) \J) \*) 

< < < < < 

O' O' in O' 




oe UJ O ex 

111 Q J Ul III 

L— a ex 3 
in < cd _j 


in n uj in uj uj iu uj 

in n l— in h- l— ►— i— 

iu jj in lu >■ in >■ in 

ex i: h a a h m h 

Q => CD Q | CD | O 
Q3UJOOUJ»-tUl 
< <OC<3QCXQC 


O t- < 3 

u. Oh- 

02 3 


3 0 0 
*- a. u. z 
3 Z 


ex lu uj Oil ex ex LU 3 

LU Q > h I- LU h Ul U > h- 
QCZ<3IUXLULUexZ<UJ 
Q-^ino.oozoexf-iin(x 


uj in z uj 3 

3 I— ex ex ex 3 O 

in 3 O Z 3 3 3 

►- O in —t 3 Z ex 

3 0L—Z3I—L— 
O 3 3 O Z O 3 

» oe ex z « Z O 


N N N N 
ex ex ex ex 
UJ UJ Ul UJ 


<00<QCQCXLU<00< in 
Q3Qh-inincxZQ3Ql— L- 

oo<w“)->Ocooo<encx 


* < oe * N oe * * 


'n^. Ul so UJ CD OQ 

Xj- ex r-4 ex ex Z Z OQQ 

ex in lu x >- ex 2 z _i o lu •—» <q<x 

2<X OqJ Ul in ►-« 3 3 3 r» s£> <c »— o 

O-SO ZZ Z Z Z 3 O CD > t-* I— 3 3 X 

•^xz ►-* *-< O o O 3 O lu in 230inin 

oe *►-«*»-# * * *ex*oc* *Z*Z*Z*Zi— ex ex * * in O ♦ ex * ex * ex * 


NtlflN0N(flDNQrtNl0*flIl'flN«)0LOMNM>tifl'«K«40>OHNrt* lf| >0 N O rl (S 1-1 U) « In p\ a r -1 oi l<| vj 11 ) |N >q O' Q r -1 f\( IT >J 

«««<0^cOO'0'0'lhO'0'0'0'0'«h000000 00 OOr«HHrtHHHHrtrtNNNNNNNNNNMPlMrt»0(OrtMPlrt l i''titit»f 

rtH(MNNNNNNNNNNN(i(N(«j^N NNNNNNNNNNNNNNNNNNNNNNNlNNN| N JN 


dQUJONinW<OlLON|fl 
-r -r -j in ui ui ui ui ui ui 'U u) 

OOOOOOiOO'OO'OWOi 


Number 42 

70 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 29 







LU 

O 


UJ . oc Z 
H K O' H 
Z U1 Ul K 


3 O 3 < etc a: 

• <0 • Z C- U. Z • LU 1— CO 

a : etc uj *-• UJ O Z 3 

luce: uiZaluzzuui 

Oiu Q H < UJ UJ H < 

oc « aX>IQha>Oj- 
O (c O 3 hU 

I O I CJOOOOCJt-ac 
*-< I UJhhmmOo:mlj 
IIZhlWWWWflJOIlUQ; 
o >- <X<<C<3<Z< 

3 tu tocototocococoO 


Q • ► _J Q -a; 

z ► o to z uj o 

►-* O Z < m Q u. 

Z _J t- O 

o _i • o z x 

O z t- O O . • Q 
ct Z lu Z Z a » ► 0»-t 

0-UIZIU_|Q_0<XZ 


Z N N 
oc O 

O i-i 10 CO 


-I _l • O CO 

\ to UJ z 


<X*-«inininOOzaQQin 

uiocco<<cocoOZQ-_i< 

ZO-<Xo.o.<<U330aD 


N O O CO m 

rt vf U Ul UJ 

V* v» tn v> w 


M O' UJ O 
VO <0 <0 UJ 
UJ so Q Q 
LU U. LU U 
VL U> UV Aft 


N N N 3 3 

a. o. a. CD* O’ 

hi iii iii m hi 


3 ZD 3 ZD -• N N N N 

O’ a a o ►- a. o. a. a. 

LU LU LU UJ Ul LU LU LU LU 


NNNNNNNNNNN 

a.o.o.a.Q.a.o.o.a. 0 . 0 . 

LULULULULULULULUUILULU 


N N N N N N 

a. a. a. a. a. a. 

Ill III III HI III III 


Z 3 0 LU I- 

-J X LU U- Ul O vfl 3 I- 

-IX.-* *-« Z 3 Z CD Z i-« O 3 

O O »-« r-i i-< > lu u. < 3 ac O 

oc cc tic * oc X a. Z a. * tt CO O CJ 


»- 3 0 

►- O Z 3 

to 3 ^ O 

3 0 3 3 3 

in o uj uj z 

< Z Z 3 


X XX -• 

H- O Z O Q Z Z 

*-«inZ*-«tOZO'ZZ33 
X333CCCUOC0033 
ZtotOtoOZOococuiuj 


X X 

Q Q Q 

Z Z o < UJ Z 

3 O oc oc CD 3 

to ex X X O al 


h-»— inxtna_a_zz*»-a.(_>oz»-*Oin ^ 

J2iIfti2i2i2i2^^^i2'^^^^)5^ , ^ r ^ ,s ' h ' NKr ^ NKfs ' <0<0<0t0< ' 3<0cg<<)c0<<)0NC ' cr ' tT ' cr ' (r ' <T ' cr ' a ' cr ' ooooo oc>c>oo»-*«-i^*-«»-« o 

MMrtrtrtiOMrtWMrtMiOrtMrtrtMioiOMiotoiOMMtOMMiOrtMMrtrtiflMcororortMrtiOrtrtit-tit't't-t-t-t-t'tvt't't't'tO 






O h- < OL 
*■* 3 z UJ 
a: o. m j- 

ui z o in 
Z •-* uj *-« 

3 Q O 
Z Q UJ 
LU z oc 


1- > X z 

t— >- A Z < h 

O CO II O z 

< O a: 

oc h- cn h- uj 

►- 3 3 UJ 3 CO 

to a. z > a. Z 

3 Z *-• < ZD 

in »-« z in x z 


uj < »- o 

Z 1 - I t- u> 

3 o in 

Z J— CD UJ 

CD oc u. 

J- H- < O O 

o Z z 

Z LU h- OC 

oc Z O Ul 

A OC UJ z 3 

3 II 3 z O 

< O UJ A O. 3 

3 to oc 11 < 


O o. Z O < 

Ul O h- >- 

10 IO z O 

CO 3 z I- 
UJ O oc 

OC 3 Z 3 UJ 

Q 3 *H 1 — > 

Q uj in ui < 

< h- 3 oc in 


3 Z 1 - 
O uj uj in 

3 OC l-H 
1-300 
UJ < Z Ul 

U > H a 


in oc 1 - z uj 

CO LU 3 LU QC *-< O h- 

LUha.3LUa<h(/l 
ocint-3^uioz*-«'0 
Q*-<3<in»-<»-«Or-l 
Q o o > •-« in uj h 

< UJ O f-H _J 3 OC LU 

oc 3 oc Ul O < < Ul 

Ul LULUQCLUI— I— Vt)3 

OCJ-ZI- oc O O in 

0 3 in UJ ►— I— I— 

h O. LU H Q: o LU ►- 

COL— >(J)OL— h— f— LU»-« 

UI3<LUf-ZLU33X 

ocOinocin»-<oo.inuj 


<t >- H oc 

h tfl h 3 

oc O Z X O. 


a 00 

< 00 

►- < < 

3 vO vO 

O ^ 

oc 3 2 

O in in 


oc oc oc oc CD 
ZZOOH- 
*-»•-« CD CD CO 



^ ^ W * LU lil * * * * * * * 

vDKWJftOHNI'WmMJKiOff.OHNrt^inv) KlOff'OHNM^in'ONlOO'OHNtONjinvONtOff'OHNrt 
OOOOHHHHHriHnHHNNNfJClNN NNNr')M(4lOlOMl4PI(*)l<)'t<tvr>t<t<f>t>t>t>tiOiAiOiO 
MNWlOMrtMMMMiOMrtMtOrtMrtrtrtrt MrOcOrOrOrOtOtOtOrorOtOrOtOcOrOtOcOcOrOrOrOtOrOrOtOrO 

00 u. in 


Q u. o h p) 

to to O' O' O' 

vT vT sT vj- vT 

(ft ft (ft O' O' 


u_ I-* vj- 

O' < < 

V* V* vt 

O' O' O' 


m no n to o' 

< < < < < 

vj- vi- <r »j- <r 

O' <T\ O' Q\ <X\ 


CD O Q LU 

< < < < 

vT vT sj- vj- 

O' O' O' O' 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

71 








o: v lu O 


OC _J Z 


O LU PH PH 


Q UJ >- a z 
Z Z U 111 J 


o z _i z o 


<* < PH 


• 3 
X o 

Ul _J 

Q 3 
Z Ul N 

h- ~ 

uj o x in 
j h u : 
CO z o 

<X ph ph 


Z Q V) 


• 3 

Z O LU 

_J z z 


Ul OC <m o a z 

_l u. Ct _l o 

CO 3 CO O Q. 

< o <z in 

t- Z O LU LU 

—1 •— LU O Ct 

o z < 

Z h- a. < _l O 

_i x o in u. o 

LU O LU 


O ► in Q 


<*•0.0 U. 


Z PH O 


O W I- 


3 Z Z 


Z 3 

LU LU 
Z Z 


_l Ct O < z 


z 

O LU 

z 


X 3 
o o 

Z _i 

z o oc a _i _i 3 

o OC Q. _l CO CO Ul 


—I *“• —I z z 


0-100 


0lU<0O»-<Z(J 


Z-J-irOcoQCNictZttttaNctQQttctX 


ZacOOa.X3a.(dOt-i-zz 


_l0o.uio.i-0 I a. O 


ozioqzo in in- 


a. X X X O 


z o «t z o o 

O O' o. O oc oc 

o. X oc a. h- 


< - 

iL- z z 

Ul ui 


o 3 ra z ra in z *raZ30000CD a C3 in a C 9 in I/I a a 


ft. Z M 
X O pH 
VI O K 


»- z 
rt z ui 
*-h O X 
ac Oh- 


oc U h- h- 


U!Oo.(JZOt— Ql— O 


O CO </></> J O co 


00I-030Q3Z00I- 


O j < in _i i/i 


O Q a: PH 

z 


—itncoa.—itntntnO-io 


Q o. Z a. Z 
-I U oo O co 


OOZOOo. Nlua.NZUUNlua.NO 


Q _i CO Q _| U 


«/> O OQ CD O a 


in o co Q 


m> is <0 o» o 
Is Is N Is <0 


h n m 
<0 <0 


*$• If) Is CO 

oo «0 <0 «0 oo 




C'OrtNMvfui'l)N(0ff>OHNM»tifi'flSe) 

coonono'O'O'O'OnO'O'O'Ooooooooo 

'i<i'i'i<i^<t«i^j'>tiniflininu)inini/>io 

o o o 


ONOHlMCO^lO'nrSlOavOrHCMNvJ- 

OHr4HHfHrtr4r4HHNNNNN 

inioiniflininioioioioioioioininm 


if) U) N <C O' o 


to <i m ui 

M M M tO 
m m in ud 


ONOi<ls<OrOlsNQ 

QOphphC^QolUsO 


Q Is Is O Is co 

CO O O N Is pH 


Nu<orsCT'(s<fs 


pH vO U. 


vj- Q O Ct O 


U. U. if) U- pH 

Is Is If) ts Is CO VO U O SO 00 Q Q 

U. U) O L •! D O rH Q O O U. U. 


Q Q sO O 


<ft]QOM^lON(Off'<ai(JQ 


LUU.OrH(VJt0lf)M>|SC\<C0UU. 

HHNNNNNNNNNNNN 

if>if)if)if)if)if)inif)if)if)if)if)if)Lf) 


Or4tfl»finu)(00\ 

MMtClflMMtOP) 

if)inLnif)inif)if)if) 

C'O'C'C'CiO'ff'Oi 


CO O Q U. O ph N'i-N00<UQLUOr0sf'0 

tC 1C W M >f •! 'f't'f>t'tvf«l>liOU)ll)ifl 

if) if) m m m m ininminininmininininin 

ON (T\ C* C* (T> (Tv O'O'O'O'ONO'OnC'O'OnOnO' 




z ui ui 
ui ro x x 

X pH o o 

o h- t— 


OC m> i- _i 
0 1-00 

in ui in in 
< 3 < < 
co in co co 




a co a z 


. x ui 

x • h- • x • 

LU OC CO h (J 

a ui 3 ph ph 

Z co O a ph a 

ph Z -J X 

3 Z O Z O 

O Z -I h- _l »- 

o 

a: Ul V O A O 


in 3 

Z O 

PH _| 

3 

h- Ul 

X z 


ui ph z in 


v ui ui z u. 

CD ID iftc 
O Z Z 3 Z 
Ul 

Z 


O x _i oc at ui 


h- m < w 


O Q Q Q 


a a a a 


► oo 

*f) co oc Z 
pH oc O ui 
3 O in Z 
in in (<j x 

ct h- Ct 

in ui Q 


a a X 3 ph XX X 

«On»-QOZZCnZQC) NQ 
ONCcinz_l_J_la:PHZZZinz 
acO_l_i333U-JCDlDiUtniD 
Uoia)cOLULULUincoctctZ<a; 
mra»-»-zzzra»-aaXaa 


Q 
• a 

_J O 

j ■) in j in in a. 


Q Z Q Q Z 3 Z 

Z Z a (D Z Z CD O PH _l 

_IOphococOOoc_IcQX<Oco 
cOO-JUlaococa.ZpHZpHrHt- 

»-<cozraaara_ja_iaara 


:c _i Q < 3 

o o oc m O 

cc ac a $* O 


CO 3 pH pH 

in- O pH pH 

« O V. Ct 


Ul 3 M> _I J ph J 

Q O PH 3 3 3 3 


l-l— Q»— »— OH-I-Q 
ininjininainin 


a O )- Q Z 


_l O a) in .1 ph O 


Q O 
_l < 


Q oc O a: O N 3 


<CXa<oc<ct<Xo:oc 


h h () O in 

in oc .j j -» j 


Q in Q in Q Q 
3-13-1 


in in in Q i- Q r 
3 3 3 _i in < in 


_j ct o z ci. z 

3 a z t- Z )- 

Z O CQ oc 3 oc 


U)tfN(OCiOHNrt-lifl>iNiOffiOpHNrt«til)'ONiO(l' 

HHHHHNNNNNNNNNNfOMMMNMMMMM 


OpH(N|f0vJ’lf)'f>lsC0 

'i-'j-vl-vtvj-vfvj-stij- 


a\OpH(Mro<*mvoN<oo\ 

'iminiflinuiiniflinmin 


HNtfl'tlfl'OSlOff'OHM 

'AiO'ftift'ft'ft-ft'ftvASSS 

Nl-'t'l-'fNfNtNfvtltstvtvt 


Is CO < ON 
O o < 


ci o h < ui a) 111 

U)M>O0iO0iOi0>0 


ooNo<:<M<r 


<r cm «x <t 


Q pH N O C) O 


U. N If) 
vJ- 


vO Is < CO O 


QUIU.OHN|i)>tifl 

CO CO CO CO O 


N tO Vi < ID Q 


OHN'tlflNVi< 


OOOOOOOOQQQQQQQQCl 




ViViDiViViNgiOiffiViOiViViViViOiViViOiViOiaiViViViViaiViffiViViViViOi 


Q LL N 

Q Q Ul _ — — _ 

ON O' O' ON ON ON O' 


<0 O Ul O CO VO O' 


<caoQuju.rH0tin 
u.u.u.U.U.U.UlU.U.0 0 0 
'4 - >j-'i-'j-»j-vr»i-»3-stinif)if) 
O'O'O'O'O'O'O'OnO'OnO'On 

(Continued on page 33 ) 


Number 42 

72 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Pacie 31 








CONVERTING BINARY 


TO DECIMAL 


BY DENNIS ALLISON 

H39 Spruce Street 
Atherton, CA 94025 


Dennis R. Allison is an independent consultant and 
part-time lecturer at Stanford University’s Computer 
Systems Laboratory. His research interests include 
programming languages and their relationship to pro¬ 
blem solving and creativity. He is presently President 
and Chairman of the Board of Trustees of the People’s 
Computer Company. He is a member of ACM, SIAM, 
and IEEE and serves as an Associate Technical Editor 
of the IEEE Computer Society’s general membership 
publication, Computer Magazine. 


Every system needs to have some medmnism for output¬ 
ting data in a form easily useable by humans. With our ten- 
finger heritage, the easy-to-generate hex, octal, and binary 
displays are inadequate, particularly for non-specialists. This 
note describes a conversion routine suitable for use with 
microprocessors as it does not use either multiplication or 
division. For a more comprehensive treatment see Knuth’s 
Seminumerical Algorithms (Addison-Weslev, Reading, MA, 
1969). 

There are several slightly different problems which have 
to be solved. For a decimal output to a terminal, we normally 
want a zero-suppressed output to have the number 2 print 
a “2” and not “00002”. On the other hand , if the output is 
to go to a LED display which normally outputs hex, the con¬ 
version must be to packed decimal, not characters, and should 
not be zero suppressed. The idea is pretty much the same for 
each, however. 


The routine depends upon being able to compute both the 
quotient and the remainder after dividing by 10, is the right¬ 
most digit. And n/10 contains all the digits to the right. 
This observation suggests the routine 

prdec ( n ) int n. | 

int q, r; /* locals for quotient and re¬ 
mainder */ 

if (n < 0) | putchar(' — n = —n; 1 

q = n/10; 
r = n % 10; 

if (q ! = 0) prdec(q); /* print digits to the 
left */ 

| putchar(r + ' 0 '); 

written in the programming language C, which performs a 
binary to decimal conversion with zero suppression. The pro¬ 
cedure is recursive, so local variables are allocated on the 
stack. The digits are constructed right to left and printed 
left to right. The subroutine stack is used to reverse the con¬ 
verted number. Signed numbers are converted to unsigned 
numbers following output of a sign. 

If one does not want to suppress zeros, one can add another 
parameter to the call, the number of digits desired. 
If one does that the program becomes 

prdec ( n,dig) int n,dig; { 

int q,r; /*locals for quotient and re¬ 
mainder */ 
if (dig < = 0) return; 
if (n < 0) { putchar(' - '); n = -n; } 
q = n/10; 
r = n % 10; 

prdec(q,dig— 1); /* print digits to left */ 
putchar(r + '0'); 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

73 










If one wants a packed decimal representation for positive 
numbers only, as would be the case for a LED display, the call 
to character output routine, putchar, should be replaced with 
a call to a packing routine which simply masks off the decimal 
digit and shifts it left four bits. One way to do this would 
be to have a global 16-bit variable and use a C routine of 
the form 

pack ( dig ) int dig; { 

packed = (packed < <4)&(dig& 017)); 

Unfortunately both these routines fail for the largest possi¬ 
ble negative number because of the way the PDP-11 handles 
the remaindering process. The division must be unsigned for 
the algorithm to work. Remember that 2’s complement num¬ 
bers have an asymmetric range skewed to the negative side. 
For example, 2’s complement 4-bit numbers represent values 
from -8 to +7. And negating the largest possible negative 
number gives the largest possible negative number. 

If we are going to implement this procedure, we need a way 
to do the division and remaindering operation. Strangely 
enough, we do the division using multiplication by 0.1. The 
fraction 1/10 has a binary representation 

1/10 = 

0.0000110011001100110011001100110011001100 ... 

which may be thought of as a sum of fractions 

1/10 = 1/16 + 1/32 + 1/256 + 1/512 + ... 

The fraction will never represent the correct value. If we 
truncate the representation at any point it will always be too 
small. If alpha is an approximation to 0.1 which is too small 
by 1/w, one can write 

(alpha + 1/w) * u = u/10 

which suggests that 

alpha * u = u/10 - u/w 

Now the error in the representation, 1/w will always be less 
than or equal to the smallest value represented in the fraction 
alpha. The value of the ratio u/w will always be less than or 
equal to one. Thus, we can write a division by ten routine 
which also computes the remainder and uses only shifts and 
adds. Using the C notation of » for right shift one has 

int rem; /* global to catch value of remainder */ 
divlO ( x ) int x; | 
int u,v; 

u=(x» 1) + (x»2) + (x»5) + (x»6) + (x»9) + 
(x» 10) + (x» 13) + (x» 14); 
u = »3; 
v = mull0(u); 

if( (rem = x - v) > = 10) | u++; rem = rem - 10;} 
j return (u); 

This program uses right shifts to implement division so it 
won’t work for negative numbers. The same problem with the 
largest negative number will also appear unless the right shift is 


implemented as a logical right shift rather than an arithmetic 
right shift which sign extends. 

The second to the last line corrects the quotient and 
remainder when the value computed is in error by one. 

One now needs to have a simple multiplication by ten 
routine. This can be done with a few temps and additions. 
In C the routine looks like 

mull0(x) int x; { 
int t; 

x = x + x;t = x + x;t = t + t; 
return (t+x); 


which works by noting that 10*x = 8*x + 2*x and using 
addition to do the multiplication by two. 

Mapping these routines into machine language is left as 
an exercise for tie reader. The only problem is how to repre¬ 
sent local variables in the recursive procedures. For most 
microprocessors local variables may be implemented on the 
subroutine stack. At subroutine entry the stack pointer is 
decremented by the number of bytes needed for local 
variables. Locals are then accessed by indexing from the stack 
pointer. Just prior to subroutine return the stack pointer must 
be incremented to readjust it so the return address is at the 
top of stack. 

And, of course, there are equivalent non-recursive programs 
which use exactly the same ideas but keep their own stacks. 
They require slifjhtly more code and data space but may run 
faster. 


(continued from page 3 1) 


V> O 


U- < • *-H 

t-i Z at X. to 

Z O O < 
o o u. ui on 


ZD LU O O O IT) 

<o:oo rO 

U. r-t rH If) 


Z oc Q X oc 

oc < a. O ZD 

h O 111 3 111 h 


oc < oc cl 
< (X. < ZD 


<J O (J oc 


o h n M 4 ft; h 

* # * * * Hi oc 

* * ♦ * * CO a: 

vO sf> \0 SO sf) Z < 


z 

►— LU < Q 
a o: t- Z 
< U tfi ui 


</) Z L) Q 
*-• O U O 
_l U < Z 


(\|oooo 
K o o o o 


H 4 4 CO o 


o O O \fl 


aa </>(/> cQ (/) (/) 


Z CDXXXXXX<X<<<< 

< ftiauiuiuiiuuiiiijiiii 

OXXXXXXOXOCJUO 


13 

LU M> 


KcOtf. OhNI04iOO)K 
fOtOW44444444 
lOininioioiomiAiomin 


0\OHNrt4ifl'0N<00'Ot4Nl04inDNc0 

4ioiomioininiflinifliO'i)'0'i)'i><D'00)o)<i) 

inioioifliOLOiAinioiflininmioifliflioifliflin 

Q <0 UI LU N N 

u. w a a o q q 


vOQQONOO.—«oo 
o^ajocorooovo 


OOOOONU LU 

o_i<s*«ooif)ao 

OOOvOlUrlUCOlU 


NOUQLlOh(04 

ifliflinifloi'H'O'D'e 

lomiomioioiiiiom 

Os Os Os Os Os Os Os Os O' 


if) 00 cO 

so Sf> 
If) If) lO 

O' O' O' 


N4DCO<UlUN(ONUsO 
KNNhNNNO'OsfflUUI 
Lr>ir)if)mmif>if)if)tf)if)LQtf) 
O' O' O' O' O' O' O' O' O' O' O' 


Number 42 

74 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Page 33 








UCSD PASCAL 

Terminal Parameters 


BY RONALD G. PARSONS 

9001 Laurel Grove Dr. 
Austin, TX 78758 


The PASCAL system from the University of California at 
San Diego has a very useful system generation procedure by 
wliich the physical parameters of the user’s screen and termi¬ 
nal may be defined to the system. These parameters include 
the keyboard cursor keys, the screen cursor movement char¬ 
acters, and such entities as the characters to clear the screen 
and erase to the end of the line. These parameters are defined 
for the system by using a supplied program SETUP and are 
stored on a file named SYSTEM.MISCINFO. 

In order to write programs which are as independent as 
possible of the user’s screen and keyboard configuration, 
these parameters must be known to the program. For example, 
if you wish to write a program which must be able to move 
the cursor around on the screen and always stay inside the 
user’s screen whether it is 64 X 16 or 80 X 24, the cursor 
controls and screen size must be known. The record definition 
and initialization procedure below may be used to make these 
pa rameters known to a user-written program. The main pro¬ 
cedure illustrates the use of the parameters in the record. 
There is only one oddly defined parameter—“verticalm- 
delay”— which tells the number of nulls to be sent after a 
vertical cursor move. This variable is defined here as character, 
but should be used as an integer. The statement 

intverticalmdelay : = ord(verticalmdelay) ; 

will transform the quantity to an integer. 

I hope the way UCSD PASCAL lets the user define his 
system parameters to the operating system will be widely 
copied. 1 wish UCSD had been consistent in their use of these 
pan meters in setting the length of their prompt lines which 
often overflow a 64 character screen line. 


Program testmiscinfo; 


SYSTEM.MISCINFO parameter record definition 
Author: Ronald 0. Parsons 
Date: August 21, 1979 

Defines terminal and screen parameters from the file 
produced by SETUP for UCSD Pascal Version 1.5. 


The following variables are associated with 
the SETUP defined parameter. 

The full name of these variables is minfobuffer.xxxxx 
e.g., 

minfobuffer.screenhelght 
or 

with minfobuffer do ... screenhelght ... end; 


The following variables are type Boolean. 


hasclock 
has8510A 
haslowercase 
hasrandom 
hasslow 
student 
premcup 
premcrlght 
preereol 
preereos 
premchome 
predcharacter 
preerscreen 
preerline 
prekmcright 
prekmcleft 
prekmcup 
prekmcdown 
prenonprintchar 
prekeystop 
prekeybreak 
prekeyflush 
prekeyendfile 
preedescapekey 
prekeydline 
prekeydcharacter 
preedacceptkey 


HAS CLOCK 
HAS 8501A 
HAS LOWER CASE 
HAS RANDOM CURSOR ADDRESSING 
HAS SLOW TERMINAL 
STUDENT 

PREFIX [MOVE CURSOR UP] 

PREFIX [MOVE CURSOR RIGHT] 

PREFIX [ERASE TO END OF LINE] 

PREFIX [ERASE TO END OF SCREEN] 
PREFIX [MOVE CURSOR HOME] 

PREFIX [DELETE CHARACTER] 

PREFIX [ERASE SCREEN] 

PREFIX [ERASE LINE] 

PREFIX [KEY FOR MOVING CURSOR RIGHT] 
PREFIX [KEY FOR MOVING CURSOR LEFT] 
PREFIX [KEY FOR MOVING CURSOR UP] 
PREFIX [KEY FOR MOVING CURSOR DOWN] 
PREFIX [NON-PRINTING CHARACTER] 
PREFIX [KEY FOR STOP] 

PREFIX [KEY FOR BREAK] 

PREFIX [KEY FOR FLUSH] 

PREFIX [KEY TO END FILE] 

PREFIX [EDITOR ’ESCAPE’ KEY] 

PREFIX [KEY TO DELETE LINE] 

PREFIX [KEY TO DELETE CHARACTER] 
PREFIX [EDITOR 'ACCEPT* KEY] 


- The following variables are type integer. 

screenhelght SCREEN HEIGHT 

screenwidth SCREEN WIDTH 


) 

) 

) 

> 

> 

) 

> 

> 

> 

) 

> 

) 

> 

> 

) 

> 

> 

> 

> 

> 

) 

) 

) 

) 

) 

> 

> 

> 

) 

) 

> 

> 

) 

> 

) 

> 

) 

> 

> 

> 

) 

) 

> 

) 

) 


Page 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

75 








(• 


variables are type char. 

*) 

(• 

leadintoscreen 

LEAD-IN TO SCREEN 

•) 

(* 

movecursorhome 

MOVE CURSOR HOME 

*) 

(• 

eraseeos 

ERASE TO END OF SCREEN 

*) 

(* 

eraseeol 

ERASE TO END OF LINE 

•) 

(• 

movecright 

MOVE CURSOR RIGHT 

•> 

(* 

movecup 

MOVE CURSOR UP 

•> 

(* 

backspace 

BACKSPACE 

•) 

c* 

verticalmdelay 

VERTICAL MOVE DELAY 

•> 

(* 

eraseline 

ERASE LINE 

•) 

(• 

erasescreen 

ERASE SCREEN 

•) 

(• 

keytomcup 

KEY TO MOVE CURSOR UP 

*) 

(* 

keytomcdown 

KEY TO MOVE CURSOR DOWN 

•) 

(• 

keytome left 

KEY TO MOVE CURSOR LEFT 

•) 

(* 

keytomcright 

KEY TO MOVE CURSOR RIGHT 

*) 

(* 

keytoendfile 

KEY TO END FILE 

•) 

(* 

keyforflush 

KEY FOR FLUSH 

•) 

(• 

keyforbreak 

KEY FOR BREAK 

•) 

(* 

keyforstop 

KEY FOR STOP 

*) 

(• 

keytodcharacter 

KEY TO DELETE CHARACTER 

*) 

(* 

nonprlntchar 

NON-PRINTING CHARACTER 

*) 

(• 

keytodline 

KEY TO DELETE LINE 

*) 

(* 

editorescapekey 

EDITOR 'ESCAPE' KEY 

•> 

(• 

leadincharacter 

LEAD-IN CHARACTER FROM KEYBOARD 

•) 

(• 

(* 

editoracceptkey 

EDITOR 'ACCEPT' KEY 

•) 

*) 


( 


) 


type 

miscinforec ■ packed record 

dummyl : packed array [0..28] of integer; 

dummy2.dummy3,student,hasslow.hasrandom,haslowercase, 

has8510A,ha8clock : Boolean; 

dummy: integer; 

erasescreen,era8eline.verticalmdelay.backspace, 

movecup.movecright.eraseeol.eraseeos.movecursorhome, 
leadintoscreen : char; 

preerline.preerscreen.predcharacter.premchome, 

preereos.preereol.premcrlght,premcup : Boolean; 
screenwidth.screenhelght : integer; 
editoracceptkey.leadincharacter,editorescapekey, 
keytodline,nonprintchar.keytodcheracter, 
keyforstop.keyforbreak.keyforflush,keytoendfile, 
keytomcright.keytomcleft.keytomcdown.keytomcup : char; 
dummy5 : integer; 

dummy6.dummy7.preedacceptkey.prekeydcharacter, 
prekeydline,preedescapekey.prekeyendfile, 
prekeyflush,prekeybreak,prekeystop.prenonprintchar, 
prekmcdown.prekmcup.prekmcleft.prekmcrlght : Boolean; 
dummy8 : packed array [ | *8..95] of integer; 
end; 


var 

mlnfobuffer : miscinforec; 
procedure minfoinit; (* Initialize •) 
var 

minfoflle : file of miscinforec; 
begin 

reset (minfoflle,'•SYSTEM.MISCINFO'); 
get (minfoflle); 
mlnfobuffer minfoflle ; 
close (minfoflle); 
end; 


begin 

minfoinit; 

with mlnfobuffer do 

begin 

writeln(* Lead-in to screen - '.ord(leadintoscreen)); 
writeln(* Cursor home ■ ',ord(movecursorhome)); 
vrriteln('Erase to end-of-screen ■ ' .ord(eraseeos)); 
writeln('Erase to end-of-llne ■ '.ord(eraseeol)); 
wrlteln('Move cursor right ■ ',ord(movecright)); 
writeln('Move cursor up ■ '.ord(movecup)); 
writeln('Key to end file ■ '.ord(keytoendfile)); 
writeln('Key to move cursor up ■ '.ord(keytomcup)); 
writeCHas clock - '); 

if hasclock then writeln('T') else writeln('F'); 
write('Has 8510A - '); 

if has8510A then writeln('T') else writeln('F'); 
writeCHas lowercase * '); 

if haslowercase then wrlteln('T') else writeln('P'); 
writeCHas random • '); 

if hasrandom then writeln('T') else wrlteln('F'); 
writeCHas slow - '); 

if hasslow then writeln('T') else writeln('F'); 
wrlte('Student * '); 

if student then writeln('T') else writeln('F'); 
write('PRE [key to move cursor up] ■ '); 
if prekmcup then writeln('T') else writeln('F'); 
writeln; 

writeIn(screenhelght,» ',screenwldth); 

gotoxy((screenwidth div 2),(screenheight div 2)); 

(• go to center of screen *) 

write('Input "return" to clear screen'); 

readln; 

write(erasescreen); 
end; 
end. 




Number 42 

76 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E Menlo Park, CA 94025 


Page 35 







PASTIMES ' 
AND 

PLEASURES 

BY CHARLES WETHERELL 



© 1979, Charles Wetherell 
Four Famous Programs 

Programs are not always interesting because of their output; 
sometimes the program itself is the object of interest. This 
month I am going to describe four famous programs which 
fall into this class. Even if you don’t actually write versions 
for your own computer, thinking through each program will 
surely reward you with deeper understanding of your 
computer. 

I Got Plenty of Nothin’ 

The first problem is to clear memory to zero. Easy enough, 
you say—just hit the CLEAR button. But the: rules are a little 
more complicated. All of writable memory must be set to zero 
at program completion; as an added fillip, all registers should 
be zero as well. The program must execute normally without 
using any input/output device and without any operator inter¬ 
vention. If possible, the program should halt normally. As an 
example, I know of one computer which used a store double 
word zero instruction to wipe out the last two words of a 
loop through memory. An even harder problem is to store a 
preselected bit pattern throughout memory. You may find 
this program is not possible for some bit patterns. 

Stamina 

Now consider the problem of writing the longest running 
program you can. The same rules apply—no I/O, no operator 
intervention, normal program execution. How about infinite 
loops? Well, my definition of a loop may be a little different 
than yours. I will say the program loops when the same main 
memory configuration occurs for the second time. The repeti¬ 
tion must be exact, bit by bit. To make things simple, you 


may specify any starting memory configuration you like. Your 
program must reside in main memory and count as part of the 
memory pattern. Strangely enough, almost every computer has 
the same solution for this problem; I will suggest it at the end 
of the column. 

Introspection 

For the third problem, consider a program which can 
describe itself. Specifically, the introspective program must 
print out an exact listing of its source coding. You are not 
allowed to use any tricks. For example, you may not reread 
the source input. Some compilers and interpreters leave copies 
of source lying around in memory. You may not reach in and 
print such a source. The only resource you are allowed is the 
program itself. A memory dump does not constitute a source 
listing. 

The introspective program is particularly interesting 
because it is always possible. In any language—FORTRAN, 
BASIC, PASCAL, assembly—as long as the language is 
“sufficiently” powerful—the program will exist. Every normal 
programming language is powerful enough; see the column on 
Ackermann’s Function (DDJ # 37) to find out how powerful 
is “powerful.” The existence is a consequence of the 
Recursion Theorem. Fortunately, you can solve this problem 
without using any mathematics. Hint: the solution hinges on 
the proper use of quotation. 

A Pox On You 

The last program is the computer virus. Before you do any 
work on viruses, you better be sure that you either have a 
“clean room” or can stand to take the consequences. If you 
are certain, I’ll go on. 


Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

77 



The virus is a program which implants itself into another 
program, subverts the host’s operations, creates multiple 
copies of itself, and then implants the copies into other 
victim programs. Obviously, once a virus gets loose in a 
system, the system will soon spend all its time breeding more 
viruses. If the fever attacks some common utility like the 
compiler'or file manager, the plague may kill the system 
immediately. Eradication of a successful virus could be very 
difficult. 

I know of one rumored virus. Back in the early days of 
computing, the 7094 operating system stored all object 
programs waiting to be punched onto a single tape. The virus 
would read the last object file off the tape, modify it to 
include a copy of the virus, and then write the object back 
onto the tape. When the object, which would be a single 
routine from some other program, was loaded and executed, 
the virus would propagate again. Indeed, since object decks 
could be physically loaded with several programs, the virus 
might be propagated by the unsuspecting owner of the sub¬ 
routine-a sort of Typhoid Mary. Security features on most 
modern systems would defeat this ploy, but it is thinking 
about such pathologies that makes designers improve security. 
I might add that releasing a virus would certainly be unethical, 
if not criminal. 

One other rumored virus caused a genetic defect in its 
host. The creator of a timesharing system also had a hand in 
writing the compiler for the language in which the entire 
system was written. He modified the compiler so that when¬ 
ever the SIGN-ON program was compiled, the compiled 
SIGN-ON procedure would always recognize his name. This 
way he could run on any version of the system anywhere. 
Not only that, but if this defect was removed from the 
compiler source code, the compiler automatically reinserted 
the flaw in the compiler object modules when the old (flawed) 
compiler—the only one available, of course—was used to 
recompile the new (clean?!) compiler sources. I heard this 
tale far removed from the perpetrator and I suspect it to be 
apocryphal. But have you checked you compiler lately? 



Hint 

The longest running program generally treats all of memory 
as a giant binary counter and simply increments constantly by 
1. When the counter overflows, all memory configurations 
(almost) will have been counted off. A sophisticated version 
will also move the program around in memory to get more 
configurations (only one move is necessary—why?). Don’t try 
this program and expect to see it finish; on a computer with 
n bits of memory, the program will run for at least 2 n or so 
cycles.. 



Number 42 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 

78 


Page 37 



BY GRIFFITH HAMLIN, JR. AND THOMAS CROCKETT 

Los Alamos Scientific Laboratory 
Los Alamos, New Mexico 87544 

ABSTRACT 

GRAF80 is a small scale graphics system designed to 
demonstrate some of the capabilities offered by micro¬ 
processor-assisted graphics. As such, it employ s both hardware 
and software techniques. The system implements in a micro¬ 
processor a ubset of the features of the S1GGRAPH-ACM 
CORE (1) graphics package, including picture segmentation 
and a subset of the output primitives and primitive attributes. 

INTRODUCTION 

GRAF80 is a graphics system that uses inexpensive micro¬ 
processors to enhance the capabilities of a Tektronix storage 
tube display. For a fraction of the cost of a Tektronix 4014, 
several features can be added that considerably increase its 
usefulness. These features include a selective erase using the 
segmented display file concept of the SIGGRAPH CORE 
graphics package, and the ability to display a limited number 
of vectors in refresh mode using a high-bandwidth hardware 
interface between a microprocessor and the Tektronix 4014. 

HARDWARE 

The hardware consists of an IMSAI 8080 microproces¬ 
sor, which forms the heart of the system; a Tektronix 4014 
direct-view storage tube terminal, which is used as the 

© 1978, SIGGRAPH-ACM. Reprinted by permission. 


graphical output device; and a host computer. The IMSAI 
8080 acts as a dedicated device driver, and has software that 
supports picture refreshing and segmentation. Any one of 
several other available 8-bit microprocessors could be used as 
well. Several possibilities exist for interconnecting the micro¬ 
processor, Tektronix terminal, and host computer. Figure 1 
shows one possibility that uses commonly available 
equipment. 

The Tektronix 4041 has a built-in serial interface that will 
support serial communications up to 9600 baud with the 
microprocessor. This rate should be sufficient to provide 
interactive access to images stored in the microprocessor’s 
segmented display file. It is not sufficient to refresh images 
using the write-through mode of the 4014. To remedy this, 
we have constructed a simple parallel interface to the 4014 
and connected it as shown in Figure 2. This interface consists 
of only nine 16-pin integrated circuits mounted and wire- 
wrapped on a blank Tektronix plug-in card. This provides 
one-way byte parallel transmission at the Tektronix 4014 
MINIBUS® speed (9 jus/byte) from the microprocessor to 
the Tektronix 4014. Communication from the Tektronix 4014 
uses the normal serial interface in the 4014 and is connected 
directly to the host computer. 

Any machine capable of producing GRAF80 commands 
may be the host computer. This could be the same or another 
microprocessor, a minicomputer, or a large mainframe. In our 
case a PRIME-300 minicomputer is used. 


Pag/3 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

79 





SOFTWARE 


Software for GRAF80 consists of two main components, 
one on each computer. The microprocessor component 
receives graphic commands, stores them in a segmented data 
structure, and interprets them to produce either a refreshed 
or a stored image on the 4014. The host computer software 
consists of a package of Fortran subroutines that issue the 
commands. 

Microprocessor Software 

Software for the microprocessor is written in PL/M, a high- 
level language designed for microprocessors (2). The software 
is designed to intercept and interpret a set of primitive 
graphical commands. It requires 4000 bytes of microprocessor 
memory plus buffers for the segmented display data structure 
generated from the commands. These commands consist of 
move and draw graphic-output primitives, along with com¬ 
mands to OPEN, CLOSE, DISPLAY, and ERASE individual 
image segments. The complete list is given in Appendix A. 
They were selected from the SIGGRAPH-ACM CORE 
graphics package. 

The main program consists of a loop that continuously 
monitors an I/O subtask and a graphics subtask. (The term 
“task” is used to indicate that these two processes could be 
executed in parallel if properly synchronized, although they 
have been implemented sequentially here. The net effect 
would be similar in either case.) When the main loop 
determines that a particular task has work to be done, it 
transfers control to that task, which runs to completion and 
returns to the main loop. 

Input to the microprocessor is interrupt driven. A simple 
interrupt routine receives a character and stores it in a circular 
buffer. The job of the I/O task is to empty the buffer and 
evaluate its contents. In order to allow ordinary (nongraphical 
or graphical) use of the terminal, a “transparent” mode is 
defined. Transparent mode defaults until a special graphics 
notify character (ASCII ETB) is received. The I/O task 
examines each character and sends it directly to the terminal 
until an ETB is encountered, at which time further data is 
considered to be graphical. The graphical input is filtered 
according to a predefined transmission format (Appendix B) 
and stored as a picture segment. When the input buffer is 
emptied, control returns to the main loop. 

The graphics task serves as an interpreter, converting the 
commands stored by the I/O task into device-dependent 
instructions which are sent to the 4014 to generate the 
picture. By redefining this task, different devices may be 
handled within the framework of a single system. Each call to 
this device driver interprets a single picture segment; repeated 
calls with the same segment allow the refresh capability. The 
graphics task returns to the main loop after once interpreting 
each segment that needs to be displayed. 

Picture segmentation is handled at a level above the device 
driver. A number of graphics commands are used for 
manipulating segments. The I/O task intercepts these and 
takes appropriate action, such as setting flags, allocating 
storage, etc. The actual picture commands (or “primitives”) 
are stored in the microprocessor’s free memory as one or more 
64 -byte blocks, linked together by a forward chain, one chain 
per segment. A set of memory management routines is 


available to manipulate this data structure. Memory allocation 
is automatic and dynamic, implying that each segment receives 
only as much memory as it requires. The total amount of 
information that may be displayed simultaneously is thus 
limited by the amount of memory available to the micro¬ 
processor. Although the current implementation uses only 
real memory, this need not be the case; nonrefreshed segments 
could use an auxiliary disk, but system performance would be 
somewhat degraded. Currently up to 16 segments may be 
defined. 

Commands for manipulating segments are listed below. 


OPEN(N,R) Opens segment N. All subsequent graphic 
primitives become part of the segment 
until a matching CLOSE is encountered. 
R = refresh status; 0 = no refresh; 1 = 
refresh. 


CLOSE(N) 

DISPLAY (N) 
ERASE(N) 

DELETE(N) 


Closes segment N. No further information 
may be added to this segment. 

Causes segment N to be displayed. 

Removes segment N from the display, 
but the segment may be redisplayed later. 

Deletes segment from microprocessor 
memory. 


Open segments may not be nested or overlapping; no more 
than one segment may be open at any time. No portion of a 
segment is visible until an explicit DISPLAY command is 
given, and a currently open segment cannot be displayed. This 
differs from the SIGGRAPH-ACM CORE system which 
specifies that portions of the open segment become 
immediately visible as they are defined. Due to the existence 
of both stored and refreshed segments in our implementation, 
we departed from the SIGGRAPH CORE here in order to 
considerably simplify the microprocessor software. 

Erasing a segment merely removes it from the display; it 
remains available in the microprocessor memory for further 
use. A DELETE command destroys the segment entirely. 

Refreshing, as pointed out, is accomplished by the graphics 
task; successive iterations of the main program loop refresh 
the segment. Since the I/O task usually is not busy, the 
graphics task becomes the limiting factor in providing flicker - 
free refresh. Within that task two considerations limit the 
refresh capacity: 


1. the rate at which graphic commands can be interpreted 
into Tektronix code by the microprocessor, 

2. the drawing speed of the Tektronix 4014 (about 190 qs/in. 
which is rather slow for refresh purposes). 

I/O time is negligible because of the parallel interface. 
Currently the flicker-free refresh capacity is approximately 
75 characters or 65 inches of 2-inch vectors (including both 
dark and written vectors). This is about half the capacity of 
the Tektronix 4014 and is limited in our current implementa¬ 
tion by the microprocessor software. Different software, 
discussed in the last section, should remedy this situation. 


Number 42 

80 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 



CONCLUSIONS 



Serial 9600- Serial Line, 

baud line Data rate 


usually determined 
by host computer. 

Fig. 1. Basic hardware configuration. 



Fig. 2. GRAF80 hardware configuration. 


Nonrefresh segments differ in that they are drawn only 
once, and not on each successive loop iteration. Normally 
such segments will be drawn in storage mode, but this does 
not have to be true. The primitive attribute REFRESH 
determines the mode the Tektronix 4014 uses when generating 
characters and vectors; therefore it is possible to draw non- 
refreshed information that immediately disappears and to 
draw storage-mode information that is continually refreshed 
(not recommended). The general assumption, however, is that 
refreshed segments will contain refresh commands and non- 
refresh segments will contain storage commands. 

Selective erase is implemented somewhat differently for 
each type of segment. Refreshed segments merely have their 
display flag turned off. Nonrefresh (storage) segments that are 
erased cause the entire display to be erased, and the display 
Hag for that segment is turned off; all other segments are 
f lagged as not having been drawn. The result is that everything 
but the erased segment is redrawn on the next pass of the 
main loop. The redraw time is very short; the only objection 
being the screen erase flash that precedes it. A typical mesh 
plot containing about 1500 14-inch vectors takes about one 
second to redraw. 

Host Software 

A package of Fortran interface subroutines on our PRIME- 
300 minicomputer allows a user’s application program to 
generate commands for the GRAF80 system. Access is allowed 
to each segment-level and primitive-level command. The sub¬ 
routines generate the proper transmission formats, perform 
data conversions where necessary, and send GRAF80 
commands out the communications line to the microproces¬ 
sor. All coordinates used at this level are integers, which run 
from 0-4095. This corresponds directly to Tektronix 4014 
enhanced graphics screen coordinates, although any arbitrary 
units could have been chosen. Appendix C contiiins documen¬ 
tation of these routines. 


From the host computer’s viewpoint the system appears as 
a virtual device, with built-in functions for picture segmenta¬ 
tion and refreshing. As such, it would be most useful when 
interfaced to a higher-level graphics system. This higher-level 
system could be an existing graphics package, modified to 
accept GRAF80 as another device type and to include segment 
manipulation features, or it could be a new system built on 
top of GRAF80. In the latter case, an implementation of the 
SIGGRAPH-ACM CORE system would be facilitated since 
GRAF80 has several of the CORE functions already available. 

Our 8080 microprocessor is only lightly loaded with the 
current GRAF80 software (except when refreshing). Thus we 
believe that much of the CORE system could be handled by 
the microprocessor with additional software. Currently we 
have designed, but not yet implemented on our microproces¬ 
sor, the image transformation features of the CORE system 
and most of the input functions. We chose these functions for 
microprocessor implementation since they can provide fast 
interactive feedback to the user when placed on a processor 
with a high-speed connection to the display device. Also, they 
involve only fixed point coordinates. Today’s microprocessors 
handle floating point computations only slowly in software. 
We have left the transformations from floating point (world 
coordinates) to fixed point (normalized device coordinates) 
to our minicomputer which has floating point instructions. 

As mentioned above, the limiting refreshing rate for 
GRAF80 could be improved through revision of the data 
structures. The graphics task could be modified to store 
Tektronix 4014 code in a separate buffer, rather than display 
it directly. A third refresh task would then display this buffer, 
with no interpretive overhead. A small test program on our 
microprocessor that used this technique was able to refresh 
approximately 140 inches of vectors, about twice as much as 
GRAF80 can currently refresh. However, our experience 
so far has been that the segmenting features (which provide 
selective erase) are more valuable for most users than the 
refresh capability. 

The handful of users with engineering applications who 
have been exposed to GRAF80 have generally been quite 
pleased with its capabilities. This is in part due to their 
previous use of an overloaded mainframe (a not uncommon 
occurrence) with a slow (300 to 2400 baud) data rate line to 
their terminal. These conditions favor our use of local 
intelligence and sending only changes in images instead of 
sending the entire image each time a small change is made. 

REFERENCES 

1. Computer Graphics (11,3) Fall 1977. 

2. A Guide to PL/M Programming, Intel Corp., Santa Clara, 

California, 1973. 



Page 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 
81 





AN ADDITION TO 8080 PILOT 

I have added a “pause” command to my implementation 
of the pilot interpreter (see DDJ #13 and #14). The com¬ 
mand “PAUSE:” delays approximately 1 second before the 
program execution continues. “PAUSE:N” delays N seconds, 
and N may be a number or numeric variable (similar to the 
INMAX: command. 

What makes the command useful is that the delay is inter¬ 
rupted by the pressing of any key and the program then 
continues with the Y/N switch set for “N” and a new variable 
“[” (shift-K) set to the number of seconds that expired before 
the key was pressed. If the delay is not interrupted however, 
the Y/N switch is set to “Y”. 

Sincerely, 920 N. Washington St. 

Robert Wilcox Owosso, MI 48867 

AN EXAMPLE WILL SHOW HOW THE COMMAND CAN BE USED: 

R! EXAMPLE OF A PILOT PROGRAM USING THE ’PAUSE:' COMMAND 

♦BEGIN 

T: WHAT IS YOUR NAME? 

T:YOU HAVE 5 SECONDS TO ANSWER. 

PAUSE: 5 

JY:*T00SL0W 

A:*N 

T:YOU ANSWERED "SN" AFTER A #C SECOND DELAY. 

J:*A$K 

♦TOO SLOW 

T:YOUR 5 SECONDS ARE UP! 

♦ASK T:WANT TO TRY AGAIN? 

A: 

M:Y 

JY:BEGIN 

E: 


CALL NMCTL 

CPI CB 

JZ PZl 

ANA A 

JNZ DELAY 

PZl: M VI E# 1 

DELAY! XRA A 

STA YNSW ;SET FOR 'N'-NOT TIMED OUT 

MOV D#A 

MOV A# E 

ADD A 

MOV E# A 

DELA1 ! LXI 3,2 

DELA2t DCR C 

JNZ DEL A 2' 

DCR B 

JNZ DEL AS: 

INR D 

CALL C0NSC.K ; SEE IF A KEY WAS PRESSED 

JNZ STOP 

DCR E 

JNZ DELA1 

ORA H 

STA YNSW ; 'Y'-TIMED OUT 

RET 

# 

;SET VARIABLE 'C' FOR NUMBER OF SECONDS BEFORE 
;A KEY WAS PRESSED. 

; 


STOP: 

MOV 

RAR 

A# D 


MQV 

D# A 

LDVAR: 

MVI 

B# ’ C * 


CALL 

VARMCH 


INX 

H 


MOV 

RET 

M# D 


; 

1CHECK FOR A KEY PRESSED 
5 

;INSERT HERE A ROUTINE WHICH TESTS TO SEE IF A KEY WAS 
5PRESSED. IT SHOULD RETURN WITH A 0 IN THE ACCUMULATOR 
UF NO KEY WAS PRESSED# OR A 1 IF A KEY WAS PRESSED.. 
;ALS0 THE ZERO FLAG SHOULD BE TESTED. 

IFOR EXAMPLE! 


THE ROUTINE TO BE ADDED TO PILOT IN ORDER TO 
IMPLEMENT THE PAUSE! COMMAND FOLLOWS# ALONG WITH THE 
MODIFICATIONS MADE TO THE "LETTER" AND "INITV" 

ROUTINES THAT ARE NECESSARY IN ORDER TO ADD THE "C" 
VARIABLE. 

ALSO# THE COMMAND MUST BE ADDED TO "CTLST": 

DB 'PAUSE '# 0DH 

DW PAUSE 

AND THE NVAR STORAGE AREA MUST BE CHANGED TO: 

NVAR: DS 55 

I HOPE THAT THIS ADDITION TO PILOT WILL BE USEFUL 
AND I WOULD BE GLAD TO HEAR FROM ANYONE USING IT. 


CONSCK: 

IN 

PORT ; CHECK STATUS PORT 


AN I 

l ;mask status bit 


RET 


# 

LETTER 

TESTS 

WHETHER CHAR IS A-Z OR C 

LETTER: 

MOV 

A# M 


MOV 

B# M 


CPI 

•A* 


JM 

NOTL 


CPI 

•Z’*2 


JP 

NOTL 


XRA 

A 


RET 


NOTL: 

ORA 

RET 

H 


; 


;****PAUS E OPERATION ROUTINE**** 

# 

.’PAUSE OPERATION - ’PAUSE:N’ DELAYS N SEC. 

•IF ANY KEY IS PRESSED BEFORE THE DELAY TIME 
JHAS EXPIRED. THE Y/N SWITCH IS SET TO 'N ' AND 
ITHE VARIABLE ’C’ (SHIFT-K) IS SET TO THE 
INUMBER OF SECONDS USED UP AND THE DELAY IS ENDED. 

! 

UF THE DELAY EXPIRES BEFORE A KEY IS PRESSED. 

JTHE Y/N SWITCH IS SET TO *Y'. AND ’t • IS LEFT - a. 


PAUSE: MVI D. 0 

CALL LDVAR J SET VARIABLE ’t’ TO 0 


# 

; INITIALIZE NUMERIC VARIABLES A-Z AND C TO ZERO. 

i 

INITV: LXI H# N VAR 



Number 42 

82 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 







A BUG IN SAM76 s CP/M 


CORRECTION 


Dear Suzanne: 

Several months ago I submitted a text written in the 
SAM 76 language to Claude Kagen at SAM76 inc. It emulated 
the integer multiplication function available in the language 
but did floating point multiplication. 

Liter while attempting to impress a friend a bug in the 
text became evident. The text failed in certiiin cases when 
the number base of the interpreter was larger than ten. 

Not realizing it might be used by SAM76 inc. I did not 
bother to inform them of the problem. 

A while ago I received the latest version of SAM76 which 
is configured for CP/M. Included on the diskette were several 
files with example texts in them. One of the files is the float¬ 
ing point multiplication text that is in error. 

I would be very pleased if you would publish a correction 
to this Text as it has been distributed for several months in 
this form. 

Thanks, 92 Granville Cres. 

C.R. Jamieson Sherwood Park 

Alberta, Canada 

This is the original Text— 

< mult > 

Zdtrnl fZtsfC13//' 

ZdtFn2FZrsFC23//' 

8ptrnlr./8ptrn2r./' 

Xdt m3 f 0123456789ABCDEF/' , 

Xdt f n3 fX fdc f n3 fX anb///' 

XdtFn4F%muF%rsFZnl//FXrsFXn2 //F!XttfC33////' 

ZdtFn5F%rsFXn4///' 

Xdt f n5 fX hc fZ fts f n5 fX n3////' 
XdtFn3FXadFXhcFXfeFnl//FXhCFXfeFn2////' 

Xdt f n4 f Xis fX n5/F Xn3/ ? !Xn4// f !X psf-X n3 /f0fX n4/////' 
XfdcFn4FXsUF Xn5/F Xn3///.Xfe f n4/' 
XetFnlFn2Fn3Fn4Fn5/ 

Correct version — 

< MUILT > 

XdtFlFXrsFC13//XdtF2FXrsFC23//' 

8 P t F 1 F ./*PtF2F ./' 

Xdt f 3 f 0123456789ABCDEF/' 

ZdtF 3FZfdCF3FXanb///' 

XdtF 4 fXifiufXts f X1//f XtsfX2// f !Xrr f [33////' 

Xdt F 5 F Xrs F Z4///Zdt f 6 fX anb//Zcnb f10/' 

Xdt f 5 f Xhc f Xfts f 5 f X3////' 

Xfdc f 4 f Xsu f Xhc f X4//f X5///' 

XdtF3FXsdFXhCFXfeF1 //f Xhc f Xfe f2////' 
XdtF4FXidFX5/FX3/F!X4 //f!Xpsf-X3/f0fX4/////' 

Xfdc f4fXsufX5/f X3/// . Xfe f 4/Xcnb f X6//' 
XetFlF2F3F4F5F6/ 

Examples of use 

XhULT f 5 .f -6 . /=-30 . 

XMULTf.007f7./=.049 
XMULTFStrind -.007r7./=Strind - 
XMULTf 

123456789.123456789f987654321.987654321/= 
121932631356500531.347203169112635269 

Xdt f SQRf!XMULT f * f *///= 

Xpt f !5QR f #/= 

ZSQR f 2453.567/=6019991.023489 
Xcnb»16/= 

XSQR »2453.567/=5278B70.A9CF71 



Dear DDJ: 

Jim Warner of the University of California, Santa Cruz 
was kind enough to inform me of an error in the UCSD 
Pascal to CP/M transfer program which was published in DDJ 
#37. The error occurs infrequently when a DLE-space code 
crosses a 512 byte block boundary. 

The enclosed partial listing replaces the original code from 
30F hex to 3AD hex (with 16 bytes left over). 

Sincerely, 9001 Laurel Grove Dr. 

Ronald G. Parsons Austin, TX 78758 


This was rewritten by J. Warner, UC Santa Cruz. 
The GETBYT routine is a new single place to get 
characters from the Pascal read buffer. 


030F - 

RB 

EQU 

$ 

030F 3AC704 


LDA 

TXTFL0 

0312 PE02 


CPI 

2 

0314 C25103 


JNZ 

N0T$TXT 

0317 3ACB04 

RBCKLP 

LDA 

NLP 

031A B7 


ORA 

A 

031B CA2503 


JZ 

RBCKTB 

031E AF 


XRA 

A 

031P 32CB04 


STA 

NLP 

0322 3E0A 


MVI 

A ,LF 

0324 C9 


RET 


0325 3ACC04 

RBCKTB 

LDA 

NTB 

0328 B7 


ORA 

A 

0329 CA3303 


JZ 

RBPB 

032C 3D 


DCR 

A 

032D 32CC04 


STA 

NTB 

0330 3E20 


MVI 

A, 1 1 

0332 C9 


RET 


0333 CD5503 

RBFB 

CALL 

GETBYT 

0336 B7 


ORA 

A 

0337 CA3303 


JZ 

RBPB 

033A FE0D 


CPI 

CR 

033C C24303 


JNZ 

CKDLE 

033F 32CB04 


STA 

NLF 

0342 C9 


RET 


0343 FE10 

CKDLE 

CPI 

DLE 

0345 CO 


RNZ 


0346 CD5503 


CALL 

GETBYT 

0349 D620 


SUI 

32 

034B 32CC04 


STA 

NTB 

034E C32503 


JMP 

RBCKTB 

0351 CD5503 

NOT$TXT 

CALL 

GETBYT 

0354 C9 


RET 



jread byte 
;.TEXT? 
jneed LP? 


;need tab? 


jread byte from buffer 
jbypass O’s at end of 1024 byte 
Page 


jNeed Line Peed 


jget the space code 

jset indentation 


; Oet the next character from the Pascal file. 
; Read disk if necessary. 


0355 - 

0ETBYT EQU 

0355 2ACD09 

LHLD 

0358 110012 

LX I 

035B CDB902 

CALL 

035E CC6703 

CZ 

0361 7E 

MOV 

0362 23 

INX 

0363 22CD09 

SHLD 

0366 C9 

RET 


$ 

BUFADD 

D,BLKBUF+512 

EQUAL 

RBLK ;return with HL 
A ,M 
H 

BUPADD 


BLKBUP 


0367 - RBLK 

0367 2ACF04 

036A EB 

036B 2AD104 

036E CDB902 

0371 CA9803 

0374 0E01 

0376 CD1BBA 

0379 110010 

0370 CD8502 

037F 118010 

0382 CD8502 

0385 110011 

0388 CD8502 
038B 118011 
038E CD8502 
0391 210010 
0394 22CD04 
0397 C9 

0398 21CA04 SETEOF 
039B 3601 
039D C9 


EQU S 

LHLD LSN 

XCH0 

LHLD LSTLSN 

CALL EQUAL 

JZ SETEOF 

MVI C,1 

CALL SELDSK 

LX I D,BLKBUP 

CALL RDSEC 

LXI D.BLKBUP+80H 

CALL RDSEC 

LXI D,BLKBUF+100H 

CALL RDSEC 

LXI D,BLKBUF+l80H 

CALL RDSEC 

LXI H,BLKBUP 

SHLD BUPADD 

RET 

LXI H,E0FFLAG 

MVI M,1 

RET 


jread LSN block 

jfound last sector 
jselect B disk 

jread four sectors 



Page 42 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

83 




THE SIMPLER PLEASURES 

Dear DDJ, 

You published a short article of mine in DDJ #34 entitled 
“Increase Your Poly 88 Pleasure.” It described how to com¬ 
bine two or more BASIC programs. Since I wrote that article, 

I have discovered a much simpler way of combining programs. 
Enclosed are the newer instructions. I hope you can find the 
space to print this new information. 

Thank you, 4104 Montreal Ave. 

David Larry Johnson Prince George, VA 23875 

Combining Poly 88 A00 BASIC Programs 

The key to combining A00 BASIC programs is in mani¬ 
pulating two “pointers.” At locations 205D-205E is a pointer 
which points to the beginning of free memory space after the 
end of BASIC. The pointer is in normal 8080 reversed byte 
format. A second pointer at 48AA—48AB points at the next 
available byte after the end of the current program in memory. 
After a SCRatch these two pointers point at locations ad¬ 
jacent to each other. With this knowledge it is very simple 
to combine programs by following these steps: 

1. Using front panel mode examine 205D—205E and write 
down the contents. This pointer value will be needed later. 
(May be 49BO.) 

2. LOAD the first program. 

3. LIST the program to determine the line number of the last 
line in the program. Write this down also. 

4. Using front panel mode change the contents of 205D— 
205E to the contents of 48AA--48AB minus one. What you 
are doing here is moving the beginning-of-memory pointer 
up next to the next-available-byte pointer. Now cold start 
BASIC with a front panel jump to location 2000. Now your 
first program is still in memory, but BASIC’s pointers are 
positioned after it so as far as BASIC is concerned, it does 
not exist. 

5. Now LOAD the next program. RENumber it so its first 
line number is greater than the last line number of the first 
program (the number you wrote down in step 3). 

6. Using front panel mode change the contents of 205D— 
205E back to their initial values that you wrote down in step 1. 

7. And finally, warm start BASIC by using a front panel 
jump to location 2003. 

Now if you type LIST you will see that both programs are 
there. You can now SAVE the combined programs or RUN 
them or do anything else with them that you could do with 
either one by itself. To RUN the second program you must 
type RUN XXXX where XXXX is the first line number of the 
second program. You can add a short routine at the beginning 
of the first program which asks which program to run and 
then jumps to the correct one. 

There are some potential problem areas associated with 
joining programs this way: 

1. Unless you type RUN to execute each program each time, 
then variables commmon to both programs may not get ini¬ 
tialized properly. 

2. If you have DATA statements in both programs, a RE¬ 
STORE will always restore to the first DATA statement in the 


first program. Use RESTORE referenced to a specific line 
number to avoid this problem. 

3. If you have defined functions with the same name in both 
programs, you will have to change all the names of the func¬ 
tion in one or the other of the two programs. 

4. If there is not STOP at the end of the first program, you 
may “fall through” into the second program when you do not 
want to. 


This technique for joining programs is quicker to do than 
to read these instructions. It works very well too. It is not 
necessary to stop at joining only two programs. You can 
continue adding programs until you run out of memory or 
out of programs. I have combined as many as ten or twelve 
short demonstration programs into one SAVE and LOAD 
unit on tape. 


ANOTHER PHONE DIALER 


Dear Editor: 

I used the algorithm from Cash Olsen’s “Fast Repertory 
Telephone Dialer Program” (DDJ #38) to develop an auto¬ 
matic phone dialer for my PET. 

I used the Microtronics M65 HAM Interface. The relay is 
placed in series with the green wire to the phone and works 
fine. I used a phone plug jack which closes the circuit for the 
green wire for normal phone operation when the computer is 
unplugged. 

The program is documented with REM statements and is 
self explanatory in conjunction with Olsens article. 


Thanks 8285 Royall Oaks Dr. 

Gary Lindensclimitt Roseville CA 95678 


REFIDV. 

1 REM LINDV/EDIM *DIALER* DR DOBBS SEP79 

2 REM DRIVE RELAY FROM USER PORT PAO 

3 P0KE59459.255 

10 PRINT'CHMSi)" 

11 PRINT PRINTPRINT“WOULD YOU LIKE ME TO CALL SOMEONE?" GOTO 21 

20 PRINT PRINT : PRINT"B0 YOU WANT ME TO F'HONE SOMEONE ELSE ?” 

21 GET 0SIF G$- ’" THEN 21 

22 IF G*="Y" THEN PRINT".1!I«BWWH0 SHOULD I CALL"; -GOTO 2000 

23 PRINT"."WnttWHMiSTHANK YOU.B":STOP 
30 D-l : IFZ-1THENGOSUB110 
35 IFA=1THEN40O 
40 IFA>=999THEN60 
50 F=A E= 100 GOSUB300 
60 IFP>999THEN20 
65 PRINT" 

70 F=P E= 100 GOSIJE300 
75 PRINT" 

80 IFL399S9THEN20 
85 F=L ; E=1000 GOSUB300 
90 GOTO 2050 
100 IFD=0THEND=10 
110 F0RN=1TOD 

120 REM OPEN RELAV 33MS 

121 P0KE59459,255:P0KE594?1,1 

125 T=1:C=TI 

126 B=TI 

128 IFB>=C+<T*2 'THEN132 
130 GOTO126 
132 REM PRINTCB-O/60 

134 REM CLOSE RELAY 16MS 

135 T=1 : C=TI P0KE59471,0 

137 B=T1 

138 IFBJ=C+*T*l > THEM140 

139 GOTO137 

140 REM PRINT'. B-CV60 

141 MEKTN 

142 T=1 C=TI 

143 B-TI 

144 IFB3=C+'T*12:'THEH146 

145 GOTO 143 

146 REM PRINTCB-O/60 
150 RETURN 

300 D=INTtF/E> F=F-CD*E) 

305 PRINTO. 

310 00SUB100 
320 1F£=1THENRETURN 
330 L>E/10 GOTO3O0 



Number 42 

84 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Bex E, Menlo Park, CA 94025 


Page 43 



400 D=1 : PRINT" 1 "; 
41£l G0SUB1 10 
4£Ci GOT060 
500 END 


99C REM**IMSERT DAT* STMTS HERE** 

995 REM**"NAME",AREA CODE,PREFIX,LAST 

996 REM FOUR DIGITS** 

997 REM**FOR LOCAL CALLS USE 1000 ** 

1000 DATA“WORK",1,916,643.4601 
1O10 DATA"HOME",1,916.791,4298 
1020 DATA“MOM",0,1000,725,5966 
1OS0 DATA"TIME”,0,1000,783,1600 
1040 DATA"JIM ELROD",0,1,988,4848 
1O50 DATA"EOB 2INKV",1,1000,421,1350 
1070 DATA"JOE SUDDUTH",1,209,745,4331 
1080 DATA"JACK EBIN",0,1000,791,7618 
1090 DATA"DALLAS PARCHER",1,1000,486,0868 

1999 DATA "END",0,0,0,0 

2000 RESTORE:INPUTN* 

2001 PRINT'.-WiWW 



2002 PRINT"DIAL I NO "S'WB";“ NOW" 

2003 PRINT PRINT 
2018 RLADMt,Z,A,P,L 

2015 II' M*0"END"THEN 2020 

2017 PRINT"I M SORRY BUT I DO NOT KNOW THAT NUMBER" 

2018 PRINT-WIDIS THERE SOMEONE ELSE YOU WOULD LIKE ME TO CALL 9 " GOTO 21 
2020 IFN*OM*THEN2010 

2025 F'RINT"afiREA CODE PREFIX NUMBER" 

2030 PRINT •'PRINTA, P, L :FRINT 
2040 RESTORE 
2045 GOTO 30 

2050 PRINT PRINT"WWHWaWAIT FOR RING" PRINT 

2051 I *'jR I=1 TO10000 : NEXT 

2052 PRINT PRINT"WUDO YOU WANT ME TO DIAL THE SAME NUMBER AGAIN?"; 

2055 GET C* IF C*=“" THEN 2055 

2060 I!' C*0*V" THEN 20 

2061 REM HANO UP FOR 3 SEC * DIAL AGAIN 

2062 PRINT"OK" : X=1 
2065 P0KE59471,X 
2070 T=3 C=TI 
2072 B=TI 

2074 1FB>=C+<T*60)THEN2080 
2076 G0T02072 

2079 PRINT(B-O/60 

2080 IFX=0THEN2GO1 
208,2 X=0 GOTO2065 


2095 OOTO20O1 

READY. 


ABOUT THE PERSONAL COMPUTING SOCIETY 

To DDJ Readers: 

I am frequently asked why, in regard to why the Personal 
Computing Society is trying so hard to become a vital service 
force for the personal computer user. Hobbyist groups dot the 
country, courteously exchanging newsletters. Professional 
groups, such as those under ACM, span the country, addressing 
issues of importance, such as educational and handicapped 
applications, standards development, data security and the 
like. Is not, then, PCS redundant? 

There are two major differences between the Personal 
Computing Society and those referenced above: 

(1) For those already involved with computers, there is a 
substantial cost efficiency. A nominal dues fee gives you access 
to one central source of information, and one centralized 
agency coordinating your opinion with those who share it 
across the country. 

Professional organizations charge expensive fees, since these 
moneys, often reimbursed by members’ employers, must 
support massive professional staffs and housing facilities. 

PCS requests a fee of $10 annually for individuals, but 
clubs can bring their entire membership into our fold for a flat 
$25. Projects currently underway include a study of legal and 
taxation considerations for hobbyist organizations, a network 
capability stringing together the bulletin board facilities 
already utilized by individuals and clubs across the country, 
and a newsletter. These are projects of interest to hobbyists; 
there are others for educators, consumers, varying special 
interest groups. 

(2) The PCS addresses the problems of the lay public, as 
well as the computer expert. No hobbyist or professional 
organization reaches the potential first-time user to educate 


him so that he can purchase wisely. Those of you who al¬ 
ready use computers are gravely affected by the ignorance of 
the public. Unless the lay person is aided with purchase 
guidelines, this vast market remains untapped as a source of 
influence on manufacturers. The vendors then remain free to 
produce without guidelines of quality assurance, and without 
listening to the needs of the user. 

Following purchase, the novice computer user becomes one 
of your number. He will require the same supportive informa¬ 
tion exchange hobbyists and professionals enjoy, but will not 
know this exchange exists, let alone where to find it. Allowed 
to enter the information network, the novice becomes an 
expert, adding his talent to the pool upon which computer 
users draw for assistance. Thus, the computer expert needs the 
support of this uninitiated public, and should reach out to it. 

All that we do is accomplished by volunteers. We wish to 
keep personal computing within the personal control of the 
individual user, so that he can determine the quality of his 
equipment, while increasing his knowledge in its use. We aim 
to accomplish this goal at a minimal cost, by circumventing 
bureaucratic overhead and appealing to members to help each 
other. 

The most important contribution you can make is your 
ideas. When you join, we become your group. It is up to 
you to tell us what you want accomplished. It is up to us, 
the collective, to make it happen. 

For further information, write Abby Gelles, Executive 
Director, Personal Computing Society, Inc., Box 147, Village 
Station, New York, New York 10014. If you wish to join at 
this time, enclose a $10 (individual) or $25 (organizations) 
check payable to Personal Computing Society, Inc. Thank 
you. 

Abby Gelles Personal Computer Society 

The Executive 185 W. Houston St. 

NY NY 10014 


Dear Dr. Dobb’s, 

Amberse M. Banks article, page 43 of DDJ #39, was a big 
help to me for Ver 4 Northstar DOS. 

As I also use the XEK Assembler from the Byte Shop of 
Westminster that requires Ver 2 DOS, I needed the two 
column approach for Ver 2 as well. 

Attached is a copy of the changes needed for Version 2. 


Sincerely, 
Don Dodge 


5291 Kenilworth Dr. 
Huntington Beach CA, 92649 


0000 

0000 

0000 

0000 

0000 

0000 

29E0 0E 0C 
29E2 CD 02 2 7 
29E5 0D 
29E6 C 2 E2 29 
29E9 C 9 
2 9 EA 
2 9 EA 
2 9 EA 
29 EA 
2 9 EA 


0010 ; V ER S10 N 2 NORTHSTAR PATCHES TO GIVE TWO COLUMN OUTPUT 
0020 ; B Y DELETING CR LF CALL AND SUBSTITUTING A SPACING ROUTINE 
0030 ;T0 EVEN OUT THE COLUMNS. ROUTINE FOR VER 4 AND VER 5 
0040 ; PUB LI SHED IN DR. DOBBS, NUMBER 39, OCTOBER 1 979, 

0050 ; V0 LUM E 4, ISSUE 9. AUTHOR AMBERSE M. BANKS. 

0060 ORC 29E0H 

0070 MV I C , 12 ; ADD 12 SPACES FOR COLUMNS 

0080 SPACE CALL 2 702H ;CA LL SPACE ROUTINE 

0090 DC R C 

0100 JNZ SPACE 

0110 R ET 

0120 ; 

0130 ; A LSO CHANCE CALL AT 2707 FROM CD 07 2 7 TO CD E0 29 

0140 ;B Y DON DODGE 

0150 ; 5291 KENILWORTH DR. 

0160 ; HUNTINGTON BEACH CA, 92649 


SYMBOL TALLE 


SPACE 29E2 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94305 


Number 42 

85 







Dr. Dobbs Journals 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 

Number 43 March 1980 Volume 5, Issue 3 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


Mathematical Typography 5 

Donald E. Knuth 

TI9900: Fully Reentrant Formatter Operating Under TIPMX, Part 2 26 

Norman V. Walters 

SYMBOL: Generating Symbol Table Alpha Listing on the H8 21 

William W. Moss 

A Hex Keyboard with Applications for the 1802 ELF 40 

Martin Bronstein 

Can You Afford to Retire? 39 

David E. Raeside 


87 







Mathematical 

Typography 


BY DONALD E.KNUTH 

Computer Science Department 

Stanford University 

Stanford, California 94305 

©1979 by the American Mathematical Society 


ABSTRACT. 

Mathematics books and journals do not look 
as beautiful as they used to. It is not that their 
mathematical content is unsatisfactory, rather 
that the old and well-developed traditions of 
typesetting have become too expensive. For¬ 
tunately, it now appears that mathematics itself 
can be used to solve this problem. 

A first step in the solution is to devise a 
method for unambiguously specifying math¬ 
ematical manuscripts in such a way that they 
can easily be manipulated by machines. Such 
languages, when properly designed, can be 
learned quickly by authors and their typists, 
yet manuscripts in this form will lead directly 
to high quality plates for the printer with little 
or no human intervention. 

A second step in the solution makes use of 
classical mathematics to design the shapes of 
the letters and symbols themselves. It is 
possible to give a rigorous definition of the 
exact shape of the letter “a”, for example, in 

Reprinted from Donald E. Knuth, 
Mathematical Typography, ” Bulletin 
(New Series) of the AMS, volume 1, 
number 2, pp. 337-372, by permission of 
the American Mathematical Society. This 
article is theJosiah Willard Gibbs Lecture 
given by Mr. Knuth in February, 1978. 



such a way that infinitely many styles (bold, 
extended, sans-serif, italic, etc.) are obtained 
from a single definition by changing only a few 
parameters. When the same is done for the 
other letters and symbols, we obtain a math¬ 
ematical definition of type fonts, a definition 
that can be used on all machines both now and 
in the future. The main significance of this 
approach is that new symbols can readily be 
added in such a way that they are automatically 
consistent with the old ones. 

Of course it is necessary that the math¬ 
ematically-defined letters be beautiful 
according to traditional notions of aesthetics. 
Given a sequence of points in the plane, what is 
the most pleasing curve that connects them? 
This question leads to interesting mathematics, 
and one solution based on a novel family of 
spline curves has produced excellent fonts of 
type in the author’s preliminary experiments. 
We may conclude that a mathematical ap¬ 
proach to the design of alphabets does not elim¬ 
inate the artists who have been doing the job 
for so many years; on the contrary, it gives 
them an exciting new medium to work with. 


INTRODUCTION. 

I will be speaking today about work in 
progress, instead of completed research; this 
was not my original intention when I chose the 
subject of my lecture, but the fact is I couldn’t 
get my computer programs working in time. 
Fortunately, it is just as well that I don’t have a 
finished product to describe to you today, 
because research in mathematics is generally 
much more interesting while you’re doing it 
than after it’s all done. I will try therefore to 
convey in this lecture why I am so excited 
about the project I am currently working on. 

My talk will be in two parts, based on two 
different meanings of its title. First I will speak 
about mathematical typography in the sense of 
typography as the servant of mathematics: the 
goal here is to communicate mathematics ef¬ 
fectively by making it possible to publish 
mathematical papers and books of high qual¬ 
ity, without excessive cost. Then I will speak 
about mathematical typography in the sense 
of mathematics as the servant of typography: 
in this case we will see that mathematical ideas 
can make advances in the art of printing. 

PRELIMINARY EXAMPLES. 

To set the stage for this discussion I would 
like to show you some examples by which you 
can “educate your eyes” to see mathematics as 


Number 43 

88 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

























































a piinter might see it. These examples are taken 
from the Transactions of the American Math¬ 
ematical Society, which began publication in 
1900 ; by now over 230 volumes have been pub¬ 
lished. I took these volumes from the library 
shelves and divided them into equivalence 
classes based on what I could perceive to be 
different styles of printing: two volumes were 
placed into the same class if and only if they 
appeared to be printed in the same style. It 
turns out that twelve different styles can be 
distinguished, and it will be helpful for us to 
look at them briefly. 

The first example (Fig. la) comes from page 
2 of Transactions volume 1; I have shown only 
a small part of the page in order to encourage 
you to look at the individual letters and their 
positions rather than to read the mathematics. 
This typeface has an old-fashioned appearance, 
primarily because the upper case letters and the 
taller lower case ones like ‘h’ and ‘k’ are nearly 
twice as tall as the other lower case letters, and 
this is rarely seen nowadays. Notice the style of 
the italic letter ‘x’, the two strokes having a 
common segment in the middle. The subscripts 
and superscripts are set in rather small type. 

This style was used in volumes 1 to 12 of 
the Transactions, and also in the first 21 pages 
of volume 13. Then page 22 of volume 13 
introduced a more modern typeface (Fig. lb). 
In this example the subscript is still in a very 
small font, and unfortunately the Greek Ct here 
is almost indisinguishable from an italic ‘a’. 
Notice also that the printer has inserted more 
space before and after parentheses than we are 
now accustomed to. During the next few years 
the spacing within formulas evolved gradually 
but the typefaces remained essentially the same 
up through volume 24: with one exception. 

The exception was volume 23 in 1922 (Fig. 
lc), which in my opinion has the most pleasing 
appearance of all the Transactions volumes. 
This modem typeface is less condensed, making 
it more pleasant to read. The italic letters have 
changed in style too, not quite so happily - 
note the ‘x’, for example, which is not as nice 
as before — but by and large one has a favorable 
impression when paging through this volume. 
Such quality was not without its cost, however; 
according to a contemporary report in the AMS 
Bulletin [45, p. 100], the Transactions came 
out 18 months late at the time! Perhaps this is 
why the Society decided to seek yet another 
printer. 

In order to appreciate the next change, let’s 
look quickly at two excerpts from the Bulletin 
relating to the very first Gibbs lecture (Fig. 2). 
The preliminary announcement in 1923 ap¬ 
peared in the modem typeface used during that 
year, but the letter shapes in the report of the 
first lecture in 1924 were very cramped and 
stilted. The upper case letters in the title are 
about the same, but the lower case letters in the 
text are completely different. 

This same style appeared in volume 25 of 
the Transactions (Fig. Id), which incidentally 
was set in Germany in order to reduce the cost 
of printing. Note that the boldface letters and 
the italic letters in this example are actually 

Paga 6 

« 


(a) 


(c) 


(e) 


( 8 ) 


(i) 


(k) 


X = ± >/\S =■ db V'*(aa'a")(«aa"j 

there correspond two quadric forms each contain 
rameters. So much Hilbert states. In order fc| 
as known systems it will l>e convenient to use 
mental cubic, due to Hesse.* 

Referred to an inflexional triangle, the equati 

(3) o’ = a] + ar] + a.'] + 6mx,x{ 
All conic polars accordingly have the form : 

(4) « e; = (y,®; + yy.) + yy\) + 2 m{ypp. 


I call this ineffective part of x, “ innocuous" 
validate the fundamental proposition 

(!(*i) AJ{x,)) = (x, * 

which was proved above (P. 4) for effective val 
ineffective part of x t is innocuous is clear: it, 
that the variation of x t does not take place in it 
D. 3. But this consideration leads to the defiri 
cf x. By this I mean the collection of values wlj 


(5) 


* 2 , •••, x m :y it y*, 


in v/hich the <p m are polynomials in ijx, y 5 , • • • , t 
has been considered recently by W. D. Mj* 
usual algebraic elimination theory to the p< 
*(*t» * 2 » •••» x m :y m ) would be found fo 
*(0.0, • • •, 0 : y m ) would be, say, of degree p. 
theorem to (r it x 2 , •••,**: y m ), therefore, 
degree p would appear. This is not in general t 
is sought in this paper, as may readily be sho 
The polynomials may have roots for which 


of systems of division algebras. The next syst 
of order over F with the basal units i*j h k* ( 
with an irreducible equation of degree pq, three 
rational functions Q{i) and \p{i) with coefficie 
iterative 0*(») of ff(i) is i, and likewise \p p (t) 
by 

«*[*'(*•)]-#'[«*(.•)] (* = 0,1, • - ■ , q-V 

The complete multiplication table of the un| 
associative law from 


k p = y , 




six planes yif-yt = 0, each counted three tim 
type j, y, — y, y, =- 0, each counted twice. 

We have seen that any point on the line y, -f 
image in (X) the whole line A, + X, = 0, A', 
in ( y ) meets the line in one point, its image s', coj 
the system s» has also the three lines of this typ 
12. Algebraic procedure. The plane cot 
and the vertex (1, 0, 0, 0) has the equation 

I'.u x. + 7 'is x, -j-p.j x t 

Since (y) and (y) both satisfy this equation wo 


z=e“z° = (*"*?.0 SSg 2a, 

C" is called a Reinhardt circular set if along w 
I e E also the set 

{ Z II Z »M Z !I> *=1.2 .n) 

bounded closed subset of C", unisolvent with respect 1 
The function b(z) being defined and lower semic 

h (,> = {h\ r) . h™}, v 0 = 


(b) 


(d) 


(f: 


0 - r»x(2> i£Ii ) - (XV.adxr, = T. 

i-1 

This element is of lower length. It follows there 
i = 1, Hence, (a) yields that r; =- A;/*, Aj 
Now r k ^ 0, by the minimality of k, and y^A,<l 
which we deduce that y.Aj an =* 0. But the a, a 
which is impossible since in particular A* = 1. 

Theorem 7. Let R be a dense ring of linear t. 
F be a maximal commutative subfield D. If Rp 
tion of finite rank over F, then R contains als* 


The algebra P is nearly simple if and only if thi 

(a) N is spanned by a, • • • , a n ~ k ~ *, b , • • s 
*• / - 1. • *. *• 

(b) Either n - k = char F u/ith k even or n 

Proof. By Theorem 5.5, there are element: 
fl » * ' ’ • a ' Furthermore, ab . 

for all i, / where each a., X.. is in F. From t! 
space of the space spanned by a n ~ k ~ 1 , .., 

Assume P is nearly simple. Then there is 
show that each is in Al. To do this, it is nec 


>f Q , i.e. 

*) = 0 for every x G A for which x(Q) = 0}. 
or m A is equivalent to the one induced by the 

(|x(z)|: xE:A. M<1 and x(w) = 0}. 

present the open unit disk in the complex plane, C, 
t polydisk in n-dimensional complex space C n . T n 
ioundary of D n t i.e. 


The set N x is nowhere dense in Z x and thus N=»p(i 
For each £ e Y—N we must prove that/ c satisfiij 
be the unique projection in {P d \ de D) such that 
the algebra (EjJE) P 0 is finite and homogeneoil 
onal abelian projections E u E it ..., E n such that) 
(l £j, k£n) be partial isometric operators in (EsJ 

(1) U lk U lm =*h mt U lk , where S is the Kronecker dc| 

(2) and 

(3) U„=E h 

for all 1 £j,kj,m£n. For each A in (Es/E)-P 0t t’ 
in & x Po such that 


:tions in GL(IK) and h afi , a, P G / as coordinate 
ined by the respective bases chosen above. If a, 
jnction of A* is the minor of |g^| determined by 
columns /J(l),..., p(j>). The coordinate ring of 
a p together with l/det|/i a ^|, while that of GL(W0 
Dgether with l/det|g^|. The coordinate functions 
so to show A' is a morphism it suffices to show 
nial in and l/det|gj. For this, the following 


haracter of GL( W) is an integral power of the 


:onverges pathwise to and uniformly for t G 
: for which X t is the (last) minimum of y\ let }j\| 
dues of and T, x the inteijump times for Y 
st an i such that )■* = T* = oo. Notice that Yq 
id that as e -* 0, Yq converges to / x = inf s X*. Le| 
ts of (—oo, oo). Then, for example, if / > 1 

e B, r e \ t - y 0 x e C, r e \ k e D,N>Q>i) 
e a, T,\ e b, - y/ e c,t +k sd.n>q 


(© 


(J) 


(/) 


Figure 1. A sequence of typographical styles in the AMS Transactions: 

(a) vol 1 (1900), p. 2; (b) vol 13 (1912), p. 135; (c) vol 23 (1922), p. 216; 

(d) vol 25 (1923), p. 10; (e) vol 28 (1926), p. 207; (f) vol )05 (1962), p. 340; 

(g) vol 114 (1965), p. 216; (h) vol 125 (1966), p. 38; (i) vol 169 (1972), p. 232; 

(j) vc! 179 (1973), p. 314; (k) vol 199 (1974), p. 370; (I) vol 225 (1977), p. 372. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

89 




quite beautiful - and we’re back to the good 
old style of ‘x’ again — so the mathematical 
formulas looked great while the accompany¬ 
ing text was crowded. Fortunately only three 
volumes were published in this style. 

A new era for the Transactions began in 
1926, when its printing was taken over by the 
Collegiate Press in Menasha, Wisconsin. Vol¬ 
umes 28 through 104 were all done in the same 
style, covering 36 years from 1926 to 1961, 
inclusive, and this style (Fig. le) was used also 
in the American Mathematical Monthly. In 
general the modem typefaces were quite satis¬ 
factory, but there was also a curious anomaly: 
Italic letters used in subscripts and superscripts 
of mathematical formulas were in a different 
style from those used on the main line! For 
example, notice the two k’s in the first dis¬ 
played formula of Fig. le: the larger one has a 
loop, so it is topologically different from the 
smaller one. Similarly you can see that the p in 
k^ is quite different from the p in p^. There are 
no x’s in this example, but if you look at other 
pages you will find that the style of x that I like 
best appears only in subscripts and superscripts. 
I can’t understand why this discrepancy was 
allowed to persist for so many years. 

Another period of typographic turmoil for 
the Transactions began with volume 105 in 
(1962). This volume, which was typeset in 
Israel, introduced a switch to the Times Roman 
typeface (Fig. 10; an easy way to recognize the 
difference quickly is to look at the shading on 
the letter o,since it now is somewhat slanted; in 
the previously used fonts this letter always was 
more symmetrical, as if it were drawn with a 
pen held horizontally, but in Times Roman it 
clearly has an oblique stress as if it were drawn 
by a right-handed penman. Note that the three 
k’s are topologically the same in the displayed 
equation here; but for some reason the two 
subscripts k’s are of different sizes. Many of the 
Times Italic letters have a somewhat different 
style than the readers of the Transactions had 
been accustomed to, and I personally think that 
this font tends to make formulas look more 
crowded. Actually the changeover to Times 
Roman and Times Italic wasn’t complete; the 
italic letter g still had its familiar shape, perhaps 
because the new shape looked too strange to 
mathematicians. 

Volumes 105 through 124 were all done in 
this style, except for a brief interruption: In 
volumes 114, 115, and 116 the shading on the 
o’s was symmetrical and the k’s had loops 
(Fig. lg). Another style was used for volumes 
125-168 (Fig. lh): again Times Roman was the 
rule, even in the g’s, except for subscripts and 
superscripts which were in the style I prefer; for 
example, compare the j’s and k’s. (These latter 
volumes were typeset in Great Britain.) 

A greatly increased volume of publication, 
together with the rising salaries of skilled per- 
sonel, was making it prohibitively expensive to 
use traditional methods of typesetting, and the 
Society eventually had to resort to a fancy 
form of typewriter composition that could 
simply be photographed for printing. This un- 


TIIE JOSIAH WILLARD GIBBS LECTURESHIP 

The Council of the Society has sanctioned the establishment 
of an honorary lectureship to be known as the Josiah Willard 
Gibbs Lectureship. The lectures arc to be of a popular nat arc 
on topics in mathematics or its applications, and are to be 
given by invitation under the auspices of the Society. They 
will be held annually or at such intervals as the Council may 
direct. It is expected that the first lecture will be delivered 
in New York City during the winter of 1923-24, and a com¬ 
mittee has been authorized to inaugurate the lectures by 
choosing the first speaker and making the necessary arrange¬ 
ments. 

1L G. D. Richardson, 
Secretary. 


THE FIRST JOSIAH WILLARD GIBBS LECTURE 

The first Josiah Willard Gibbs Lecture was delivered 
under the auspices of this Society on February 29, 1924, 
by Professor M. I. Pupin, of Columbia University, iu the 
auditorium of the Engineering Societies' Building, New York 
City. A large and distinguished nndience was present, 
including, besides members of the Society, many physicists, 
chemists, and engineers who had been invited to attend. 

In introducing the speaker, President Vcblen spoke as 
follows: 

“In instituting the Willard Gibbs Lectures, the American 
Mathematical Society has recognized the dual character of 
mathematics. On the one hand, mathematics is ouc of the 
essential emanations of the human spirit,—a thing to be 
valued in and for itself, like ail or poetry. Gibbs made 


Figure 2. A time of transition. (Excerpts from the AMS Bulletin 29 (1923), p. 385; 30 (1924), 
p. 289.) 


Formula 

Type C 

Type B 

Type T 

1 

z 

$fl$s2$t 

1 over 2 

1 \over 2 

-&* 

*gq"2 

theta sup 2 

\thetaT2 


$rf(x’i)$t 

sqrt{f(x sub i )} 

\sqrt{f(xii)> 


Figure 3. Three ways to describe a formula. 

fortunate circumstance made volumes 169-198 
of the Transactions look like Fig. li, except for 
volumes 179, 185, 189, 192, 194, and 198 
which were done in a far better (yet not wholly 
satisfactory) style that can be distinguished 
from Fig. If by the italic g’s. Fig. lj was 
composed on a computer using a system de¬ 
veloped by Richard McQuillen; this was one of 
the fruits of an AMS research project supported 
by the National Science Foundation [2, 3, 
4,5,6], 

Computer typesetting of mathematics was 
still somewhat premature at the time, however, 
and another kind of “cold copy” made its ap¬ 
pearance in volumes 199 through 224 - an 
“IBM Compositor” was used, except for vol¬ 
umes 208 and 211 which reverted to the Vari- 
typer style of Fig. li. The new alphabet was 
rather cramped in appearance, and some words 
were even more crowded than the others (see 
Fig. Ik). At this point I regretfully stopped sub¬ 
mitting papers to the American Math. Society, 
since the finished product was just too painful 
for me to look at. Similar fluctuations of typo¬ 
graphical quality have appeared recently in all 
technical fields, especially in physics where the 
situation has gotten even worse. (The history of 
publication at the American Society of Civil 
Engineers has been discussed in an interesting 
and informative article by Paul A. Parisi [44].) 


Fortunately things are now improving. Be¬ 
ginning with volume 225, which was published 
last year, the Transactions now looks like Fig. 
11; like Fig. lj, it is computer composed, and 
the Times Roman typeface is now somev/hat 
larger. I still don’t care for this particular style 
of italic letters, and there are some bugs need¬ 
ing to be ironed out such as the overlap be¬ 
tween lines shown in this example; but it is 
clear that the situation is getting better, and 
perhaps some day we will once again be able to 
approach the quality of volumes 23 and 24. 

COMPUTER-ASSISTED COMPOSITION. 

Perhaps the main reason that the situation is 
improving is the fact that computers are able to 
manipulate text and convert it into a form 
suitable for printing. Experimental systems of 
this kind have been in use since the early 1960’s 
(cf. the book by Barnett [10]), and now they 
are beginning to come of age. Within another 
ten years, I expect that most office typewriters 
will be replaced by television screens attached 
to a keyboard and to a small computer. It will 
be easy to make changes to a manuscript, to 
replace all occurrences of one phrase by 
another and so on, and to transmit the manu¬ 
script either to the television screen, or to a 
printing device, or to another computer. Such 


Number 43 

90 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 940Z5 


Page 7 





systems are already in use by most newspapers, 
and new experimental systems for business 
offices actually will display the text in a variety 
of fonts [26]. It won’t be long before these 
machines change the traditional methods of 
manuscript preparation in universities and tech¬ 
nical laboratories. 

Mathematical typesetting adds an extra level 
of complication, of course. Printers refer to 
mathematics as “penalty copy”, and one of 
America’s foremost typographers T. L. De 
Vinne wrote that “[even] under the most 
favorable conditions algebra will be trouble¬ 
some.” [17, p. 171] The problem used to be 
that the two-dimensional formulas required 
complicated positioning of individual metal 
pieces of type; but now this problem reduces 
to a much simpler one, namely that two-di¬ 
mensional formulas need to be represented as a 
one dimensional sequence of instructions for 
transmission to the computer. 

One-dimensional languages for mathemat¬ 
ical formulas are now familiar in programming 
languages such as FORTRAN, but a somewhat 
different approach is needed when all of the 
complexities of typesetting are considered. 
In order to show you the flavor of language for 
mathematical typesetting, I will briefly describe 
the three reasonably successful systems known 
to me. The first, which I will call Type C, is 
typical of the commercially available systems 
now used to typeset mathematical journals such 
as the Transactions ( cf. [12]). The second, 
which 1 will call Type B, was developed at Bell 
Telephone Laboratories and has been used to 
prepare several books and articles including the 
article that introduced the system [27]. The 
third, which I will call Type T, is the one I am 
presently developing as part of the system I call 
TEX [29]. (This has no connection with a 
similarly-named system recently announced by 
Honeywell Information Systems. In my lan¬ 
guage, the T, E, and X are Greek letters and 
TEX is pronounced “tech”, following the 
Greek words for art and technology). 

Fig. 3 shows how three simple formulas 
would be expressed in these three languages. 
The Type C language uses $f...$s...$t 
for fractions, *g for “the next character is 
Greek,” q for the Greek letter theta, ” for 
superscripts, $r . . . $t for square roots and ’ 
for subscripts. The Type B language is more 
mnemonic, using “over”, “theta”, “sup”, 
“sqirt”, and “sub” together with braces for 
grouping when necessary. The Type T language 
is similar but it does not make use of “re¬ 
served words”; a special character \ is used 
before any nonstandard text. This means that 
spaces can be ignored, while they need to be 
inserted in just the right places in the Type 
B la nguage; for example, the space after the “i” 
is important in the example shown, otherwise 
f(xj) would become f(xj) according to the 
Type B rules. Another reason for the \ delimi¬ 
ter in Type T is that it becomes unnecessary 
to match each text item against a stored dic¬ 
tionary, and it is possible to use “sup” to mean 
supcemum instead of superscript. The special 
symbols \ { } t 4- in Type T can be changed 


to any other characters if desired; although 
these five symbols don’t appear on conven¬ 
tional typewriters, they are common on com¬ 
puter terminal keyboards. 

Incidentally, computer typesetting brings us 
some good news: It is now quite easy to re¬ 
present square roots in the traditional manner 
with radical signs or vinculums, so we won’t 
have to write x'' 2 when we don’t want to. 
(Added in proof: I was pleased to find that this 
announcement was greeted with an enthu¬ 
siastic round of applause when I delivered the 
lecture). 

None of these languages makes it possible 
to read complex formulas as easily as in the 
two-dimensional form, but experience shows 
that it is not difficult for untrained personnel 
to learn how to type them. According to 
[12]. “Within a few hours (a few days at most) 
a typist with no math or typesetting back¬ 
ground can be taught to input even the most 
complex equations.” And the Type B authors 
[27] report that “the learning time is short. 
A few minutes gives the general flavor, and 
typing a page or two of a paper generally 
uncovers most of the misconceptions about 
hew it works.” Thus it will be feasible for 
both typists and mathematicians to prepare 
papers in such a language, without investing a 
great deal of effort in learning the system. 
The only real difficulties arise when preparing 
tables that involve tricky alignments. 

Once such systems become widespread, 
authors will be able to prepare their papers 
and see exactly how they will look when 
printed. Everyone who writes mathematical 
papers knows that his intentions are often 
misunderstood by the printer, and corrections 
to the galley proofs have a nontrivial prob¬ 
ability of introducing further errors. Thus, in 
the words of three early users of the Bell Lab’s 
system, “The moral seems clear. If you let 
others do your typesetting, then there will 
be errors beyond your control; if you do your 
own, then you have only yourself to blame.” 
[1] Personally, I can’t adequately describe 
hC'W wonderful it feels when I now make a 
change to the manuscript of my book, as it 
is stored in the Stanford computer, since I 
know that the change is immediately in effect; 
it never will go through any middlemen who 
might misunderstand my intention. 

Perhaps some day a typesetting language 
will become standardized to the point where 
papers can be submitted to the American 
Mathematical Society from computer to com¬ 
puter via telephone lines. Galley proofs will 
not be necessary, but referees and/or copy 
editors could send suggested changes to the 
author, and he could insert these into the manu¬ 
script, again via telephone. 

Of course I am hoping that if any language 
becomes standard it will be my TEX language. 
Well. .. perhaps I am biased, and I know that 
TEX provides only small refinements over what 
is available in other systems. Yet several dozen 
small refinements add up to something that is 
important to me, and I think such refinement 
might prove important to other people as well. 


Therefore I’d like to spend the next few 
minutes explaining more about TEX. 

THE TEX INPUT LANGUAGE. 

TEX must deal with “ordinary” text as well 
as mathematics, and it is designed as a unified 
system in which the mathematical features 
blend in with the word-processing routines 
instead of being “tacked on” to a conventional 
typesetting language. The main idea of TEX is 
to construct what I call boxes. A character of 
type by itself is a box, as is a solid black rec¬ 
tangle, and we use such “atoms” to construct 
more complex boxes analogous to “molecules,” 
by forming horizontal or vertical lists of boxes. 
The final pages of text are boxes made out of 
lists of boxes made out of lists of boxes, and so 
on down to the individual characters and black 
rectangles which are not decomposed further; 
for example, a typical page of a book is a box 
formed from vertical lists of boxes representing 
lines of type, and these lines of type are boxes 
formed from a horizontal list of boxes repre¬ 
senting individual letters. A mathematical 
formula breaks down into boxes in a natural 
way; for example, the numerator and denomi¬ 
nator of a fraction are boxes, and so is the 
bar line between them (since it is a thin but 
solid black rectangle). The elements of a 
rectangular matrix are boxes, and so on. 

The individual boxes of a horizontal list 
or a vertical list are separated by a special 
kind of elastic mortar which I call “glue.” The 
glue between two boxes has three component 
parts (x, y, z) expressed in units of length: 

the space component, x, is the ideal or 
normal space desired between these 
boxes; 

the stretch component, y, is the amount of 
extra space which is tolerable; 

the shrink component, z, is the amount of 
space which may be removed if 
necessary. 

Suppose the list contains n+1 boxes B 0 , Bj, 
.... B n separated by n globs of glue having 
specifications (xj, x lf z x ),... , (x n , y n , z n ). 
When this list is made into a box, we set the 
glue according to the desired final size of the 
box. If the final size is to be larger than we 
would obtain with the normal spacing Xj + 
... + x n , we increase the space proportional 
to the y’s so that the actual space between 
boxes is 

x t + ty!,..., x„+ ty n 

for some appropriate t > 0. On the other hand 
if the desired final size must be smaller, we 
decrease the space to 

Xl -tz 1 ,...,x n -tz n , 
in proportion to the individual shrinkages zj. In 
the later case t is not allowed to become greater 
than 1; the glue will never be smaller than 
x - z, although it might occasionally become 
greater than x + y. Once the glue has been set, 
the box is rigid and never changes its size again. 

Consider, for example, a normal line of text, 
which is a list of individual character boxes. 


Page 8 


Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

91 



The glue between letters of a word will have 
x = y = z = 0, say, meaning that this word 
which is a list of individual character boxes. 
The glue between letters of a word will have 
x = y = z = 0, say, meaning that this word 
always has the letters butting against each 
other; but the glue between words might have 
x equal to the width of the letter ‘e,’ and y = x, 
and z = Vix, meaning that the space between 
words might expand or shrink. The spaces after 
punctuation marks like periods and commas 
might be allowed to stretch at a faster rate but 
to shrink more slowly. 

An important special case of this glue 
concept occurs when we have “infinite” 
stretchability. Suppose the x and z components 
are zero, but the y component is extremely 
large, say y is one mile long. If such an element 
of glue is placed at the left of a list of boxes, 
the effect will be to put essentially all of the 
expansion at the left, therefore the boxes will 
be right-justified so that the right edge will be 
flush with the margin. Similarly if we place 
such infinitely stretchable glue at both ends of 
the list, the effect will be to center the line. 
These common typographic operations there¬ 
fore turn out to be simple special cases of the 
general idea of variable glue, and the computer 
can do its job more elegantly since it is dealing 
with fewer primitives. Incidentally you will 
notice from this example that glue is allowed 
to appear at the ends of a list, not just between 
boxes; actually it is also possible to have glue 
next to glue, and boxes next to boxes, so that a 
list of boxes really is a list of boxes and glue 
mixed in any fashion whatever. I didn’t 
mention this before, because for some reason it 
seems easier to explain the idea first in the case 
when boxes alternate with glue. 

The same principles apply to vertical lists. 
For example, the glue which appears above and 
below a displayed equation will tend to be 
stretchable and shrinkable, but the glue 
between lines of text will be calculated so that 
adjacent base lines will be uniformly spaced 
when possible. You can imagine how the 
concept of glue allows you to do special tricks 
like backspacing (by letting x be negative), in a 
natural manner. 

LINE DIVISION. 

One of the more interesting things a system 
like TEX has to do is to divide up a paragraph 
into individual lines so that each line is about 
the right length. The traditional way to do this, 
which is still used on today’s computer type¬ 
setting systems, is to make the best possible 
line division you can whenever you come to the 
right margin, but once this line has been output 
you never reconsider it again-you start the 
next line with no memory of what has come 
before. Actually it often happens that one 
could do better by moving a short word down 
from one line to the next, but the problem is 
that you don’t know what the rest of the para¬ 
graph will be like when you have only looked at 
one line’s worth. 


The TEX system will introduce a new 
approach to the problem of line division, in 
which the end of a paragraph does influence 
the way the first lines are broken; this will 
result in more even spacing and fewer hyphen¬ 
ated words. Here is how it works: First we 
convert the line division problem to a precisely- 
defined mathematical problem by using TEX’s 
glue to introduce the concept of “badness.” 
When a horizontal list of boxes has a certain 
natural width w (based on the width of its 
boxes and the space components of its glue), 
a certain stretchability y (the sum of the stretch 
components) and a certain shrinkability z (the 
sum of the shrinkages), the badness of setting 
the glue to make a box of width W is defir,ed 
to be 1 + 100t 3 in our previous notation; more 
precisely, it is 


1 

, ifW = w, 

1 + ioo/ w_w Y 

, if W> w , 

\ y / 

1 + 10 o/ w-W Y 

, ifw-z^W < w 

V * t 

infinite 

, if W < w - z . 


Thus if the desired width W is near the natural 
width w, or if there is a lot of stretchability and 
shrinkability, the badness rating is very small; 
but if W is much greater than w and there isn’t 
much ability to stretch, we have a lot of bad¬ 
ness. Furthermore we add penalty points to the 
badness rating if the line ends at a compara¬ 
tively undesirable place; for example, when a 
word needs to be hyphenated, the badness goes 
up by 25, and an even worse penalty is paid if 
we have to break up mathematical formulas. 

The line division problem may now be 
stated as follows. “Given the text of a para¬ 
graph and the set of all allowable places to 
break it between lines, find breakpoints which 
minimize the sum of the squares of the bad¬ 
nesses of the resulting lines.” This definition is 
quite arbitrary, of course, but it seems to work. 
Preliminary experiments show that the same 
choice of breakpoints is almost always found 
when simply minimizing the sum of the 
individual badnesses rather than the sum of 
their squares, but it seems wise to minimize the 
sum of squares as a precautionary measure since 
this will also tend to minimize the maximum 
badness. 

Just stating the line division problem in 
mathematical terms doesn’t solve it, of course:; 
we need to have a good way to find the desired 
breakpoints. If there are n permissible places to 
break (including all spaces between words and 
all possible hyphenations), there are 2 n possible 
ways to divide up the paragraph, and we would 
never have time to look at them all. Fortu¬ 
nately there is a technique that can be used to 
reduce the number of computational steps to 
order n 2 instead of 2 n ; this is a special case of 
what Richard Bellman calls “dynamic program¬ 
ming.” Let f(j) be the minimum sum of badness 
squares for all ways to divide the initial text of 
the paragraph up to breakpoint j, including a 


break at j, and let b(i, j) be the badness of a 
line which runs from breakpoint i to break¬ 
point j. Let breakpoint 0 denote the beginning 
of the paragraph; and let breakpoint n + 1 be 
the end of the paragraph, with infinitely 
expandable glue inserted just before this final 
breakpoint. Then 

f(0) = 0 ; 

f(j)= min (f(i) + b(i,j) 2 ), 

0 < i < j 

for 1 ^ j <Sn+l . 

The computation of f(l).f(n+l) can be 

done in order n 2 steps, and f(n+l) will be the 
minimum possible sum of badnesses squared. 
By remembering the values of i at which the 
minima occurred for each j, we can find break¬ 
points which give the best line divisions, as 
desired. 

In practice we need not test extremely 
unlikely breakpoints; for example, there is 
rarely any reason to hyphenate the very first 
word of a paragraph. Thus it turns out that this 
dynamic programming method can be further 
improved to an algorithm whose running rime 
is almost always of order n instead of n , and 
comparatively few hyphenations will need to 
be tried. Incidentally, the problem of hyphen¬ 
ation itself leads to some interesting mathe¬ 
matical questions, but I don’t have time to 
discuss them today. (Cf. [41] and the 
references in that paper.) 

The idea of badness ratings applies in the 
vertical dimension as well as in the horizontal; 
in this case we want to avoid breaking columns 
or pages in a bad manner. For example, penalty 
points are given for splitting a paragraph 
between pages after a hyphenation, or for 
dividing it in such a way that only one of its 
lines-a so-called “widow” line—appears on a 
page. The placement of illustrations, tables, and 
footnotes is also facilitated by formularing 
appropriate rules of placement in terms of bad¬ 
ness. 

There is more to TEX, including for 
example some facilities for handling the rather 
intricate layouts often needed to typeset tables 
without having to calculate column widths; but 
I think I have described the most important 
principles of its organization. During the next 
few months 1 plan to write the computer pro¬ 
grams for TEX in such a way that each algo¬ 
rithm is clearly explained and so that the 
system can be implemented on many different 
computers without great difficulty; then I 
intend to publish the programs in a book so 
that everyone who wants to can use them. 

ENTR’ACTE. 

I said at the beginning that this talk would 
be in two parts, discussing both the ways that 
typography can help mathematics and that 
mathematics can help typography. So far we 
have seen a little of both, but the mathematics 
has been comparatively trivial. In the remainder 
of my lecture I would like to discuss what I 
believe is a much more significant application 
of mathematics to typography, namely to the 


Number 43 

92 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 



specification of the letter shapes themselves. 
A more accurate way to describe the two parts 
of my lecture would be to say that the first part 
was about TEX, a system which takes manu¬ 
scripts and converts them into specifications 
about where to put each character on each 
page; and the second part will be about another 
system I’m working on called METAFONT, 
which generates the characters themselves, 
for use in the inkier parts of the printing 
business. 

Before I get into the second part of my 
lecture I need to discuss recent developments 
in printing technology. The most reliable way 
to print mathematics books of high quality 
during the past several decades has been to use 
the monotype process (actually the Monotype 
Corporation now manufactures digital photo- 
setting equipment as well as the traditional 
‘monotype’ machines) which casts characters 
in hot lead, together with hand operations for 
complex built-up formulas. When I watched 
this process being applied to my own books 
several years ago, I was surprised to learn that 
the lead type was used to print only one copy; 
this master copy was then photographed, and 
the real printing took place from the photo¬ 
graphic plates. This somewhat awkward 
sequence of steps was justified because it was 
the best way known to give good results. 
During the 1960’s, however, hot lead type was 
replaced for many purposes by devices like the 
Photon machine used to prepare the printed 
programs for this lecture; in this case the 
proi:ess is entirely photographical, since the 
letter shapes are stored as small negatives on 
a rotating disk, and the plates needed for 
printing are obtained by exposing the film 
after transforming the characters into the 
proper size and position with mirrors and 
lenses (cf. [10]). Such machines are limited 
by slow speed and the difficulties of adding 
new characters. 

‘THIRD-GENERATION” 
TYPESETTING EQUIPMENT 

More recent machines, such as the one used 
to prepare the current volumes of the Trans¬ 
actions, have replaced these “analog” processes 
by a “digital” one. The new idea is to divide the 
page or the photographic negative into millions 
of liny rectangles, like a piece of graph paper or 
like a television screen but with a much higher 
resolution of about 1000 lines per inch. For 
each of the tiny “pixels” in such a raster 
pattern-there are about a million square pixels 
in every square inch-the typesetting machine 
decides whether it is to be black or white, and 
the black ones are exposed on the photographic 
plate by using a very precisely controlled 
electron beam or laser beam. Since these 
machines have few moving parts and require 
little or no mechanical motion, they can 
operate at very high speeds even though they 
are exposing only a tiny bit of the film at any 
time. 

Stating this another way, the new printing 
equipment essentially treats each page of a 


book as a huge matrix of 0’s and l’s, with ink 
to be placed in the positions that are 1 while 
the 0 positions are to be left blank. It’s like the 
flashcards at a football stadium, although on a 
much grander scale. The total job of a system 
like TEX now becomes one of converting an 
author’s manuscript into a gigantic bit matrix. 

The first question we must ask of course is, 
“What happens to the quality?” Clearly a 
television picture is no match for a photograph, 
arid the digital typesetting machines would be 
quite unsatisfactory if their output looked 
inferior to the results obtained with metal 
type. In matters like this, I have to confess 
being somewhat of a stickler and a perfec¬ 
tionist; for example, I refuse to eat margarine 
instead of butter, and I have never heard an 
electronic organ that sounds even remotely as 
beautiful as a pipe organ. Therefore I was quite 
skeptical about digital typography, until I saw 
an actual sample of what was done on a high 
quality machine and held it under a magnifying 
glass: It was impossible to tell that the letters 
were generated with a discrete raster! The 
reason for this is not that our eyes can’t distin¬ 
guish more than 1000 points per inch; in 
appropriate circumstances they can. The 
reason is that particles of ink can’t distinguish 
such fine details-you can’t print the edge of 
an ink line that zigzags 1000 times on the 
diagonal of a square inch, the ink will round 
off the edges. In fact the critical number 
seems to be more like 500 than 1000. Thus 
the physical properties of ink cause it to appear 
as if there were no raster at all. 

It now seems clear that discrete raster-based 
printing devices will soon make the other 
machines obsolete for nearly all publishing 
activity. Thus in future days the fact that 
Gutenberg and others invented movable type 
will not be especially relevant, it will merely 
be a curious historical fact which influenced 
history for only about 500 years. The ulti¬ 
mately relevant thing will be mathematics: the 
mathematics of matrices of 0’s and l’s! 

SEMI-PHILOSOPHICAL REMARKS. 

I have to tell the next part of the story from 
my personal point of view. As a combinatorial 
mathematician, I really identify with matrices 
of 0’s and l’s, so when I learned last spring 
about such printing machines it was impossible 
for me to continue what I was doing; I just had 
to take time off to explore the possibilities of 
the new equipment. My motivation was also 
increased by the degradation of quality I had 
been observing in technical journals; and 
furthermore the publishers of my books on 
computer programming had tried valiantly but 
unsuccessfully to produce the second edition 
of volume 2 in the style of the first edition 
without using the rapidly-disappearing hot lead 
process. It appeared that my books would soon 
have to look as bad as the journals! When 1 saw 
that these problems could all be solved by 
appropriate computer programming, I couldn’t 
resist trying to find a solution by myself. 

One of the most important factors in my 


motivation was the knowledge that the problem 
would be solved once and for all, if I could find 
a purely mathematical way to define the letter 
shapes and convert them to discrete raster 
patterns. Even though new printing methods 
are bound to be devised in the future, possibly 
even before I finish volume seven of the books 
I’m writing, any new machines axe almost 
certain to be based on a high precision raster; 
and although the precision of the raster may 
change, the letter shapes can stay the same 
forever, once they are defined in a machine- 
independent form. My goal was therefore to 
give a precise description of the shapes of all 
the symbols I would need. 

I looked at the way fonts of the type are 
being digitized at several places in different 
parts of the world; it is basically done by 
taking existing fonts and copying them using 
sophisticated camera equipment and computer 
programs, together with manual editing. But 
this seemed instinctively wrong to me, partly 
because the sophisticated equipment wasn’t 
readily available in our laboratory at Stanford, 
and partly because the copying of copyrighted 
fonts is of questionable legality, but mostly 
because I felt that the whole idea of making a 
copy was not penetrating to the heart of the 
problem. It reminded me of the anecdote I had 
once heard about slide rules in Japan. 
According to this story, the first slide rule ever 
brought to the Orient had a black speck of dirt 
on it; so for many years all Japanese slide rules 
had a useless black spot in this same position! 
The story is probably apocryphal, but the 
point is that we should copy the substance 
rather than the form. I felt that the right 
question to ask would not be “How should 
this font of type be copied?” but rather: 
“If the great type designers of the past were 
alive today, how would they design fonts for 
the new equipment?”- I didn’t expect to be 
capable of finding the exact answer to this 
question, of course, but I did feel that it would 
lead me in the right direction, so I began to 
read about the history of type design. 

Well, this is a most fascinating subject, but 
I can’t talk much about it in a limited time. 
Two of the first things I read were autobio¬ 
graphical notes by two well-known 20th 
century type designers, Hermann Zapf [51] 
and Frederic W. Goudy [20], and I was espe¬ 
cially interested by some of Zapfs remarks: 

With the beginning of the ’sixties ... I 
was stimulated by this new field [photo- 
composing] ... The type-designer — or 
better, let us start calling him the alpha¬ 
bet designer-will have to see his task 
and his responsibility more than before 
in the coordination of the tradition in 
the development of letterforms with the 
practical purpose and the needs of the 
advanced equipment of today ... The 
new photocomposing systems using 
cathode-ray tubes (CRT) or digital 
storage for the alphabet bring with them 
some absolutely new technical problems, 
many more than did the past ... [51, 
P-71]. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 10 


Number 43 

93 



I have the impression that Goudy would not 
have been so sympathetic to the new-fangled 
equipment, yet his book also gave helpful ideas. 

MATHEMATICAL TYPE DESIGN. 

Fortunately the Stanford Library has a 
wonderful collection of books about printing, 
and I had the chance to read many rather rare 
source materials. I learned to my surprise that 
the idea of defining letters mathematically is 
by no means new, it goes back to the fifteenth 
century and it became rather highly developed 
in the early part of the sixteenth. This was the 
time when there were Renaissance men who 
combined mathematics with the real world, and 
in particular there was an interest in con¬ 
structing capital letters with ruler and compass. 
The first person to do this was apparently 
Felice Feliciano, about 1460, whose hand¬ 
written manuscript in the Vatican Library was 
published 500 years later [19]. Feliciano was 
an excellent calligrapher who wanted to put the 
principles of calligraphy on a sound mathemat¬ 
ical foundation. Several other fifteenth-century 
authors made similar experiments ([8] gives a 
critical summary of these early developments), 
but the most notable work of this kind 
appeared in the early sixteenth century. 

The Italian mathematician Luca Pacioli, 
who had previously written the most influential 
book on algebra at the time (one of the first 
algebra books ever published), included an 
appendix on alphabets in his De Devina Pro- 
portione, a book about geometry and the 
“golden section” which appeared in 1509. 
Another notable Italian work on the subject 
was published by Francesco Tomiello in 1517 
[48], [33]; Fig. 4 illustrates the letter B as con¬ 
structed by Pacioli, Tomiello, and by Giovan- 
battista Palatino [43]. Palatino was one of the 
best calligraphers of the century, and he did 
this work about 1550. Similar work appeared in 
Germany and France; the German book was 
probably the most famous and influential, it 
was Albrecht Durer’s Underweysung der 
Messung [18], a manual of instruction in 
geometry for Renaissance painters. The French 
book was also rather popular, it was Champ 
Fleury by Geofroy Tory [49], the first royal 
printer of France and the man who introduced 
accented letters into French typography. Fig. 5 
shows Tory’s two suggestions for the letter B. 
Of all these books I much prefer Torniello’s, 
since he was the only one who stated the con¬ 
structions clearly and unambiguously. 

Apparently nobody carried this work 
further to lower case letters, numerals, or italic 
letters and other symbols, until more than 100 
years later when Joseph Moxon made a detailed 
study of some beautiful letters designed in 
Holland [38]. The ultimate in refinement of 
this mathematical approach took place shortly 
afterwards when Louis XIV of France commis¬ 
sioned the creation of a Royal Alphabet. A 
commission of artists and typographers worked 
on Louis’ project for more than ten years 
beginning about 1690, and they made elaborate 
constructions such as those shown in Fig. 6 
[24], 





4- 


(c) 

Figure 4. Sixteenth century ruler-and-compass constructions for the letter B by (a) Pacioli 
[42], (b) Tomiello [48] , and (c) Palatino [43] . 



Figure 5. Two more B's, by Tory [49]. 


Number 43 

94 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


Page 1 






\Gnttu\t OtMrre*. 

( rm 04 . /vfi// i 

1'f 1 -/i,1,file- prtir > 
JmWim/#' 

M I# dM/rw. ’ 


t "ill,.J»:-!h!iiiliii-»aiu|l''i|ii.;.i..iiia.,:':ii.iii^|B\ Warth: n j? 






..1 'l.ll'M^li^'IIUllltlVlIhli 


T’hus it is clear that the mathematical 
definition of letter forms has a long history. 
However, I must also report near-universal 
agreement among today’s scholars of typog¬ 
raphy that those efforts were a failure. At 
worst, the ruler-and-compass letters have been 
called “ugly” and at best they are said to be 
“deprived of calligraphic grace” [8], The 
French designs were not really followed faith¬ 
fully by Phillipe Grandjean who actually cut 
Louis XIV’s type, nor by anybody else to date, 
and F. W. Goudy’s reaction to this was: “God 
be praised!” [20, p. 139]. Such strictly geo¬ 
metric letter forms were in fact criticized 
already in the sixteenth century by Giovan 
Cresci, a noted scribe at the Vatican Library 
and the Sistine Chapel. Here is what Cresci 
wrote in 1560: 


Well, Cresci was right. But fortunately there 
have been a few advances in mathematics 
during the last 400 years, and we now have 
some other tricks up our sleeves besides straight 
lines and circles. In fact, it is now possible to 
prescribe formulas that match the nuances of 
the best type designers; and perhaps a talented 
designer working with appropriate mathemat¬ 
ical tools will be able to produce something 
even better than we now have. 


DEFINING GOOD CURVES. 


I have come to the conclusion that if Euclid, 
tihe prince of geometry, returned to this 
world of ours, he would never find that the 
curves of the letters could be constructed by 
means of circles made with compasses. [16] 


Let’s consider the following mathematical 

problem: Given n points Zj, z 2 .z n in the 

plane, what is the most pleasing closed curve 
that goes through them in the specified order 
Z], Z 2 ,..., z n and then returns to zi? To 
avoid degenerate situations we may assume that 
n is at least 4. This problem is essentially like 
the dot-to-dot puzzles that we give to young 
children. 

Of course it is not a well-posed mathemat¬ 
ical problem, since I didn’t say what it means 
for a curve to be “most pleasing”. Let’s first 
postulate some axioms that the most pleasing 
curve should satisfy. 

Property 1 (Invariance). If the given points 
are rotated, translated, or expanded, the most 
pleasing curve will be rotated, translated, or 
expanded in the same way. [In symbols: 
MPC(azi +b,..., az n + b) = aMPC(Zi,.. ,z n ) 
+ b.] 

Property 2 (Symmetry). Cyclic permutation 
of the given points does not change the solu¬ 
tion, [MPC(z!,z 2 .z n ) = MPC(z 2 ,..., 

z n> 2 i )•] 

Property 3 (Extensionality). Adding a new 
point that is already on the most pleasing curve 
does not change the solution. [If z is between 
zfc and z^+ 1 on MPC(zi,. .. ,z n ), then 
MPC(zi.... .Zk.z.zk+j,... ,z n ) = MPC 

(Zj,... .zjc.zjj+j,... ,Zn).] 


(to) 

Figure 6. Roman and italic letters designed for Louis XIV of France [24]. 


These properties are rather easy to justify on 
intuitive grounds. For example, the exten- 
sionality property says that additional infor¬ 
mation won’t lead to a poorer solution. 

The next property is not so immediately 
apparent, but I believe it is important for the 
application I have in mind. 

Property 4 (Locality). Each segment of the 
most pleasing curve between two of the given 
points depends only on those points and the 
ones immediately preceding and following. 

[MPC(Zi ,z 2 .Zj,) is composed of 

MPC(z n ,zi,z 2 ,z 3 ) from zj to z 2 , then 
MPC(zj ,z 2 ,z 3 ,Z 4 ) from z 2 to z 3 ,..., then 
MPC(z n _ 1 ,z n ,z 1 ,z 2 ) from zn to Zj.] 
According to the locality property, changes to 
one part of a pattern won’t affect the other 
parts. This simplifies our search for the most 
pleasing curve, because we need only solve the 
problem in the case of four given points; and 
experience shows that it is also a great simpli¬ 


fication when letters are being designed, since 
individual portions of strokes can be dealt with 
separately. Incidentally, property 4 implies 
property 2 (cyclic symmetry). 

One way to satisfy all four of these prop¬ 
erties is simply to let the most pleasing curve 
consist of straight line segments. But this 
doesn’t seem adequately pleasing, so we 
postulate: 

Property 5 (Smoothness). There are no 
sharp comers in the most pleasing curve. 
[MPC (Zj ,..., z n ) is differentiable, under some 
parameterization.] In other words, there is a 
unique tangent at every point of the curve. 

The extensionality, locality, and smoothness 
properties taken together imply, in fact, that 
the direction of the tangent at z 2 depends only 
on z 1 , z 2 , and z 3 . For this tangent appears in 
two curves, the one from zi-_ 2 to z^ and the 
one from zfc to z^+j, hence we know that it 
depends only on (zk- 2 ,zi c _ 1 ,zi c ,z) c +i) and 


C jiutnu turn d< la Iftnx A — 

:F~: 


(oiulrtuliim Jr In H 


Page 12 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

95 





























and that it depends only on (%-1 .z^.z^+i, 
zk+ 2 ). By the extensionality property, we can 
assume that n is at least 5, so Zk _ 2 is different 
from zjc +2 and the tangent must be independ¬ 
ent of them both. We have actually used only a 
very weak form of extensionality in this 
argument. 

If we apply the full strength of the ex¬ 
tensionality postulate, we obtain a much 
stronger consequence, which is quite un¬ 
fortunate: There is no good way to satis¬ 
fy Properties 1-5! For example, suppose we 
add one more axiom, which is almost necessary 
in any reasonable definition of pleasing curves: 

Property 6 (Roundness). If Zj, z 2 , z 3 , Z 4 are 
consecutive points of a circle, the most pleasing 
curve through them is that circle. This property 
together with our previous observation about 
the tangent depending only on three points 
completely determines the tangent at each of 
our given points; namely, the tangent at Zfc is 
the tangent to the circle which passes through 
Zfc_!, zk, and z^+i. (Let’s ignore for the 
moment the possibility that these three points 
lie on a straight line.) Now the extensionality 
property says that if z is any point between Z\ 
and z 2 on the most pleasing curve for 
Zj,... ,z n , we know the tangent direction at 
z, as long as z is not the line from z\ to z 2 . But 
there is a unique curve starting at any z off this 
line and having the specified tangents at each of 
its points, namely the arc of the circle from z to 
z 2 passing through Z \: No matter where you 
start, off the straight line, there is only one 
curve having the correct tangents. It follows 
that the tangent at z 2 depends only on z\, z 2 
and the tangent at Zj, and this is impossible. 

The above argument proves that there is no 
way to satisfy properties 3, 4, 5, and 6 . A sim¬ 
ilar argument would show the impossibility for 
any reasonable replacement for property 6 , 
since the tangents determined for all z between 
Zi and z 2 will define a vector field in which 
there are unique curves through essentially all 
of the points z, yet a two-parameter family of 
curves is required between Z\ and z 2 in order 
to allow suficient flexibility in the derivatives 
there. 

So we have to give up one of these proper¬ 
ties. The locality property is the most 
suspicious one, but I mentioned before that I 
didn’t want to give it up; therefore the ex¬ 
tensionality property has to go. This means that 
if we take the most pleasing curve through 

Zi.z n and if we specify a further point 

z actually on this curve between z^_ l and zfc, 
where the tangent at z is not the same as the 
tangent to the circle from zj[_ j to z to z^, 
then the “most pleasing” curve through these 
n+1 points will be different. A possible virtue is 
that we are encouraged not to specify too many 
points; a possible drawback is that we may not 
be able to get the curves we want. 

A PRACTICAL APPROXIMATION. 

Returning to the question of type design, 
our goal is to specify a few points and to 
have a mathematical formula that defines a 


pleasant curve through these points; such curves 
will be used to define the shape of the character 
we are designing. Ideally it should also be easy 
to compute the curves. I decided to use cubic 
equations 

z(t) = a 0 + <* 11 + a 2 t 2 + a 3 t 3 
where a 0 , a lt a 2 , a 3 are complex numbers 
and t is a real parameter. The curves I am 
dealing with are cubic spines, namely piece- 
wise cubic equations, since a different cubic 
will be used in each interval between two of the 
given points; however, the way I am deter¬ 
mining the coefficients of these two cubics is 
different from any of the methods known to 
me, in my limited experience with the vast 
literature about spines. Perhaps my way to 
choose the coefficients is more awkward than 
the usual ones; but I have obtained good results 
with it, so I’m not ashamed to reveal the 
curious way I proceeded. 

In the first place, I decided that the cubic 
equation between Z\ and z 2 should be deter¬ 
mined completely by Zj and z 2 and the direc¬ 
tions of the tangents at Zj and z 2 . We have 
already seen that these tangents are essentially 
predetermined if properties 4, 5, and 6 are to 
be valid, and I have also found frequent occa¬ 
sion in type design when it was desirable to 
specify that a certain tangent was to be made 
horizontal or vertical. Thus, my method of 
computing a nice curve through a given se¬ 
quence of points is first to compute the tangent 
directions at each point, then to compute the 
cubics in each interval based solely on the end¬ 
points of that interval and on the desired 
tangents there. By rotation and translation and 
scaling, according to property 1 , we can assume 
that the problem is to go in the complex pliine 
from 0 to 1 , with given directions at the end¬ 
points. The most general cubic equation which 
does this is 

z(t)= 3t 2 -2t 3 +re i 6 t(l-t ) 2 
+ se ~ * 0 t 2 (1 — t) , 

and it remains to determine positive numbers 
r and s as appropriate functions of 9 and 0. 

In the second place, I realized that it was 
impossible to satisfy property 6 with cubic 
splines, because you can’t draw a circle as a 
cubic function of t. But I wanted to be able to 
get curves that were as near to being circles 
as possible, whenever four consecutive data 
points lay on a circle; the curves should prefer¬ 
ably be indistinguishable from circles as far 
as the human eye is concerned. Therefore when 
9 = 0 I decided to choose r = s in such a way 
that z( 1 / 2 ) was precisely on the relevant circle, 
hoping that the curve between 0 and 1/2 
and between 1/2 and 1 wouldn’t veer too 
far away. Well, this turned out to work ex¬ 
tremely well: A little calculation, done with the 
help of a computer, (thanks are due to the 
developers of the computer algebra system 
called MACSYMA at MIT, and to the ARPA 
network which makes this system available 
for research work) showed that the maximum 
deviation from a true circle occurs at the points 
t = (3 and the relative error is negli¬ 

gibly small. For example, if we take four points 
equally spaced at distance 1 from some center, 


the spline curve defined by these points in the 
above manner stays between distance 1 and 
distance 71/54 - 2v^/9 <1.00055 from the 
center, an error of less than one part in a thou¬ 
sand: if there are 8 points, the maximum error 
is less than four parts per million; and if there 
are n points, the maximum error goes to zero 
as 1 /n . 

(Changing the notation slightly, let 

2 ( 1 ) « I + (t le - l)(3t ! -2t’) + 411(1-0(1 -1-c iB t) (sin|^/|'l + “ s |) 

and f(t) * |z(l)| a . Then 

/cos0-l\ 1 

f’(l) - 8sin’2 I _ ! _I <t-l)t( 2 t-l)( 6 l ’-61 + 1) 

H-/ 

and 

"»« U(l)l • 

0<t<l 


,/wn . 1 + 

\ 6 / 55296 


while minQ <t < 1 |z(t)| = z ( 0 ) = z(l/ 2 ) = 
z(l)=l. The “ two-point circle” has max 
|z(t) |= \/28/27 = 1.01835, the three-point 
circle has max | z(t) | = \/325/324 = 1.001542, 
and the eight-point circle has max |z(t) | = 
1.0000042455 .) 

Another case when a natural way to choose 
r and s suggests itself is when 0 + 0=90 ; 
then the curve z(t) should be nearly the same as 
an ellipse having the endpoints on its axes. 
So far therefore I knew that I wanted 


_4 _ 

I + COS 0 


when 0 = 


0 ; 


. 4 cos 9 

(I + cos 45 ® )(cos 45 °) 
So I tried the formulas 


4 cos 0 

(I + cos 45 °)(cos 45 °) 


when 0 -I- 0 ■ 90 ° 


So I tried the formulas 






which fit both cases. However, this didn’t give 
satisfactory results, especially when 0 + 0 
approached 180 . My second attempt was 


4 sin 0 





and this has worked very well. Fig. 7 shows 
the spline curves that result from the above 
approach when 0 = 60 and when 9 varies from 
0° to 120° in 5° steps. 

It can be proved that if 9 and 0 are non- 
negative and less than 180 , the cubic curve 
z(t) I have defined will never cross the striaght 
lines at angles 9 and 0 that meet the endpoints 
0 and 1 respectively. This is a valuable pro¬ 
perty in type design, since it can be used to 
guarantee that the curve won’t get out of 
bounds. However, I found that it also led to 
unsatisfactory curves when one of 0 or 0 was 
very small and the other was not, since this 
meant that the curve z(t) would be very 
close to a straight line yet it would enter that 
line from outside at a rather sharp angle In 
fact, the angle 9 is not infrequently zero, 
and this forces a straight line and a sharp 
comer at the right endpoint. Therefore I 


Number 43 

96 


Or. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 



:i!. Mathematieikl-i; liJ i 

.__Mathemati.cal.. 

' ■!'U : 'TTTT 1 ■ j : •’ i'j i" ! I : ! | .; ! 1 : I'-' 

: ; Typography j j. 

it .till* • ■ t* ■ '.i 1 • • 1 i •• « • • • • • • • • •»1 1 • i 

’ • Typography , 

(•) 

(*) 

J ' • •. • • . ‘ 9 j ! ' • • i: | : 

; Mathematical ' 

li , Mathematical 
Typography i.} 

• ' | ' j -t 11. I •$"!•••.j • 

(r) 

; Typography j , r ;j ! j 

0>) 

• : [' • ;| ’ • II • 1 ~ 

Mathematicali ! 

M ATHEM ATIG ALj: j 
Typography ! 

1 . | .. I . ■ • . •• • •! 1 • • 

(g) 

i, Typography ; 

• • . • : : i • • • • • s • ■ • 

NlATHematical 

(C) 

T YPOgraphy 

(h) 

1 Mathematical i li. 


Typography 

: i . . • * 

(d) 

Muthomatloal 

Typography 

(i) 


Figure 13. Different styles of type: (a) conventional "modern" font; (b) corresponding boldface; (c) sans serif font; (d) boldface 
sans serif; (e) typewriter imitation with fixed width letters; (f) slanted letters; (g) caps and small caps; (h) "small lower 
case"; (i) variations. 


design each size of type individually. I’m not 
claiming that Fig. 14 shows the best way for 
the proportions to vary, it will take further 
experimentation before I have a good idea of 
what is desirable. The point I wish to make is 
that the alteration of type sizes for subscripts 
and so on is not as simple as it might seem at 
first, but a system like METAFONT will be 
able to vary the parameters quite readily, and 
visual experiments on different parameter 
settings can be carried out quickly. It used to 
tale months for a type designer to make his 


drawings and have them converted to metal 
molds before he could see any proofs. One of 
the results was that there simply wasn’t time 
to give proper attention to all the mathemat¬ 
ical symbols and Greek letters, etc., as well 
as to the more common symbols, so a printer 
of mathematics had to make to with a hodge¬ 
podge of available characters in different sizes. 
(For example, he was often obliged to use dif¬ 
ferent styles of letters in subscript positions, as 
we have seen.) Under the approach I am rec¬ 
omending, we automatically get consistency of 
all the symbols whenever the parameters 
change. 


FROM CONTINUOUS TO DISCRETE. 

The METAFONT system must not only 
define the characters in the continuum on the 
plane, it must also express them in terms of a 
discrete raster. Such squaring off of letters on 
graph paper has a long history, going back far 
before the invention of computers or television; 
for example, we all can remember seeing cross- 
stitch embroidery samplers from the nineteenth 
century. The same idea on a finer scale has been 
used in tapestries for many centuries: In our 
home library, my wife found the example of 
Fig. 15 which was woven in the northern part 
of Norway about 1500; this shows the name of 
St. Thomas in a style imitating contemporary 



Figure 14. Adjusting the letters to coarser rasters. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

97 










changed the formulas by making sure that both 
r and s are always 1/2 or greater unless spe¬ 
cial exceptions are made; furthermore I never 
let r or s exceed 4. Fig. 8 shows the spline 
curves obtained under the same conditions as 
Fig. 7, but with s set to 1/2 if the above 
formula calls for any smaller value. 

Using these techniques we obtain a system 
for drawing reasonably nice curves, if not the 
most pleasing ones, and it is especially good at 
circles. If the method gives the wrong tangent 
direction at some point, you can control this 
by specifying two points very close together 
having the desired slope. I have also included 
another way to modify the standard tangent 
directions, intended to make the system as 
good at drawing ellipses as it is at drawing 
circles: Before computing the splines I first 
shrink the entire figure in the vertical direc¬ 
tion by muliplying all the y coordinates by a 
given aspect ratio (normally 1); then the splines 
are calculated, and the resulting shrunken 
curves are stretched out again by dividing the 
y coordinates by the aspect ratio. 



Figure 7. Spline curves with 0 = 0° (5 ) 120° 
and </> = 60 f 



Figure 8. Same as Figure 7 but adjusted so 
that r' = min04,r), s'= min (’/4,s). 


APPLICATION TO TYPE DESIGN. 

Now let’s take a closer look at what can be 
drawn with a mathematical system like this. I 
suppose the natural thing to show you would 
be the letters A to Z; but since this is a math¬ 
ematical talk, let’s consider the digits 0 to 9 
instead. (See Fig. 9.) Incidentally, the way I 
have arranged these numerals illustrates a 
fundamental distinction between a mathema¬ 
tician and a printer: the mathematician puts 0 
next to the 1, but the printer always puts it 
next to the 9. 

Most of these digits are drawn by using 
another idea taken from the history of typo¬ 
graphy, namely to imitate the calligrapher who 
uses pen and ink. Consider first the numeral ‘3’, 
for example: The computer program which 
drew this symbol in Fig. 9 can be paraphrased 



Figure 9. Digits 0 to 9 drawn by the META 
FONT programs. (Further refine¬ 
ments to these characters will be 
made before the font has its final 
form.) 

as follows. “First draw a dot whose left bound¬ 
ary is 1/6 of the way from the left edge to the 
right edge of the type and whose bottom 
boundary is 3/4 of the way from the top to the 
bottom of the desired final shape. Then take a 
hairline pen and, starting at the left of the dot, 
draw the upward arc of an ellipse; after 
reaching the top, the pen begins to grow in 
width, and it proceeds downward in another 
ellipse in such a way that the maximum width 
occurs on the axis of the ellipse, with the right 
edge of the pen 8/9 of the way from the left 
edge to the right edge of the type. Then the pen 
width begins to decrease to its original size 
again as the pen traverses another ellipse taking 
it down to a position 48% of the way from 
the top to the bottom of the desired final 
shape. ...” 

Notice that instead of describing the bound¬ 
ary of the character, as the renaissance geo¬ 
meters did, my METAFONT system describes 
the curve traveled by the center of the pen, and 
the shape of this pen is allowed to vary as the 
pen moves. The main advantage of this ap¬ 
proach is that the same definition readily yields 
a family of infinitely many related fonts of 
type, each font being internally consistent. The 
change in pen size is governed by cubic splines 
in a manner analogous to the motion of the 
pen’s center. In order to define the 20 or so dif ¬ 
ferent type fonts used in various places in my 
books, I need for the most part to use only 
three kinds of pens, namely (i) a circular pen, 
used for example to draw dots and at the base 
of the numeral ‘7’; (ii) a horizontal pen, whose 
shape is an ellipse, the width being variable but 
the height being constantly equal to the height 
of a hairline pen - such a pen is used most of 
the time, and in particular to draw all of the 
numeral ‘3’ except for the dots; (iii) a vertical 
pen, analogous to the horizontal one, used for 
example to draw the strokes at the bottom of 
the ‘2’ and at the top of the ‘5’ and the ‘7’. 
For the fonts I am using, it was not necessary 
to use an oblique pen (i.e., an ellipse that is 
tilted on its side) except to make the tilde 
accent for Spanish n’s; but to produce fonts of 
type analogous to Times Roman, an oblique 
pen would of course be used. If this system 
were to be extended to Chinese and Japanese 
characters, I believe it would be best to add 
another degree of freedom to the pen’s motion, 
allowing an elliptical pen shape to rotate as well 
as to change its width. 


The digit ‘4’ shows another aspect of the 
METAFONT system. Although this character 
is fairly simple, consisting entirely of straight 
lines, notice that the thick line has to be cut 
off at an angle at the top. In order to do this, 
there are erasers as well as pens. First the 
computer draws a thick line all the way from 
top to bottom, like the upper case letter ‘I’, 
then it takes an eraser which erases everything 
to its left and comes down the diagonal stroke, 
then it takes a hairline pen and finishes the 
diagonal stroke. Such an eraser is used also at 
the top of the ‘1’ and the bottom of the V, 
etc. 

Sometimes a simple spline seems to be in¬ 
adequate to describe the proper growth of pen 
width, so in a few cases I had to resort to de¬ 
scribing the left and right edges of the pen as 
separate curves, to be filled in afterwards. This 
occurs for example in the main stroke of the 
numeral ‘2’, whose edges are defined by two 
splines having a specified tangent at the bottom 
and having vertical slope at the right of the 
curve. 

With these techniques I found that it was 
possible to define a decent-looking complete 
font, containing a total of 128 characters, in 
about two months, although it will still be 
necessary of course to do fine tuning when 
more trail pages are typeset. (See Fig. 10.) The 
most difficult symbol by far, at least for me, 
was the letter S ( and the numeral 8, which uses 
the same procedure); in fact I spent three days 
and nights without sleep, trying to make the S 
look right, before I got it. At one point I even 
felt it would be easier to rewrite all my books 
without using any S’s! After the first day of 
discouraging trials, I showed what I had to my 
wife, and she said, “Why don’t you make it S- 
shaped?” 

0ABCDEFGHIJKLMN 

OPQRSTUVWXYZ[“]- 

‘abcdefghijklmno 

pqrstuvwxyzfffiflffiffl aelihoe/ELfXCE 
0123456789:;<=>? * 

r<;G%ic'()*+,-./ rA©Asnr:r<t>nij 

Figure 10. A font of 128 characters defined 
by METAFONT with standard 
pen settings. (The accent charac¬ 
ters will be appropriately raised 
and centered over other letters 
when used by TEX.) 

Fig. 11 shows how this problem was solved 
by Pacioli, Torniello, Palatino, and the French 
academicians; but the letter doesn’t look like a 
modern S. Furthermore I think the engraver of 
the French S cheated a little in rounding off 
some lines near the middle — perhaps he used a 
French curve. With my wife’s assistance, I 
finally came up with a satisfactory solution, 
somewhat like those used in the sixteenth 
century but generalized to ellipses. Each 
boundary of each arc of my S curve is com¬ 
posed of an ellipse and a straight line, deter¬ 
mined by (i) the locations of the beginning and 


Page 14 

98 


Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 






ending points, (ii) the slope of the straight line, 
and (iii) the desired left extremity of the 
curve. It took me three hours to derive the 
necessary formulas, and I think Newton and 
Leibnitz would have enjoyed working on this 
problem. Fig. 12 shows various trial S’s drawn 
by this scheme with different slopes; I hope 
you prefer the middle one, since it is the one 
I am actually using. 



Figure 12 Different S's obtained by varying 
the slope in the middle. (This 
shows 1/2, 2/3, 3/4, 1, 4/3, 3/2, 
and 2 times the "correct" slope.) 


FAMILIES OF FONTS. 

To extend the METAFONT system, one 
essentially writes a computer program for the 
description of each character, in a special lan¬ 
guage intended for describing pen and eraser 
strokes. My colleage R. W. Gosper has observed 
that this is the opposite of Sesame Street: 
Instead of ‘This program was brought to you 
by the letter S” we have ‘This letter S was 
brought to you by a program.” There are about 
20 parameters to the program, telling how big a 
hairline pen is, how wide it whould be when 
drawing straight or curved stem lines, and 
specifying the sizes and proportions of various 
parts of the letters (the x-height, the heights of 
ascenders and descenders, the set width, the 
length of serifs, and so forth). By changing 


these parameters, we obtain infinitely many 
different styles of type, yet all of them are 
related and they seem to blend harmoniously, 
with each other. 

For example, Fig. 13 shows some of the 
possibilities. In Fig. 13a we have a conventional 
“modem” font in the tradition of Bodoni and 
Bell and “Scotch Roman”. Then Fig. 13b 
shows a corresponding boldface, in which the 
hairlines are slightly larger and the stem lines 
are substantially wider. By making the hairlines 
and stem lines both the same size, and setting 
the serif length to zero, we obtain a sans serif 
font as shown in Fig. 13c. All of these examples 
are produced with the same programs defining 
the letter shapes; only the parameters are being 
varied. Actually the particular font shown in 
Fig. 13c will have a different style of g, because 
the descenders are especially short in this font, 
but I have shown this “g” in order to illustrate 
the parametric variations. Fig. 13d shows a 
boldface sans-serif style in which the pen has 
an oval shape wider than it is tall; I find this 
style especially pleasing, particularly because it 
came out by accident — I designed the 
programs only so that two or three different 
fonts would look right, all the others are free 
bonuses, and I had no idea that this one would 
be so nice. 

With a suitable setting of the parameters, 
we can even imitate a typewriter with its 
fixed width letters, as shown in Fig. 13e. There 
is also a provision to slant the letters as in Fig. 
13f; here the pen position is varied, but the 
actual shape of the pen is not being slanted, 
so circles remain circles. 

Another setting of the parameters leads to 
caps and small caps as shown in Fig. 13g; small 
caps are drawn with the pens and heights or¬ 
dinarily used for lower case letters, but con¬ 
trolled by the programs for upper case letters. 
Fig. 13h shows something printers have never 
seen before: this is what happens when you 
draw lower case letters in the small caps style, 
and we might call it “small lower case”. It 
actually turns out to be one of the most 
pleasing fonts of all, except that the dots are 
too large. 

Finally, Fig. 13i illustrates the variations 
you can get by giving weirder settings to the 
parameters. 

When I was an assistant professor at Caltech, 
the math department secretaries used to send 
occasional “crank” visitors to my office, and 
I recall one time when a man came to ask if 
anybody had calculated the value of 7 T “out to 
the end” yet. I tried to explain to him that 7T 
had been proved irrational, but this didn’t seem 
to sink in, so finally I showed him a table of 7T 
to 100,000 decimals and told him that the 
expansion hadn’t ended yet. I wish I could have 
had my typographical system ready at that 
time, so that I could have shown him Fig. 14! 

Fig. 14 illustrates another principle of type 
design, namely that different sizes of type in 
the same style are not simply obtained from 
each other by optical transformations. The 
heights and widths and pen stroke sizes change 
at different rates, and a good typographer will 


Number 43 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

99 
















Figure 15. Lettering equivalent to this raster pattern appears in a Norwegian tapestry from 
Gildeskaal old church, woven about 1500 [22, p. 116]. 


calligraphy, and I’m sure that examples which 
antedate the printing press can be found 
elsewhere. 

Fig. 16 shows how METAFONT produces 
the same letters from the same parameters but 
with different degrees of resolution in the 
raster. This digitalization process itself is 
considerably more difficult than it may seem at 
first, and some nontrivial mathematical 
concepts were needed before I could produce 
satisfactory results. In the first place, it is not 
sufficient merely to draw or to imagine drawing 
the character with infinite precision and then to 
“round” it by blacking in all the squares on 
graph paper that are sufficiently dark in the 
true image. One of the reasons this fails is that 
the three stem lines of the m, for instance, 
might be located in different relative positions 
with respect to the grid, so that the first stroke 
might round to three units wide (say) and the 
second might round to four. This would be 
quite unsatisfactory, as the eye quickly picks 
up such a variation in thickness, but it is 
avoided by METAFONT since the pen itself is 
first digitized and then the same digitized pen is 
used for all three strokes. Another problem is 
that those three strokes should be equally 
spaced; it would look bad if there were seven 
units between the first two and eight units 
between the last two, so the program for ‘m’ 
needs to round its points in such a way that 
this doesn’t happen. 


The process of digitizing the pen is not 
trivial either. Suppose, for example, we want a 
circular pen that is 2 raster units wide; the 
appropriate pen is clearly 2X2 square, which 
is the closest to a circle that we can come at 
this low degree of resolution. Now notice that 
we can’t center a 2 X 2 square on any particular 
square, since none of the four squares is at its 
center; the same problem arises whenever we 
have to deal with a pen having even dimensions. 
One way to resolve this would be to insist on 
working only with odd numbers, but this would 
be far too limiting; so METAFONT uses a 
special rounding rule for the position of the 
pen’s center. In general, suppose the pen is an 
ellipse of integer width w and integer height h; 
then if the pen is to be positioned at the real 
coordinates (x, y), its actual position on the 
discrete grid is taken to be 

(Lx -6 (w) J,|_y-5 (h) J) 
where L x J denotes the greatest integer less 
than or equal to x, and 6 (even) = %, 6 (odd) = 
0. The pen itself, if positioned at the origin, 
would consist of all integers (x, y) which 
satisfy 

^ 2(x-8(»)) j ’ + ^ 2(y-6Ql)) ^ ’<!+„„ ^ 28 (w) 2*(h)^ 1 

This formula-which incidentally is not the 
first one I tried-ensures that the discrete pen 
will indeed be w units wide and h units high. 


when w and h are positive integers. Fig. 17 
shows the pens obtained for small w and h. 

Still another problem appears when we want 
curved lines to look right. Fig. 18(a) shows a 
semicircle of radius 10 units, drawn with a pen 
of height 1 and width 3, when the right 
boundary of the pen falls exactly at an integer 
point; the pen sticks out terribly in one place. 
On the other hand if this right boundary falls 
just shy of an integer point, we get the curve in 
Fig. 18(b) which looks too flat. The ideal 
occurs in Fig. 18(c), when the right boundary 
occurs exactly midway between integers. There¬ 
fore the METAFONT programs adjust the 
location of curves to the raster before actually 
drawing the curves, forcing the favorable 
situation of Fig. 18(c); the actual shape of each 
letter changes slightly in order to adapt that 
letter to the desired raster size in a pleasant 
way. 

There is yet another problem, which arises 
when the pen is growing in such a way that the 
edges of the curve it traces would be mono¬ 
tonic if the pen were drawn to infinite preci¬ 
sion, yet the independent rounding of pen 
location and pen width causes this mono ton¬ 
icity to disappear. The problem arises only 
rarely, but when it does happen the eye 
immediately notices it. Consider, for example, 
the completely linear situation in Fig. 19, 
where each decrease by one unit in y is 
accompanied by an increase of .3 units in x and 
an increase of .2 units in the pen width w; the 
intended pen height is constant and very small, 
but in the discrete case the pen height is taken 
to be 1. The lightly shaded portion of Fig. 19 
shows the true shape intended, but the darker 
squares show that the digitized form yields a 
non-monotonic left boundary. METAFONT 
compensates for this sort of problem by 
keeping track of the desired boundaries when 
the pen width is varying, plotting points twice 
(e.g. plotting both (x, y) and (x-1, y) ) when 
necessary to keep the boundary correct. In 
other words, the idea of rounding the pen 
location and the width independently is some¬ 
times effectively abandoned. 

The final digitization problem that I needed 
to resolve was to make the left half of an “O” 
look like the mirror image of its right half, to 
make a left parenthesis look like the mirror 
image of a right parenthesis, and so on. This 
was done by having the METAFONT programs 
in such cases choose a center point that was 
either exactly at an integer or an integer plus Vi, 
and to introduce dual rounding which could be 
proved to produce exactly the correct 
symmetry properties. 

ALTERNATIVE APPROACHES 

As I have said, I believe the METAFONT 
system is successful as a way to define letters 
and other symbols, but probably even better 
procedures can be devised with further re¬ 
search. Some of the limitations of my cubic 
splines are indicated in Fig. 20. Part (a) of that 
illustration shows a five-pointed star and the 
word “mathematics” in an approximation to 


mathematics 

mathematics 

mathematics 

mathematics 

mathematics 


■i 

i 


••***ii 

•eattu 


Figure 16. Adjusting the letters to 
coarser rasters. 


Figure 17. Discrete "elliptical" pens of 

small integer width and height. 


Number 43 Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 Page 17 

100 










the optimum curve will have linearly changing 
curvature of the form ax + by + c at point 
(x, y), and he has suggested choosing the 
constants by taking b/a= (y 2 - y 1 )/(x 2 -xj) 
between (xj, yi) and (x^, yj), and requiring 
that slope and curvature be continuous across 
endpoints. Such an approach seems to require 
considerably more computation than the cubic 
splines recommended here, but it may lead to 
better curves, e.g. satisfying the extension- 
ality property. 

Another interesting approach to curve¬ 
drawing, which may be expecially useful 
for stimulating handwriting, is a “filtering” 
method suggested to me recently by Michael 
S. Paterson of the University of Warwick (un¬ 
published). To get a smooth curve passing 
through points z^, assuming that these points 
my own handwriting, done with straight line writing is inherently un-beautiful, there are still are about equally spaced on the desired curve, 

segments so that you can see exactly what the some kinks in Fig. 20(e) that could probably be one simply writes 

data points are that I fed to my spline routine, ironed out if a different approach were taken. z(t) = 2(— l)^Z]jf(t—k)/2(—l) k f(t—k) 
Part (b) shows the way my handwriting might The most interesting alternative from a k k 

look when I get older; it was obtained by mathematical standpoint seems to be tq find a where f(t) is an odd function of order t as 

simply setting r=s=2inallthe spline seg- cuive of given length that minimizes the t->0, decreasing rapidly away from zero, e.g. 

ments, therefore making clear what tangent integral of the square of the curvature with f(t) = csch t = 2/(e l - e _t ). 
angles are prescribed by the system. Part (c) respect to arc length. This integral is propor- 

is somewhat more disciplined, it was obtained tional to the strain energy in a mechanical — 

by putting r = s = Vi everywhere. Fig. 20(d) is spline (in other words, a thin slat or beam) of 

like Fig. 20(c) but drawn with a combined the given length, going through the given 

pen-and-eraser. Such a combination can lead points, so it seems to be an appropriate 

to interesting effects, and the star here is my quantity to minimize. E. H. Lee and G. E. w 

belated contribution to America’s bicentennial. Forsythe [31] have reviewed early work on 

When the general formulas for cubic splines this variational problem, and shown that it is 

are used as I explained above, we get Fig. 20(e) equivalent to having the spline at equilibrium 

in which the star has become a very good with forces applied only at the given points of 

approximation to a circle (as I said it would), support. The Norwegian mathematician Evan on 

In tliis illustration the pen is thicker and has a Mehlum [36] has shown that if we specify a 

slightly oblique stress. Although my hand- fixed arc length between consecutive points, 





Figure 18. Difficulties of rounding an arc properly. (Three circles of radius 10 drawn with a 1 x 
3 pen.) 



Pen width Rounded width 
and location and location 
(3.5, 0.5,10.5) (3, 0,10) j 

(3.7, 0.8, 9.5) (3, 0, 9) 

(3.9, 1.1, 8.5) (3, 1, 8) 

(4.1, 1.4, 7.5) (4, 0, 7) 1 

(4.3, 1.7, 6.5) (4, 1, 6) 

(4.5, 2.0, 5.5) (4, 1, 5) 

(4.7, 2.3, 4.5) (4, 1, 4) 

(4.9, 2.6, 3.5) (4, 2, 3) 

(5.1, 2.9, 2.5) (5, 2, 2) 

(5.3, 3.2, 1.5) (5, 3, l) 

(5.5, 3.5, 0.5) (5, 3, 0) 



Figure 20. Examples of the cubic splines ap¬ 
plied to sloppy handwriting. 


I have not had time yet to experiment with 
Paterson’s method or to attempt to harness 
it for the drawing of letters. It is easy to see 
that the derivative z'(zk) = f( l)( z k+t -zk_ j) 
- f(2)(zjj +2 -zjj.j) + ... lies approximately 
in the direction of zj, +1 - zj c _ 1 . 


Figure 19. Failure of monotonicity due to independent rounding. (Rounding takes (w,x,y) into 
(Lwj, Lx-S (lwj) ,LYj) •) 


Page '18 


Dr. Dobb's Journal of Computer Calisthenics 8c Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

101 





RANDOMIZATION. 


BIBLIOGRAPHY. 


In conclusion, I’d like to report on a little 
experiment that I did with random numbers. 
One might complain that the letters I have 
designed are too perfect, too much like a 
computer, so they lack “character.” In order 
to counteract this, I can build a certain amount 
of randomness into the choices of where to put 
the pen when drawing each letter, and Fig. 21 
shows what happens. The coordinates of key 
pen positions were chosen independently with 
a normal distribution and with increasing 
standard deviation, so that the third example 
has twice as much standard deviation as the 
second, the fourth has three times as much, and 
so on. Note that the two m’s on each line 
(except the first) are different, and so are the 
a’s and the t’s, since each letter is randomly 
drawn. 

After the deviation gets sufficiently large 
the results become somewhat ludicrous; and I 
don’t want people to say that I ended this 
lecture by making a travesty of mathematics. 
So let us conclude by looking at Fig. 22, which 
shows what is obtained in various fonts when 
the degree of randomness is somewhat 
controlled. I think it can be said that the letters 
in this final example have a warmth and charm 
which makes it hard to believe that they were 
really generated by a computer following 
strict mathematical rules. Perhaps the reason 
the printing of mathematics looked so nice in 
the good old days was that the fonts of type 
were imperfect and inconsistent. 

SUMMARY. 

I’d like to summarize now by pointing out 
the moral of this long story. My experiences 
during the last few months vividly illustrate 
the fact that there are plenty of good mathe¬ 
matical problems still waiting to be solved, 
almost everywhere you look-especially in 
areas of life where mathematics has rarely been 
applied before. Mathematicians can provide 
solutions to these problems, receiving a double 
payoff-namely the pleasure of working out 
the mathematics, together with the apprecia¬ 
tion of the people who can use the solutions. 
So let’s go forth and apply mathematics in 
new ways. 

ACKNOWLEDGMENTS. 

I would like to thank my wife Jill for the 
many important suggestions she made to me 
during critical stages of this research; also Leo 
Guibas and Lyle Ramshaw for the help they 
provided in making illustrations at Xerox Palo 
Alto Research Laboratories; also Lester 
Earnest, Michael Fischer, Frank Liang, Tom 
Lyche, Albert Meyer, Michael Paterson, Michael 
Plass, Bob Sproull, Jean E. Taylor, and Hans 
Wolf, for helpful ideas and stimulating discus¬ 
sions and correspondence about this topic; also 
Gordon L. Walker, for verifying my conjectures 
about the printing history of the Transactions 
and for providing me with additional back- 


mathematics 

' . :i r . 

mathematics 

mathematics 

■ I r_ , -i 4--, 

mathematics 

math emat ics 

mathematics 

mathematics 

mathematics 

math emat ice 

, ; 

mathe/naticp 

mathematics 

mathematics 

Figure21. Increasingly random pen posi¬ 
tions; 0 = o. i,..., . 


mathematics 

mathematics 

mathematics 

mathaiMtiQS 

Figure 22. A bit of randomness introduced 
into various styles of type. 

ground information; also Prof. Dirk Siefkes for 
his help in acquiring Figs. 4(c) and 11(c), and 
the Berlin Kunstbibliothek for permission to 
publish them; and to Andre Jammes for permis¬ 
sion to publish Figs. 6 and 11(d). 


(I have included here several articles not 
referenced in the main text, namely a discus¬ 
sion of publishing at the American Institute 
of Physics [37]; some experiments in type¬ 
setting physics journals with the Bell Labs 
system [32], [7]; computer aids for technical 
magazine layout and editing together with a 
brief proposal for a standard typesetting 
language [11]; reports about early computer 
programs for character generation and mathe¬ 
matics composition [23], [30], [34], [35], 
[40], [46]; a description of the mathematics 
a traditional printer needs to know [9]; three 
standard references on the typesetting of 
mathematics [14], [47], [50]; some fonts 
of type and special characters designed by the 
American Math. Society [39]; a recent 
approach to mathematical definition of tradi¬ 
tional type faces based on conic sections [15]; 
a proposal for a new way to control the spacing 
between letters based on somewhat mathe¬ 
matical principles [28]; and two purely mathe¬ 
matical papers inspired by typography [13], 
[ 21 ].) 

1. A. V. Aho, S. C. Johnson, and J. D. 
Ullman, “Typesetting by ACM considered 
harmful,” Communications of the ACM 
18(1975), 740. 

2. American Mathematical Society, “Devel¬ 
opment of the Photon for efficient mathe¬ 
matical composition,” Final report 
May 10, 1965), National Science Founda¬ 
tion grant G-21913; NTIS number 
PB168627. 

3. American Mathematical Society, “Devel¬ 
opment of computer aids for tape-control 
of photocomposing machines,” Report 
No. 2 (July 1967), “Extensions of the 
system of preparing a computer-processed 
tape to include the setting of multiple line 
equations,” National Science Foundation 
grant GN-533; NTIS number PB175939. 

4. American Mathematical Society, “Devel¬ 
opment of computer aids for tape-control 
of photocomposing machines,” Final 
report. Section B (August 1968), “A 
system for computer-processed tape 
composition to include the setting of 
multiple line equations,” National Science 
Foundation grant GN-533; NTIS number 
PB179418. 

5. American Mathematical Society, “Devel¬ 
opment of computer aids for tape-control 
of photocomposing machines,” Final 
report, Section C (January 1969), “Im¬ 
plementation, hardware, and other sys¬ 
tems,” National Science Foundation grant 
GN-533;NTIS number PB182088. 

6. American Mathematical Society, “To 
complete the study of computer aids for 
tape-control of composing machines by 
developing an operating system,” Final 

report, no. AMATHS-CAIDS-71-0 (April 

1971), National Science Foundation grant 
GN-690; NTIS number PB200892. 

7. American Physical Society, “APS tests 
computer system for publishing opera- 


Number 43 

102 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 



tions,” Physics Today 30, 12 (December 
1977), 75. 

8. Donald M. Anderson, “Cresci and his 
capital alphabets,” Visible Language 4 
(1971), 331-352. 

9. J. Woodard Auble, Arithmetic for Printers, 
second edition (Peoria, Ill.: Bennett, 
1954). 

10. Michael P. Barnett, Computer Type¬ 
setting: Experiments and Prospects (Cam¬ 
bridge, Mass.: M.I.T. Press, 1965). 

11. Robert W. Bemer and A. Richard Shriver, 
“Integrating computer text processing 
with photocomposition,” IEEE Trans, on 
Prof. Commun. PC-16 (1973), 92-96. 
This article is reprinted with another type¬ 
face and page layout in Robert W. Bemer, 
“The role of a computer in the publication 
of a primary journal,” Proc. IFIPS Nat. 
Comput. Conf. 42, Part II (1973), M16- 
M20. 

12. Peter J. Boehm, “Software and hardware 
considerations for a technical typesetting 
system,” IEEE Trans, on Prof. Commun. 
PC-19 (1976), 15-19. 

13. J. A. Bondy, “The ‘graph theory’ of the 
Greek alphabet,” Graph Theory and Ap¬ 
plications, Y. Alavi et al., eds. (Berlin: 
Springer, 1972), 43-54. 

14. Theodore William Chaundy, Percy Regi¬ 
nald Barrett, and Charles Batey, The 
Printing of Mathematics (Oxford: Oxford 
University Press, 1954). 

15. P. J. M. Coueignoux, “Generation of 
Roman Printed Fonts,” Ph.D. thesis, 
Dept, of Electrical Engineering, Mass. Inst, 
of Technology (June, 1975). 

16. Giovanni Francesco Cresci Milanese, 
Essemplare de Piv Sorti Lettere (Rome, 
1560). Also edited and translated by 
Arthur Sidney Osley (London, 1968). 

17. T. L. DeVinne, The Practice of Typog¬ 
raphy: Modem Methods of Book Compo¬ 
sition (New York: Oswald, 1914). 

18. Albrecht Durer, Underweysung der Mes- 
sung mit dem Zirckel und Richtscheyt 
(Nuremberg, 1525). An English transla¬ 
tion of the section on alphabets has been 
published as Albrecht Durer, Of the Just 
Shaping of Letters, R. T. Nichol, trans. 
(Dover, 1965). 

19. Felice Feliciano Veronese, Alphabetum 
Romanum, Giovanni Mardersteig, ed. 
(Verona: Editiones Officinae Bodoni, 
I960). 

20. Frederic W. Goudy, Typologia: Studies in 
Type Design and Type Making with Com¬ 
ments on the Invention of Typography, 
the First Types, Legibility and Fine 
Hinting (Berkeley, Calif.: Univ. of Cali¬ 
fornia Press, 1940). 

21. F. Harary, “Typographs,” Visible Lan¬ 
guage 7 (1973), 199-208. 

22. Roar Hauglid, Randi Asker, Helen Engel- 
stad, and Gunvor Traetteberg, Native Art 
of Norway (Oslo: Dreyer, 1965). 

23. A. V. Hershey, “Caligraphy for com¬ 
puters,” NWL Report No. 2101 (Dahlgren, 
Va.: U.S. Naval Weapons Laboratory, 
August 1967); NTIS number AD662398. 


24. Andre Jammes, La Reforme de la Typog¬ 
raphy Royale sous Louis XIV (Paris: 
Paul Jammes, 1961). 

25. Paul E. Justus, ‘There is more to type¬ 
setting than setting type,” IEEE Trans, 
on Prof Commun. PC-15 (1972), 13-16. 

26. Alan C. Kay, “Microelectronics and the 
personal computer,” Scientific American 
237, 3 (September 1977), 230-244. 

27 Brian W. Kemighan and Lorinda L. 
Cherry, “A system for typesetting mathe¬ 
matics,” Communications of the ACM 18 
(1975), 151-157. 

28. David Kindersley, Optical Letter Spacing 
for New Printing Systems (London: 
Wynkyn de Worde Society, 1976). 

29. Donald E. Knuth, ‘Tau Epsilon Chi, a sys¬ 
tem for technical text,” manuscript in 
preparation. 

30. Dorothy K. Korbuly, “A new approach to 
coding displayed mathematics for photo¬ 
composition,” IEEE Trans, on Prof 
Commun. PC-18 (1975), 283-287. 

31. E. H. Lee and G. E. Forsythe, “Varia¬ 
tional study of nonlinear splines,” SIAM 
Review 15 (1973), 120-133. 

32. M. E. Lesk and B. W. Kemighan, “Com¬ 
puter typesetting of technical journals on 
UNIX,” Computing Science Tech. Report 
44, (Murray Hill, N.J.: Bell Laboratories, 
June, 1976). 

33. Giovanni Mardersteig, The Alphabet of 
Francesco Tomiello (1517) da Novara 
(Verona: Officina Bodoni, 1971). 

34. M. V. Mathews and Joan E. Miller, “Com¬ 
puter editing, typesetting, and image 
generation,” Proc. AFIPS Fall Joint 
Computer Conf. 27 (1965), 389-398. 

35. M. V. Mathews, Carol Lochbaum, and 
Judith A. Moss, ‘Three fonts of com¬ 
puter drawn letters,” Communications of 
the ACM 10 (1967), 627-630. 

36. Even Mehlum, “Nonlinear Splines,” in 
Computer Aided Geometric Design, 
Robert E. Barnhill and Richard F. Riesen- 
feld, eds. (New York: Academic Press, 
1974), 173-207. 

37. A. W. Kenneth Metzner, “Multiple use and 
other benefits of computerized pub¬ 
lishing,” IEEE Trans, on Prof. Commun. 
PC-18 (1975), 274-278. 

38. Joseph Moxon, Regulae Trium Ordinum 
Literarum Typographicarum, or the Rules 
of the Three Orders of Print Letters: viz. 
the l Roman, ltalick, English | Capitals and 
Small; Shewing how they are compounded 
of Geometrick Figures, and mostly made 
by Rule and Compass (London, Joseph 
Moxon, 1676). 

39. Phoebe J. Murdock, “New alphabets and 
symbols for typesetting mathematics,” 
Scholarly Publishing 8 (1976), 44-53. 
Reprinted in Notices Amer. Math. Soc. 
24(1977), 63-67. 

40. Nicholas Negroponte, “Raster scan ap¬ 
proaches to computer graphics,” Com¬ 
puters and Graphics 2 (1977), 179-193. 

41. Wolfgang A. Ocker, “A program to hy¬ 
phenate English words,” IEEE Trans, on 
Prof Commun. PC-18 (1975), 78-84. 


42. Luca Pacioli, Divina Proportione, Opera a 
tutti glingegni perspicaci e curiosi neces- 
saria Ove ciascun studioso di Philosophia, 
Prospectiva, Pictura, Sculptura: Architec¬ 
ture: Musice: altre Mathematice: suavis- 
sima: sottile: e admirabile et doctrina 
consequira: e delectarassi: con varie 
questione de secretissima scientia (Venice, 
1509). 

43. Giovanbattista Palatino Cittadino Ro¬ 
mano, Libro Primo del le Lettere Maiu- 
scole Antiche Romane (unpublished), 
Berlin Kunstbibliothek MS. OS5280. 
Some of the individual pages are dated 
1543, 1546, 1549, 1574, or 1575. See 
James Wardrop, “Civis Romanus Sum: 
Giovanbattista Palatino and his circle,” 
Signature, n.s. 14 (1952), 3-39. 

44. Paul A. Parisi, “Composition innovations 
of the American Society of Civil Engi¬ 
neers,” IEES Trans, on Prof Commun. 
PC-18 (1975), 244-273. 

45. R. G. D. Richardson, ‘The twenty-ninth 
annual meeting of the Society,” Amer. 
Math. Soc. Bulletin 29 (1923), 97-116. 
(See also vol. 28 (1922) pp. 234-235, 
378 for comments on the special Trans¬ 
actions volume, and pp. 2-3 of vol. 28 
for discussion of deficits due to increased 
cost of printing.) 

46. Glenn E. Roudabush, Charles R. T. Bacon, 
R. Brace Briggs, James A. Fierst, Dale W. 
Isner, and Hiroshi A. Noguni, ‘The left 
hand of scholarship: Computer experi¬ 
ments with recorded text as a communica¬ 
tion media,” Proc. AFIPS Fall Joint 
Computer Conf. 27 (1965), 399-411. 

47. Ellen E. Swanson, Mathematics Into Type 
(Providence, R.I.: Amer. Math. Soc., 
1971). 

48. Francesco Tomiello, Opera del Modo de 
Fare le Littere Mauiscole Antique (Milan, 
1517). 

49. Geofroy Tory, Champ Fleury (Paris, 
1529). Also translated into English and 
annotated by George B. Ives (New York: 
GrolierClub, 1927). 

50. Karel Wick, Rules for typesetting mathe¬ 
matics, Tr. by V. Boublik and M. Hejlova 
(The Hague: Mouton, 1965). 

51. Hermann Zapf, About Alphabets: Some 
Marginal Notes on Type Design (Cam¬ 
bridge, Mass.: M.I.T. Press, 1970). 



Page 20 


Dr. Dobb's Journal of Computer Calisthenics 8< Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

103 




QYHVIROT * Generating Symbol Table 

3I1UDUL. Alpha Listing on the Hg 


BY WILLIAM W. MOSS accessory data can follow each element of the string table 

1507 Riverview Lane without affecting the sorting. In this program the symbol’s 

Bradenton, FL 33505 value follows the string itself. There is no software limit to 

the number of strings which can be sorted, as all variable in 
the sort routine are 16-bit values, and thus the real limitation 
Enclosed is a listing of the program ‘SYMBOL’ which is the addressing space of the hardware (65 kilobytes). The 

generates alphabetically sorted listings of the symbol table limit for the number of bytes which can be compared from 

from runs of the Heath H8 assembler. To utilize the program each string is 255 since one byte is allowed for this rvalue, 

one simply has to rim it immediately after a run of the as- The initialization requirements are given in the listing of the 

sembler (i.e., before another program writes over the assembler routine. At the end of the sort the table containing the pointer 

symbol table in memory). The table is then printed out in addresses to the string data has been rearranged such that the 

column order on the console. The symbol values are listed in first address is the pointer to the first alphabetically ranked 

offset octal format. Hexadecimal format can also be used if string, etc., down to the alphabetically lowest string, 

desired by substituting the routine ‘HEXOUT’ for ‘OCTOUT’ The program is written with standard Intel 8080 assembly 
and changing the code in the ‘PRINT’ routine as shown in the language mnemonics except for the use of four Heath DOS 
accompanying listing. calls (SCALL) which are defined as follows: 

Of general interest to Intel 8080 or Zilog Z80 users is 
the inclusion of a routine (SMSORT) which performs the (1) .SETTOP sets upper memory limit in HDOS. 

alphabetical sorting of variable length character strings utiliz- (2) .SCOUT outputs the character in register ‘A’ to con¬ 
ing the efficient Shell-Metzner algorithm. The speed of this sole. 

routine is further increased because the strings in the data (3) .ERROR prints out system error messages, 

table are not physically swapped during the sort: 2-byte (4) .EXIT returns to system monitor, 

pointers are exchanged instead. Because the string data table 

is unchanged and only the number of characters specified As an example of the program’s output the symbol table 
in the length byte are actually compared for sorting purposes, for the program itself is listed. 

ASM 

HDOS AS*-eML»ler Issue ♦104*02.OO. 

*. -SYMBOL 

00353 Strttemerit* Assembler! 

11924 Buies Free 
No Errors fie Lee ted 

sm»o! 

ERROR 000 O '57 FRRUR 044 044 READLBL 042.233 TABADDR 043.214 

, F >' I r 00O 000 I. Bl TAB 044.110 ROWCNT 043.251 USEC 043.040 

.SCOUT 000,002 NEWI.RL 04' 31 S.OMAY 040.324 USERFUA 042.200 

.SETTOR 000 052 NFWI J NF 043.24? SFTI 043.014 VAR T 044.0*4 

ALL DONE 044 07" NFXTIBl 042.310 SET 1 043.14? OARJ 044.074 

ASMTAB 075,134 NOMATCH "4^ 101 SFTL 043.02? VARK 044.100 

COLUMNS 000.004 Or TOUT 044,040 SETM 042.350 VARl 044.10 7 

t.OMP 043 0'4? POINT 04 4 SMSORT 042.340 VARM <'44 t"4 

i.KI P 000 017 POIMTAB 044.0*2 SPACES 044.027 VARN 044,106 

DEMHl. 043.20? PRINT 043.236 STROUT 043.332 

BIGOUT 044.04* READCHP 042.2 3'* SYMVAL 043.226 


SYMBOL TABI E SORTER AND PRINTER FOR HH ASSEMBLER HEATH ASM 1104.02.00. 

M|l! TAM W. MOSS - 1 JUNE. 1979 


* PROGRAM TO PRINT OUI AN ALPHABETICALLY SORTED SYMBOL TABLE FOLLOWING USE 

* OF THE HEATH H8 ASSEMBLER [VERSION t04.02.00J 

* 

♦ TO IISFJ ASSEMBLE AS USUAL WITH THE HEATH ASM PROGRAM. 

+ IMMEDIATELY AFTER THE ASSEMBLY IS COMPUTED RUN THIS PROGRAM. 

♦ THF SYMBOL TABLF IS THEN PRINTED ON THE CONSOLE 

♦ definitions: 

♦ 

"0.004 cm UMNS EGU 4 NUMBER OF COLUMNS DESIRED IN TABLE LISTING 

075.136 ASMTAB EQll 75136A FWA SYMBOL TABLE FOR ASM 104.02-00 

00O.012 CRLF EGU 10 CARRIAGE RETURN / LINE FEED CHARACTER IN HDOS 

04".?>4 S.OMAX EGU 40324A SYSTEM OVERLAY MA*IMUM SIZE 

"47. USERFUA EGU 42200A START OF USER MEMORY IN HDOS 

* HEATH DOS SYSTEM CALL DEFINITIONS: 



Number 43 

104 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 






000.052 
000.002 
000.057 
000.000 


.SETTOP EGU 
•SCOUT EQU 
.ERROR EQU 
.EXIT EQU 




04 ?. 200 
042.203 
042.205 


04.1 377 377 
377 052 
353 


* ROUTINE TO SET MAXIMAL USER HIGH MEMORY LIMIT IN HDOS 

LXI Hr-1 REQUEST ALL OF MEMORY (I.E. TOO MUCH) 


042.206 052 324 040 

042.211 001 012 000 

042.214 011 

042.215 315 207 043 

>4 20 m 052 

042.222 332 064 044 


S.OMAX 

HL 

= OVERLAY 

SIZE 


B. 10 

B 

HL 

= OVERLAY 

PLUS MARGIN 

FOR ERROR 

DEMHL 

HL 

= MAX MEM 

- OVERLAY - 

10 


.SETTOP REQUEST MEMORY LIMIT 

ERROR JUST IN CASE SOMETHING AMISS 


* ROUTINE TO MOVE AND RESTRUCTURE THE SYMBOL TABLE 

* FINAL STRUCTURE: 

* BEGIN AT 'LBLTAB'. 

* DATA UNIT FOR EACH SYMBOL t 

* (1) LENGTH OF SYMBOL CHARACTER STRING ('N') - 1 BYTE 

* (2) STRING DATA - 'N' BYTES 

* (3) SYMBOL'S VALUE - 2 BYTES - STORED IN LOW/HIGH FORM 


042.225 
042.230 
042.233 
042.234 
042.235 
042.237 
042.240 
042.241 
042.242 
042.245 
042.247 
042.250 
042.251 
042.252 
042.253 
042.254 
042.257 
042.260 
042.261 
042.262 
042.263 
042.264 
042.265 
042.266 
042.267 
042.270 
042.271 
042.272 
042.273 


041 136 075 
021 110 044 

325 

023 

016 000 
176 
107 
247 

312 276 042 

346 177 

022 

023 

043 

014 

270 

312 237 042 
043 
176 
022 
023 
043 
176 
022 
023 
043 
343 
161 
341 

303 233 042 


LXI 

LXI 

READLBL PUSH 
INX 
MV I 

READCHR MOV 
MOV 
ANA 
JZ 
ANI 
STAX 
INX 
INX 
I NR 
CMP 
JZ 
INX 
MOV 
STAX 
INX 
INX 
MOV 
STAX 
INX 
INX 
XTHL 
MOV 
POP 
JMP 


IF END OF TABLE REACHED 
CLEAR HIGH BIT 


HrASMTAB 
DtLBLTAB 

D SAVE ADDR FOR STRING BYTE COUNT 

D 

C»0 

ArM 

BfA SAVE CHARACTER 

A 

POINT IF END OF TABLE REACHED 

177Q CLEAR HIGH BIT 

D 

D 

H 

C 

B SEE IF HIGH BIT WAS SET 

READCHR 

H SKIP CODE BYTE 

A » M 

D SAVE LOW BYTE 


SAVE HIGH BYTE 


HI - ADDRESS FOR BYTE COUNT 
STORE BYTE COUNT 


* ROUTINE TO CONSTRUCT A POINTER TABLE FOR THE STRING DATA TABLE. 

* STRUCTURE AS FOLLOWS? 

* BEGIN AT < POINTAB'). 

* EACH TWO BYTF DATA ITEM IS THE ADDRESS OF THE START (JF DATA 

* FOR EACH SYMBOL IN THE STRING DATA TABLE. 


042.276 

341 



POINT 

POP 

H 1 

042.277 

160 




MOV 

Mr B 1 

042.300 

043 




INX 

H 

042.301 

042 

072 

044 


SHl.D 

F’OINTAB 

04?.304 

353 




XCHG 


042.305 

041 

110 

044 


LXI 

HfLBI TAB 

042.310 

176 



ne:xtlbl 

MOV 

A.M 

042.311 

247 




ANA 

A 1 

042.312 

312 

340 

042 


JZ 

ShSORT 

042.315 

1 75 




MOV 

AfL 

042.316 

022 




STAX 

D 

042.317 

023 




INX 

D 

042.320 

174 




MOV 

A.H 

042.321 

022 




STAX 

P 

042.322 

023 




INX 

t 

042.323 

00 3 




‘iNX 

B ( 

042.3' 4 

176 




MOV 

A.M 

042 3 5 

306 

003 



ADI 

3 i 

042.327 

205 




ADD 

L 

04? 330 

157 




MOV 

L. r A 

042.331 

1 7 4 




MOV 

ArH 

042.332 

316 

000 



AC I 

0 

042 534 

147 




MOV 

H » A 1 

4 

303 

310 

042 


JMP 

NFXTI BL 


HL = (LWA OF LBLT.iB) FI 

MARK END OF LBLTAB WITH 0 (DC 


END OF LBLTAB? 


COUNT LABELS IN TABLE 


LENGTH OF LABEL + 3 DATA BYTFS 


0 .ON ENTRY' 


* SHELL-METZNER STRING SORTING ROUTINE 

* ENTRY: BC NUMBER OF STRINGS TO BE SORTED 

* ('POINTAB') = START OF POINTER TABLE 

* POINTER TABLE MADE UP OF A SERIES OF 16 BIT ADDRESSES 

* POINTING TO THE POSITION IN THE DATA TABLE FOB I mCH 

+ OF THE ITEMS TO BE SOPTED. 

* DATA TABLE STRUCTURE• 

* FTRST BYTF = LENGTH OF STRING 

* FOI LOWING BYTES - STRING CHARACTERS 

* BYTES BEYOND SPECIFIED LENGTH ARE IGNORED 

* EXIT? POINTER TABLE REARRANGED TO POINT TO STRINGS IN ALPHABETICAL ORDER. 

* STRING DATA TABLE IS UNCHANGED- 

* VARN - NUMBER OF STRINGS SORTED. 


04? <40 

i ma 



SHSORT 

MOV 

042.<41 

151 




MOV 

■•A? 34'’ 

042 

106 

044 


SHI D 

042,345 

042 

104 

044 


SHLD 

•"'4 2 . 350 

05? 

.104 

044 

SFTM 

l HL D 

. 353 

1 74 




MOV 

04? 354 

747 




ANA 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

105 



04°» 355 

03 7 




RAR 



04 2,356 

1 47 




MOV 

Hr A 


042.357 

175 




MOV 

ArL. 


04 2.360 

037 




RAR 



04''. 5At 

157 




MOV 

L » A 


042.362 

04? 

104 

044 


SHI D 

VARM 

VARM - VARM / 2 

04? 365 

>64 




ORA 

H 


04 j . 3/.A 

31? 

236 

043 


JZ 

PR INI 

IF END OE SORT 

042 ! '1 

041 

001 

000 


LXI 

Hr i 


042,574 

04' 1 

CV7/S 

044 


SHL 0 

VAR J 

VARJ - 1 

042 177 

052 

106 

044 


L HI D 

VARN 


'•4 5.00: 

45 3 




XCHG 



043 003 

052 

104 

044 


LHLD 

VAPM 


04 S •••■■ 

315 

,'07 

043 


CA1 I 

DEMHL 


04 <. 011 

04? 

100 

044 


shi, n 

VARK 

VARK -= VARN - VARM 

O 45 •Ot4 

05? 

0 76 

044 

SET I 

1 HID 

VAR 1 


043,03 * 

04? 

r> ? 4 

044 


SHL D 

VAR T 

VARI - VARJ 

043,0? 

05 ? 

074 

044 

SETL 

LHLD 

VAR 1 


043.025 

353 




XCHG 



04 • .026 

7>5? 

104 

044 


LHLD 

VARM 


044 031 

'• <1 




DAD 

D 


043.03? 

r*4? 

102 

044 


SHLD 

“AH 

VARL ^ VAR I + VARM 

043 035 

315 

226 

043 


CALL 

SYMVAL 

HL = STARI OF DATA POINTED BY VAKI 

, lA J , 

345 




PUSH 

H 


043.041 

052 

074 

044 


LHLD 

VARM 


043 044 

315 

226 

043 


CALI... 

SYMVAL 


04 04 

3?' 




POP 

D 


04 3.nso 

0 32 




1 DAY 

D 

A * CHAR COUNT POP STRING T VAR! 1 

04 

11.6 




MOV 

CrM 

C = CHAR COUNT FOP STRING TVAR 1 1 

04< 052 

271 




CMP 

r 


•>4 3 : O', 3 

365 




PUSH 

PSW 

'C' SFT IF LENSTRJNG CVAR11 LLN< 

• •43.054 

32? 

060 

04 * 


JNC 

USEC 


■ 05 

117 




MOV 

r»A 


043.060 

043 



USEC 

INX 

H 

C = LENGTH OF SHORTER STRING 

043.061 

023 




I NX 

n 

HL & DE POINT TO SI ART OF LABEL S 

04 i 06? 

03? 



COMP 

LDAX 

D 


043.063 

276 




CMP 

M 

COMPARE STRINGS 

043.064 

302 

101 

043 


JNZ 

NOMATCH 

TF NO MATCH 

043.06 7* 

0?3 




INX 

D 


043.070 

043 




INX 

H 


04 < 0 /I 

015 




DCR 

C 


043.07» 

302 

062 

043 


JNZ 

COMP 


043•075 

361 




POP 

PSW 

CHARACTERS THE SAME, SEE IP ONE SI 

04 3 . b «*6 

303 

to? 

04 3 


IMP 

NOMATCH ft 

043 10t 

341 



NOMATCH 

POP 

H 

CLEAR STACK 

043.1o» 

^ ?•> 

162 

043 


JNC 

SE r 1 

TF NO REARRANGEMEN1 REQUIRFD 





♦ SWITCH THE P 

•HNTFR ADDRESS AT (VARI> WITH THA> A( (VAKI 

04 < . 1 O'. 

052 

.. .1 

044 


LHL D 

VAKI 


043 ,H0 

315 

2'6 

...1 ^ 


CALL 

TABADDR 


043. i 1 \ 

345 




PUSH 

H 

STACK = POINTER DATA FOR lVART • 

04 3 114 

052 

102 

044 


LHLD 

VARL 


04 4 11/ 

315 

216 

043 


CALL 

1ABADDR 

HL - FOTNTFP DATA FOR (VARL' 

04 3 | >? 

321 




POP 

n 


04 3 » ! : 3 

03? 




LDAX 

D 


043 124 

107 




MOV 

B»A 


043 125 

176 




MOV 

A.M 


043.126 

02? 




STAX 

D 


044 1?7 

1.60 




MOV 

M • D 


04 < 1.30 

023 




INX 

D 


• *43 131 

043 




I NX 

H 


043.13? 

03? 




L DAX 

n 


04 { 133 

107 




MOV 

B, A 


043 - 134 

176 




MOV 

A.M 


043.135 

022 




STAX 

D 


043.1 <6 

160 




MOV 

M.B 






* SWITCH COMPI ETED 


043 137 

05? 

074 

044 


LHID 

VAR l 


043.142 

353 




XCHG 



043.143 

052 

104 

044 


LHLD 

VARM 


043.146 

315 

207 

043 


CALL 

DEMHL 


043.151 

042 

074 

044 


SHLD 

VAR I 

VARI * VARI - VARM 

043.154 

053 




DCX 

H 


043.155 

174 




MOV 

A. H 


043.156 

247 




ANA 

A 


043.157 

362 

022 

043 


JP 

SETL 

IF VARI >= 1 

043.162 

052 

076 

044 

SET J 

LHLD 

VARJ 


043.165 

043 




INX 

H 


043.166 

042 

076 

044 


SHLD 

VARJ 

VARJ = VARJ + 1 

043.171 

353 




XCHG 



043.172 

052 

100 

044 


LHLD 

VARK 


043.175 

353 




XCHG 



043.176 

315 

207 

043 


CALL 

DEMHL 


043.201 

332 

350 

042 


JC 

SETM 

IF VARJ > VARK 

043.204 

303 

014 

043 


JMP 

SETI 






* DEMHL 

— Hl. 

DE - HL 






* 

entry: 

HL * DE 

= 16 BIT INTEGERS (UNSIGNED) 





* 

exit: 

HL = DE 

- HL 





* 


DE = UNCHANGED 





* 


'C' SET 

IF HL > DE 





* 

uses: 

A»F»H»L 


043.207 

1 73 



DEMHL 

MOV 

A.E 


043 210 

225 




SUB 

L 


043.211 

157 




MOV 

Lf A 


043.212 

.172 




MOV 

A* 0 


043.213 

234 




SBB 

H 


043.214 

147 




MOV 

Hr A 


043.215 

311 




RET 




a 


045.216 
045.217 
O45.220 
045.221 
045.224 


* TABADDR -- FIND LOCATION OF DATA POINTER IN TABLE 

* ENTRY! HL. = INTEGER VALUE < 1 -> N > 

* EXIT.' HL = A DDR OF TWO BYTE DATA POINTER ( FOR INPUT VALUE > 

* uses: d»e>h»l»f 

TABADDR DCX H 

DAD H HL = C(ORIGINAL HL) - ID * 2 


* exit: 

* uses: 

TABADDR DCX 
DAD 
XCHG 

044 L.HLD 

DAD 


POINTAB 
D 


Number 43 

106 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 




043.225 

31 1 




RET 

U - 





* SYMVAl — FIND DATA RELATED TO INPUT INTEGER VALUE IN ARRAY K 





% 

ENTRY: 

HL - INTEGER VALUE < 1 -> N ) POINTING TO DATA ARRAY 





* 

exit: 

HL = FWA STRING DATA FOR THAT VALUE 





* 

uses: 

A r D r E r H r L r F 

043.226 

315 

216 

043 

SYMVAL 

CALL 

TABADDR 

043.231 

176 




MOV 

ArM 

043 232 

043 




INX 

H 

043.233 

146 




MOV 

H » M 

043.234 

157 




MOV 

l rA 

043.235 

311 




RET 






* SORTING IS COMPLETED. NOW PRINT OUT TABLE. 

043.236 

042 

074 

044 

PRINT 

SHLD 

VARI VARI 0 (HL - 0 ON EXIT FROM SMSORTJ 

043.241 

353 




XCHG 

DE = 0 

043.242 

001 

374 

377 


l XI 

B»-COLUMNS COMPLEMENT OF NUMBER OF COLUMNS 

043.245 

052 

106 

044 


LHLD 

VARN 

043.250 

053 




DCX 

H 

044 251 

01 1 



ROWL'NI 

DAD 

B 

('4 4.252 

023 




INX 

D 

043. :»r>3 

332 

251 

043 


JC 

ROWCNT 

043.25* 

35 i 




XCHG 


043,257 

042 

104 

044 


SHL D 

VARM VARM NUMBER OF ROWS TN TABLE 

043.262 

076 

012 


NEULINE 

MVI 

ArCRLF 

043.264 

377 

002 



SCALL 

.SCOUT CR/LF TO CONSOLE 

043.266 

076 

004 



MVI 

A»COLUMNS NUMBER OF COLUMNS TO PRINT 

043.270 

062 

100 

044 


STA 

UflRK VARK = NUMBER COLUMNS LEFT TO BE PRINTED 

043.273 

052 

104 

044 


LHLD 

VARM 

043.276 

353 




XCHG 


043.277 

052 

074 

044 


LHLD 

VAR I 

043.302 

043 




INX 

H 

043.303 

042 

074 

044 


SHLD 

VARI VARI = LINE COUNT 

043.306 

042 

076 

044 


SHLD 

VARJ VARJ = ARRAY INDEX VALUE 

043.311 

315 

207 

043 


CALL 

DEMHL SUBTRACT VARI FROM VARM 

043.314 

332 

070 

044 


JC 

ALLDONE 

043.317 

052 

076 

044 

NEWLBL 

LHLD 

VAR J 

043.322 

315 

226 

043 


CALL 

SYMVAL 

043.325 

116 




MOV 

C»M C = BYTE COUNT OF STRING 

043.326 

076 

010 



MVI 

ft.8 TAB 0 SPACES FOR LABEL VALUES 

043.330 

221 




SUB 

c 

043.331 

107 




MOV 

B * A B = SPACES NEEDED FOR TAB 

043.332 

043 



STROUT 

INX 

H 

043.333 

176 




MOV 

ArM 

043.334 

377 

002 



SCALL 

.SCOUT 

043.336 

015 




DCR 

C 

043.337 

302 

332 

043 


JNZ 

STROUT 

043.342 

315 

027 

044 


CALL 

SPACED 

043.345 

043 




INX 

H 

043.346 

043 




INX 

H 

043.347 

315 

040 

044 


CALL 

OCTOUT PRINT HIGH BYTE 

043.352 

076 

056 



MVI 

Ar ' . 

043.354 

377 

002 



SCALL 

.SCOUT 

043.356 

053 




DCX 

H 

043.357 

315 

040 

044 


CALL 

OCTOUT PRINT LOW BYTE 

043.362 

041 

100 

044 


LX I 

HrVARK 

043.365 

065 




DCR 

M 

043.366 

312 

262 

043 


JZ 

NEWLINE 

043.371 

052 

076 

044 


LHLD 

VAR J 

043.374 

353 




XCHG 


043.375 

052 

104 

044 


LHLD 

VARM 

044.000 

031 




DAD 

D 

044.001 

042 

076 

044 


SHLD 

VAR) 

044.004 

353 




XCHG 


044.005 

052 

106 

044 


LHLD 

VARN 

044.010 

353 




XCHG 


044.011 

315 

207 

043 


CALL 

DEMHL OUTSIDE ARRAY BOUN‘6? 

044.014 

332 

262 

043 


JC 

NEWLINE YES' 

044.017 

006 

004 



MVI 

B.4 

044.021 

315 

027 

044 


CALL 

SPACED 4 SPACES BETWEEN COLUMNS 

044.024 

303 

317 

043 


JMP 

NEWLBL 





* SPACED — PRINT SPACES ON CONSOLE 





* 

entry: 

B - NUMBER OF SPACES TO B c PRINTED 





* 

uses: 

A. B 

044.027 

076 

040 


SPACED 

MVI 

Ar ' ' 

044.031 

377 

002 



SCALl 

.SCOUT 

044.033 

005 




DCR 

B 

044.034 

302 

031 

044 


JNZ 

SPACFB+2 

044.037 

311 




RET 






* OCTOUT — PRINT OCTAL VALUE OF BYTE AT M 





* 

entry: 

HL = ADDRESS OF BYTE TO BE OUTPUT 





♦ 

exit: 

BYTF OUTPUT TN OCTAL TO CO*QLE 





* 

uses: 

A r F r f 

044.040 

176 



OCTOUT 

MOV 

ArM 

044.041 

747 




ANA 

A CLEAR CARRY 

044.042 

016 

003 



MVI 

C r 3 

044.044 

027 



DIGOUT 

RAL 


044.045 

027 




RAL 


044.046 

027 




RAL 


044.047 

365 




PUSH 

FSW 

044.050 

346 

007 



ANI 

7 

044.052 

306 

060 



ADI 

600 

044.054 

3 7 7 

002 



SCALL 

.SCOUT 

044.056 

361 




POP 

FSW 

044.057 

015 




DCR 

C 

044.060 

302 

044 

044 


JNZ 

DIGOUT 

044.063 

311 




RET 


044.064 

046 

012 


ERROR 

MVI 

HrCRLF 

044.066 

377 

057 



SCALL 

.ERROR PRINT OUT SYSTEM ERROR MESSAGE 

044.070 

377 

000 


ALLDONE 

SCALL 

.EXIT RETURN TO HDOS CONTROL 





* DATA SECTION 


044.072 




* 

POINTAB 

DS 

2 (continued on page 38) 


Pago 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

107 










ti 9900 

FULLY REENTRANT ^ 
FORMATTER OPERATING 
UNDER TIPMX 




PART 2 


BY NORMAN V. WALTERS 

Software Engineer 
R&D Department 
Fairfield Industries, Inc. 
Houston, TX 77042 


This is the concluding segment in a two-part series. 


Z Z x 

- ►-> Ul 
3 F- 

Q CL 
_l <E - 
U X z 

- o 

ll. CM F- (0 

cl in to <r 

- O D Ul 
<1 O O F- 
U. - X _J 

<r 

CL 3 


U. O _J 
* ~iCL CL 

- CL O CL 

- UJ 

cc o. <r 

3hH 
-« -I <1 E 
J CQ Cl - 


U LU 

(0 D 

D -J 

<r <i <r 

o uj > 

111 CL (0 1 

cq <r uj co : 

x lu f 

Ci CL F- CC 

UJ O Q L 

fit>q( 

- ix oq <r 

x UJ c 

UJ Q UJ c 

UJLUXl 
WXhFi 

•— t- <r c 

o ■ i 

cl - -< o < 

UJ CL a CL 
F- O Z l 

f- cl - z : 

<x a: - f 

E UJ UJ 
CL ill D 

O Z cu¬ 
ll. <r j a: c 


ix _j <r x ► 

o <r uj o : 

cl > a. cc i 

cl z uj cl : 

UJ — CL UJ 


: uj cl 

> 3 LU CL 

: o i- uj 

JU F- 

i _i <r o 

> <r cc <r 

I <1 Ul CL LU 

: • i z <r z 

• X (j H I M 

<r i-uh 
■ E f- d d 
DOFO 
I F- 0. CL Z> X 
. <1 t- CD 0. OQ 
I X D D Z D 

: f- o co •-« co 


z z 
O Ul o 
-< z un 
F- M l- z c 

H F w M ; 

(0 D <0 F ■ 
O O O X 
lL CC CL O i 


O Z> O F- i 

UJ (L CO D l 

CL F- CL Cl ( 

D D D Z l 

(J O O >-< l 


X UJ 
CL -J 
LU CD 

> <r ir 

o in 

CLXI- 

h- <r y co v (n 

(0 > CO <1 CO I-* 

<r <r e <x o 

0. U. E E IU 

O Z iC 
I- x E I 

z uj m d i- 

m CO Q J Q Z 

o <r <x o 

0. CD CL O 3 J 


************************************ 


**************** 


F1E<IE#EU 
EFZdlMtH# O 

(t OI-ZO OH 

u.ccir¥F>-*z-cr>-«iNC'jcooou.-* 

S ll. F- CQ (J UJ Cl CC —• A. A A. « 

hlUilLlllLlilLDDDDDIO 
Q UJ UJ Id UJ UJ UJ 111 0 G G G G('; 
-•QaaiLCCCLCCcujuujujujiu 

X 

> X. (J-> 

~ UJ (ft E <X IL 
O CO <X J E Z 
CC<IE03h 

• <z co m o •-« .j 


<L O O U. II CQ 
CM 0 0(00 0 
000)000 
o o o o o o 


u u u w u u y u o ^ e> o 

ooooooooooooo 


Page 26 

108 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, IVIenlo Park, CA 94025 


Number 43 



z 

ID X. 
Z CD 
UJ <2 
CC Z 
O 

Z ^ 
"x o 
UJ 

CO X 
(0 G 

UJ 

a: z 
q z 
a x 
<r _j 
o 
a. u 
o 

UJ 

g > 
id ►-< 
o h 

G <1 
F CD 
Z UJ 

- z 


i.: *-• co 

O'i CD <X 

■a: z 

i: x 
*“* h 

it a x. 

u <r cci cd 

ui cc <r u 

2 : _j z _i 

o uj <r m 

z z g <r 

3HOUJI- 
G Z ~ CD 
a: <r h z x 

x u X UJ 

ui uj uj z Q 

> oc z 

QC *-« Q *-< 

KOQIU 
<1 Z UJ 

DhOO CO 
Ul G \ <2 

2 CO m CD CQ = 


CO 


M Q G G > 

UJ O G CO 

CD G CO <1 

zzqu. h g g g 

~ £ O Z <1 X D (0 G Q. 
QjHUOZOG^OdtCW 
<1 h g z g z m g <r g <1 d 
GGGHQOD lCIUOhJ 


z 
z o 

CD - 

- CD 
CO 


J G 
Z 

■ <1 D 

: cc <L 

) G G 
j it CC 

: g g 
<2 > 
: h o 

) CO 

h 
H CO 


CD X 

<r 

(ft G G 

t-i 



CO 

z <r 

H 

D G 
~t G H 

H 

H 

_l 

G 

—i 

G 

Q D G 

Z 

Z 

3 

Z (ft 

O 

<2 0 0 



Q 


* 

G G 
<r o 

K 

CD CO 
CO 
G G 
H CC 
<2 Q 



z 

o 


H 

G Q 

<1 

z 

G 

D H 

E 

G Z) 

G 

G 

G 


G 

OD 

°3 

M 

> 


(ft G G 

G 

ZOO 

<1 

DOG 


G 

H 

G iC 


H iC CD 

Z 

Gee 


o z z 


c 

o 

o 

Q 




o 








0 

2 ° 

"*■ 




O N % 

\ 

G 




\ \ \ 


CD 

o co 

A 

o 

>0 


od a . <r .. 

„ 

tv 

CD 

OD 


< * + 

1 

A 

A A 

_ 



CN 

QD A A ' A \ 

\ 

A 

A 

A 

N 

\ N S 

\ 

<1 

<i <r 

H 

<i 

<r 

<r 

<r <r g g g g 

G 

G 

G 

G 

G 

G G G 

G 

H 

H H 


H 

H 

H 

H H H H H 

H 

H 

H 

H 

F 

H H H 

F 

<1 

« 5 

Q 

C 

<2 

<1 

<r -2 > > > > 

> 

> 

> 

> 

> 

> > > 

> 

O 

Q Q 


Q 

Q 

a 

Q Q CO ffl CD CD 

ca 

m 

CD 

ffi 

a 

ill CO CD 

CD 

CN 


CN 




G G 

z 

a 

<r 

<r 

z 

g <r co 

z 

Z 

iC it 

G 




1CGGGO 

o 

D 

G 

G 

G 

H H G 


2 

CO CD 

•-0 

G 



(ft O G G O 

0 

cc 

3 

a 

m 

O CD G 

z 

P 

■2 <2 

2 

B 



<1 G G G G 

G 

cc 

G 

cc 

cc 

CC G G 

cc 

K 

Z Z 

Z 

<r 



Z X I I X 

I 

X 

I 

X 

X 

XII 

X 

Z 

Z G 

(ft 

H 



m o o o a 

O 

o 

CJ 

o 

o 

OOO 

o 

O 

O O 

o 

<1 

O 

CN 

od o a g <r <r 

o 

G 

G 

00 

o 

g <r at 

a 

D 

OD O 

Q 

O 


o 

O O O CN O CD 

CN 

N 

O 

o 

CN 

in (N CN 

CN 

jj 

O 00 

# 

5 

O 

O 

O OD 








O 

o o 

O 

o 

o 

o 

o o 








<t 

CO <2 

o 

G 

o 

CN 

«»■ o od O' <r co 

O 

a 

G 

G 

O 

-x CN CD 

*• 





CN 

(N 

CN CN CN CN M CN 


M 

N 

a 

O' 

CD CD CD 

P) 

O 

2 2 

O 

O 

Q 

O 

o o o o o o 

o 

O 

O 

o 

6 

OOO 

o 

O 

o o 

o 

O 

o 

O 

o o o o o o 

o 

O 

o 

o 

o 

OOO 

o 

o 

CN 

CD 

«r 

in 

<t 

IV OD O' O ^ CN 

CD 

<r 

in 

xD 

IV 

CD O' O 


in 

in in 

in 

in 

in 

in 

in in in nd xd >o 

>0 

o 

xD 

xD 

xD 

o o rv 

IV 















o 

o o 

o 

o 

o 

o 

o o o o o o 

o 

o 

o 

O 

O 

OOO 

o 


G CC - 
+ - M 

O O' *-x 

cc cc 


h z> 

<2 O •- 

a z <2 


CN . 
- CO 

cc cc 


cc 

a. 

G 

X 

CD 


> > 

o - o 

z <1 z 


T. 2 -2 ~ -x g 


cc ~ -x 


OO-OO'OOOOOOCNOOOOCDOCOCNO 

dOGOMN^OONO-GN-OCNG 

•ooonwoaiooaiooofNoiDO'f 

OOOGOOGOOGOOGOOGOO 

<OCD(IUlJJO(NV<OQO«UlllO(N«<OCD( 

co co r> co co «r «r <r <* «r <»■ »* in in in in in t 

000000000000000000 -: 

OOOOOOOOOOOOOOOOOOC 


§s§ 


CJOOGOCNCJfCJ 

G<NGCNGCOGO>G 

'tO'tO'TO’tO't 

OOOOOOOOO 

lOCCt-OflOCGGO 

I'O-O-O'O'O-O-O'ON 

•OOOOOOOOO 

•OOOOOOOOO 


g a 
- <1 
+ z 
<»■ <1 
-• cc 

CC H 
* <SJ 


> 

O G 
Z CD 


g q 
- <1 
O' + Z 
cc <1 
- ^ cc 

N CC H 

g * «j 


> > 

g o _J 
Z CD 


rv 

G Q 
- <E 
00 + Z 
G <r <2 
» cc 
MCK 
G * <SU 


> > 

g o G 
z a> 


CM G 
GOG 
- G A 
CN . - 
G (N CO 
* CC CC 


> > Q 
221 



GGOUO^MUO^NGOfNOU(N(NP)G 

£GGG<IO<J-G<2OOG<IO00OG0'O»*G 

OJO-OaCN-^KOCI-HjflJONGOONO 

OOOGOOGGOOGGOOGOGGGOO 

CM*’>OOOCGGON* , "OOOaGGO(N*«OCOC 

NNNNNNNOOGOOCOOOCTjOOOOO'O'O'O'O'O' 

OOOOOOOOOOOOOOOOOOOOO 

OOOOOOOOOOOOOOOOOOOOO 

r* N « lf> *0 IV a ^ o -x NfK 

O' O' O' O' O' O' O' O' 00 000 

2 2 J ~ ^ CN CN CN CN <N 

OO OOO OOO OO OOO 


H X 
<r -j 
z o 
G G 


<2 G 

■ iC G G 

CO O Z 

; <r h z 

: z co x 

3 G 3 

OGiC O 
G -• CO G 

> <r 

GGZ^G 
> Q CD > 

- H <2 >- 
H H <r Z I— . _ . 

<2 X G <TxG>- 

(DGG3(DCD*->a:G 
GZGQG<III-0 
ZHGGZZ(0(0h 


CD ^ 
G 

* O <1 
(0\|- 
<r *— co 
z 

O G 
H Z O 


> G CD 

<OSNG >, „ 

S A A A A A 


X D X 
OOO 
G G G 


z z 
xdo 
izi 


* * 
(ft (ft 


G ^ CN 
X CO Z Z „ 

CO <L 3 3 ecu 
G Z G O Z Z O 
G G G G * CO • 


G G 

O 5 
<2 «2 
G G 
O O 
I— H 
CO CO 

G G 
(ft (ft 

<2 <1 
CQ CD 


G 



O 




















G 






VJ 

CO 


G 



z 



















G 

a 






H 



G 



*"X 



















O 

Q 





o 

O 

o 


X 



cc 
















G Z 



o 



H 



G 

z 

o 


D 



H 




H 




z 








G O 



Q 

G 


G 



CO 


o 


Z 



CD 








o 

z 







<Z — 


G 

G 

O 


CO 


H 

G 

o 










O 





o 







G HZ 

G 

a 

O 


G 

G 


O 


a 

G 


H 



G 








H 








O <2 O 

a 

3 


z 

CO 

G 

G 

O 

G 


o 


D 



O 




Q 

CD 



<1 

H 




CD 



H Z *-x 

o 

Q 

z 

o 

<r 

O 

X' 

G 

X 


o 


G 



G 





CD 



z 

<1 

G 



<r 



CO G H 

o 

G 

o 


CD 


CO 

a 

H 

co 

z 


H 




CC 



H 

G 



G 

Z 

> 



G 



G O <1 

G 

O 


H 


G 




z 

G 


2 



Z 

G 

o 


CD 

G 



O 

S 

<1 



G 



> G G Z 

G 


H 


G 

G 

G 

G 

Z 

o 

G 

CO 

O 



o 

H 



G 

Q 



X G 

o 

CD 



•2 


G 

<2 CO Z G 


u 


CO 

o 

H 

O 

o 




<1 


G 

CD 


Z 

.j 

<L 


Q 



H Z 

G 






<r 

(ft <r »-x o 

_l 

<r 

CO 

o 

G 

Z 

G 

G 


H 

O 

Z 

G 

G 

•D 

H 

X 

G 

D 

G CD 

«2 

X 


O — 

Z 

> 



G 


_j 

GO G 

<r 

cc 

CD 

G 





a 

o 

H 


O G 

> 

G 


CD 


H 

CD 


H 


z 


CC G 



> 


G G 

> G G Z 

K 

G 

G 


G 

O 

G 

G 

G 

X 


H 

G 

H 

G 

'.D 

o 

CD 

O 

G G 

h a: o 


G G 


G <2 



<r 


X 

G <2 G X O *-x 

G 

X 


G 

X' 

G 

D 

X 

o 

cc 

Q 


Z CD 


Q 

CJ 



<r 

O G 

<r g z 

H 

-1 O 

H 

H G 



CD 


G H 

<1 G G H CO 

X 

G 

G 

■X 

G 


G 

G 

<E 

H 

G 

CD 

G Z 

G 

P 

G 

G 

X 1 


Q 

Z G G 


CD 

X' 

Z O 

G 

G 



<1 <1 

G O G G G H 

G 


O 

<f< 

<2 

<2 

<X 

<X 

G 

CO 



O D 

O 

<2 


O 

CD 

G 

Z Q 

G U. 


3 

G G 

E 

X G 

G 

5 

G 


G H 

O H G *-< D D 


G 

CO 

CC 

> 

G 

> 

> 

G 

z 

G 

G 

G Z 

<r 


H 

<t 

G 

Z 

o <r 

O D 


o 

Z D 

z 

CD Z 

> 

« 

G 


G (ft 

G CO X 3 O O 

G 

G 

G 

X 


CC 






CD 


CL LL. Lt 

Z 

G 




GfflO 

o 

« o 


O G 

H 

CD 

H 


_J 

Z 

G 

G 

X 

o 

G 

<2 

G 

G 

G 


Q 

D 

►x H 

CD G G 

G 

CD 

H 

_l 

H Q 


Z 


-J 


H 



CD 


G 

G I *x Q uj UJ 

G 


o 


<2 


«2 

<r 

G 

o 

O 


•-x D 

G G 

G 




<r _j 

H G 


G 

a 

Q 

G 

a 

iii 


Z 

Z G 

H H *-x _J H H 


G 


G 


¥ 



<2 

o 

Z 

X 

O G 

O G G 

G 

Q 

O 


O G 

x Z G 

O 

x <r 

<1 

O -x 

a 

z 

O 

G 

G G 

Q O G *-x fx 

Q 

H 

Q 

H 

H 

u 

H 

H 


o 



CD Z 

<2 D D 

3 

<r 


<2 

O "X 

UJ 

H 

CD <r G 

G 

O -x 

G 


G 


*-x G 

O *x OD •-< G G 

<L 


<1 



<r 



CD 


CD 

a 

<2 •-< 

CO CD CO 

O 

m 

a 

Z 

—1 G 

Z G CD 

~J z G 

G 

—1 G 

G 

-J 

G s 

= = = CO 

CO G 

G 3 <T G 3 3 

G 

G 

G 

G 

Z 

H 

Z 

Z 


z 


<x 


G3G3hCOmm 


G O 
CD <*■ O 


X X X X XXX 
OOOO G G G 
G G G G G G G 


O -0 

OCNCNCNCNCNsDCNCNCNCNCNCNCN-xNJCNCNCNCNCN-xCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNON 

O 

KJ?^X^J2^^2K^H?i5i5? w ^ wc,,wwwwt,5Wwwww wwcocoo^cocococoG« 

9 m J? rt? S2 2? £ & $2 t0 'V W w w w w W G G (ft (ft (ft (ft (ft CO CO (ft (ft CO CO CO CO CO CO CO 

Ui(D(DGQCDn<DCQ(DCQCUCQ0DCQCDiD£D(nGCi0QCDi£CDGQGQaQ£|£BttiCQa4CQCD(DCDCDCDQQ 




a CO Z O CO 

^ !“, 2: ° GGi^GG 0-*CNCD^ _l CC 

G <2 OG UJ-2I-G GGDZKDG'-'GGGGG ZHGI-G 

Z>GGGOCDGGQy)Z.ZOXO«0^l->>>>>>>OO<CZC0Gao 

???Irm?m---! JHj ^®GOCQQGGI-CCCCCC H HhGG[L H t 

CnajGGmGmCjQQGGGGJJGZGGGGG(0(OCO(0(OCOCO(flCO»-l-D33 


D 
G O 
CO CO co 

<1 <r <1 


CO D G 
CO G CD 
G G CL 

G 
»- Z 
D <r 

o G 
G G 
3 G 


OOOO 

OOOO 

-*CNlT'>0<r — <T ~ 

AAAAAAAA 

<r<r<i<r<r<r<i<r 

I— I— HI— I— I— I—I— 

< 2 <r<r<i<r' 2 <i<i 

QQQQQOQQ 


OOOO 

OOOO 

-« C-l UD >0 <2 — -< 

CJOCJOOCJCJQ > 


CO -< 

<r g 

Z Q Q 
G O 
Z CO o 
G D 
> CO 
G G CO 
CO G G 
«2 _l 
O Z 
Z > D 
« G 


g g <r 

O 0-J D 

g d a 

<E G 
G O 
X G CO 

h co <r 


G O o CD G O G 
O (N IV GO 
O O O O O iv O 
OOOOOOO 


G O <X 
CD O O 

o«io 

OOO 


OOCN<TCD<rOCN’f'OC:'<ICJGOOCN«-<pOO<2CJCJGO(N<t-OCO<2CjGO<N*>OCD<rCJ 

^eeeeeeeeiiiixiiiiiiiaiffiiii 

S?2222^22i;9 2 9 000000000000000 000 0000000 

OOOOOOOOOO •_'wOOOOOOOOOOOOOOOOOOOOOOOO OOO 


g oooo<r^»a--< 
m 00000000 
o Hmn-ooooo 
o 00000000 

OOCN«t>0(D«OG 

OOOOOOOOO 

OOOOOOOOO 

OOOOOOOOO 


*****#*•□ 

o 

*• 

o 

o 

o 


S ; iS^^2?^!C^^2?^^^S^!G^^222i^r^2??!!?^'^^ : '2 v0 ^ (N,0,,, ' tr '' 0fv0: »'>o-.c-icD«rin«oivGO'0-.cNG^inx5rvGo-.wcD«j-in>orvGO'0-.( 

oooooooooooooooooooooooooSoooo2222222222::::::::::^!i NN ”^^ w "””"^””^ ! 

OOODOOOOOOOOO OOOOOOOOOOOO OOO CO OOOOOOOOOOOOOOOOO OOOOOOOOO OOOOOOOOOOOOOOOOOOOOO 


Number 43 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 

109 




x »- 
x 

3 m 
o i 
z 

i— 

UJ LL 


X _J 

uj m 

Q <1 

Z H 

e 

cc o 
o x 
u. u. 


O UJ 
o 3 

o o 

e 

UJ 

CO ~ 
3 CM 


E 

o: o 
o x 
u. u 

UJ UJ 

Q <0 

o <r 

o CD 

CD 3 

UJ UJ 

r z 

*- UJ 
3 
CM o 
E 
UJ 

co - 

3 CM 


H I 

<1 b- 

e a 
cc — 
O 3 


CC * 

a: cn 

o <r 
O E 

I- Q 
UJ Z 

0 <r 


UJ 

5 

<i 


3 CC I 

*- O K 

<r u. q 

h- *-H _ 

CD O 3 *-< 


y iii u 
o _J 
UJ O UJ 
X O ~ 
O J- IL 


Q 

_J 

Ul CO 

u. * 

_J X 
_J K 

Ll 3 


CO UJ h 


Q 

o 

cc 

CL 


X <f X 
CC —< UJ 
Ul cc ^ 


z z 
3 >- cq 


N * 
CC CO 
- <1 
CO E 
CC Z 


3 O 

o o 

E O 


(0 

<X 
E 
4 CD 
E - 
CC N 
U CC 


UJ Q 

z z 
-5 <r 


-i > 

cc o 

CO E 


in <x 

E E 
CC Q 


CL O 
E O 

3 O 


co 

C <1 

<r e 

>0 CD 
E * 
CC 

lL CC 


X O 

(0 E 


a 

a 

cc 

CO 

* 


CM 

* 

in e 

r v <c 


<r 


CC 

JL 


CC 3 

cc z 

4 UJ 

CD 

N * 

<r 

CC CO 

<Z CC 1 


- <r 

CC CO 

Z 

CC C» n 

<r x 

N e <1 

CO 4 •* s 

00 - 

4 CC 

- <c 


- E - 

E CJ 

E 00 X 

EE 4 - 

cc in 

CC b- 

N CD 

CD 

N CC N 

in cc o 

CC CC (0 

CCincC-OCDCMCCN 

* cc 

* <&) 

CC <SJ 

& 

CC U CC 

CC U 41 

U * <SI 

uccuxxx*x 

•-f 







CD 

' 3 Ci 

> 

3 3 


3 G 

CJ 1- 

CL 3 O 

Ul O CL O CC CC 3 

o z 

O _J 

O O 

_i 

u LJ m 

Ul _l _J 

X O Cl 

ZZEZ_J_IO- 


E - 
CC N 
lL X 


E “0 _J D “5 CD 3 E CJ 


« 3 •-* O O E O 


SC 

~ CO 

- <1 
E E 
CC M 
Ul UJ 


G U 
Ul O 
3 o 


- CM O 

- CC - ^ 

e - r . 

X CM X C- 
u CC u CC 


a 3 uj 
UJ o z *-< 
•3ETO 


***** 


<1 o 

CO o -• 

EE E 

cc cc cc 

Ul U U 


UJ (0 

u o 

U 4 


UJ o 
CJ 4 

in <* 

o o 


<10-0 

H-OO 

«r 

o o o 


D U J :9?£^-OUlJ J -O«fONNH o y fU l^ o Q < i o fl5UJO«-UOOOOCi < INlL-0lHOroo<»OU 
,H T!2' 0 £C?£? :i 29'- j r , 9 ,0fsJ(00 ^ OQO °'- ,, ^No-«-oco-«-» 0 ' 0 <r»HCo cm co — ^xjo-'^o-oino in <r<t 
/./V. ~ — ~-'~'''-'~^c-4 0~«00000000000 0 OOOOOOO^OC'J 0 ^ 0 0^0'N 0 »hO~«000 


CJCMO-^OOOCJOO- 


o o o o o o o 


oooooooooooooooooooo 


[0^44444444^^^^^^^^ CO CO C0C0C0C0 CO C0444 

ooooooooooooooooooooooooooooo 


-ONOnNOOO-OQflfljS 

QOOO^IXIO-hMCNOCOOCO 

-CJQC0(Nffln-O(0O-0<N 

Q0Mh0N-CC0«U«0 

-oocxrouiorj^-ococouj 

o^^i>CNO^<i<r<r<i<r<r<r<r 

ooooooooooooo 


>o c*- 

in in 

CM CM 

o o 


O^CMCD^in-OC-CD 
>0>0'0'0*0-0>0'0'0 
CM CM CM CM CM C-l <N CM C-l 
OOOOOOOOO 


z - 

H 3 

Ul 

uj a 


3 3 


3 CC 
CL O 
Z U 

h- 0 

d <r 

CL E 


4- O 
>0 N 
CM CM 
Q O 


•-< *-< Z 


CM 
N N 
CM CM 
O O 


CO <* 
N f“- 
C-l C-l 
O O 


in -o 

C-* N 
C-l CM 
O O 


N 00 
C* N 
CM CM 
O O 


z 

*-« UJ 
Q 
> O 
CC o 


b- CC 
X o 
UJ u 
z 

sc 

I- CO 


x UJ 

uj a 
a o 
z <J 


Ul Q 

UJ 3 
Cl <1 
O 3 
O 

CC 
CL O 
O U 

h“ SC 
U O 
*- UJ 
X X 

CO u 


CM O 

<t in 

4 

N 00 O' 

O - CM 

CO 

<r in 

00 00 

c» <» 

00 

Oj 00 CO 

CN 4 4 

4 

4 4 

C-l CM 

CM CM 

N 

C-l CM M 

CM CM CM 

CM 

C-l CM 

O O 

o o 

O 

O O O 

o o o 

C 

o o 


Morsaio^o^cMCo 
OO'O'iJ'OOOO 
C-l CM CM C-l CO CO <0 CO 

oooooooo 


in 

o o 

CO (0 

o o 



UJ 

-1 CO 

u — 

cc 

CO <1 

X 

UJ 

o 

CL 


CO x 

o 

<r 

o 

3 b- 

UJ o 

u 

CM 

»- _i 
U CL 

CD 

h 

O b- 

Q 


<x 

UJ u 

CC UJ 

O 

X b- 

b- 

o - 

CL O 

<r 

CO - 


3 CC 
<1 
CL X 
3 O 


*0 c** 
o o 
n co 
o o 


00 CN O -H 
o o —< •-« 
CO CO (0 (0 
o o o o 


cc 

UJ cc 
I- UJ 
Z I- 

- z 

o - 

Cl O 
CL 
h 

CO b- 


z t- 
<l <t 
CC E 

Ul cc 

CL O 

o u 

CL CL 
E X 
3 3 
CD 00 



CC 

b- 

cc 



CC 

CL 

CC 




CC 


3 

D 


cc 


Z 

3 





CO 

O 

U 



CO 


(J 



N 

1- 

cc 

CC 

CC 


CL 

cc 

Q 

a 



X 

3 

3 

3 

3 


z 

3 

CC 

cc 

o 



O 

o 

4J 

4J 



CJ 

Gsl 

<J0 

o 



CC 

cc 



u 

Q 

a 



N o 


+ 

3 

3 

O 

O 

u 

CC 

cc 

O 

6 

cc u 

o * 

CD CO 

41 

41 

o 

O 

A 

<$D 

4J 

O 

o 

- A 

^ r- 

- E 



CM 

4 





in 

CO ► 


X X 

CO 

00 

U 

U 

CM CM 

CM 

CM 

CJ 

a 

CC N 

N 

X u 

CC 

CC 

4J 

4J 

CC CC 

CC 

CC 

41 

41 

* cc 

CC (L 

uj a 





CD -i 








3 

3 



Cl Q 

3 

3 



3 Q 

_l 

h 

o 

o 



3 Z 

O 

O 



a z 

X -• 

0 

E 

E 

<r 

<r 

co <r 

E 

E 

<1 

<r 

e <r 

CO CJ 

3 CD 


CD CD CD CD 00 



Z 

N 

CO 


0 

4 O 

h* u 



X O 

X o 


h 

* A 

U * A 

CL 

O 

CO - 

ui CO - 

O 

UJ 

X 4 

Z X 1^ 

4J 

CO 

* X 

UJ * X 


0 





3 Q 

a 3 a 


I 

O Z 

UJ 0 z 

CD 

1- 

e <r 

3 E <t 


CC 

<1 

- in x 

- E CJ 
N 4 CC O 
CC CC U HD 


<r o t- 
J UJ J J 
CO Q 3 (D 


-J CC 
-I CC 
~ UJ 
U <SJ 


i 

3 CD 


h- U 
E A 
U - 
0^ 00 H O 
CC CC O CC 

I— I— 

O O CL 

Z Z E ~ 


****** 


(0U(0<ro(NUO-c<rcuMu.^<i 

G CD O CD C l O CD CM O CD O U O 00 
00000000000000-0 C-l OCDO 

cjocjo<xoo<iooooooo 

cjujocm«i-md0<icjujo cm «r-o0 
cncn<x<i<i<i<i<i<i<icdcqcdiIicq 
OOOOOOOOOOOOOOO 
OOOOOOOOOOOOOOO 


ClfflOO«O^C0C0NONNUHMJOOO<tO|jJO-0O(MO«O«Off 
OCO C-l O0DCMOC0Q^-O<TC0^ c-l 'OQ'OU-OCO'OQ-OU'ON'OOQ-O-O'OO 
co o oo o o co o o - ci o ^ ci o in o ^ o t - t ci ci o‘mt m 

oo<roo<roooouoo oooooooooooooooooooo 

<roujoc-i^--ooo<ioujocM«r-oco<roujo<N«t>oco<iouiocM'e'O0<i 
CDCDCD UOUUUOu O QQQQQQQQUJUJUJUJUIUJUJUUUUUUU 
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o 
ooooooooooooooooooooooooooooooooo 


_ -I ^ ft in U 

o _J CC EE Q 

CL -H cc CC CC Z 

• O * U UJ Ul U UJ 

CO-OlLOCONOSO N 4 4 O O CD O <1 CN CO CO O 
j'-tSHQ<t®cio *^oo<ic-iU'0oooQa) 
HfioooHciuno <c -o -■ -o -o o v i in in o ci 
oooooooo*- 00^00-^0 0 00^0 

OUJON^-OCOdO 

uuooooooo 

OO--*-.-*--.- 
OOOOOOOOO 


OOOOOOOOOOOO 


in 

-0 

rv 

CO 

4 O 


CM 

CO 


4 r- 

CO 4 

O - 

CM 

CO 


in 

>0 


CO 

O' 

^CMro«*m'0i s 'OOCN 

O CM 

CO 

o 

o 

o 

o 

o -• 







CM CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CO CO CO to CO CO CO CO CD 

'J- <r <j- 

■S’ 

CM 

CM 

CM 

CM 

CM CM 

CM 

CM 

CM 

CM 

CM CM 

CM CM 

CM CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM CM CM CM CM CM CM CM CM 

CM CM CM 

CM 

o 

O 

o 

o 

O O 

Q 

O 

O 

O 

O O 

O O 

O O 

O 

O 

O 

o 

O 

O 

O 

O 

OOOOOOOO O 

O O O 

O 


^ in -o n oo 

CM CM (M CM C-l 

o o o o o 


O', o 
«* in 

CM CM 

o o 


- CN CO < 

ui in in i 

CM (N CM C 

o o o 


Page 28 

110 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 


CD 


UJ 



CL 

<r 

z 

G 

UI 

u 

<1 

Z 


CD 

CL 

UJ 


CD 


CL 

CL 

G 

1- E 




O 

0) 

>0 


ID 

CL 

O 


<1 CL 

CL 

CD 

CD 

It 

<r 

Ct 

O 


UJ 

z 

CD 

G 

►— 

z 



CD 


1- 

b- 


o 

CD 

> U 

(0 





in 


CL 

X 


UJ 

CL 


ct 

1- 

CD Cl 

1- 

ct 

_l 

UJ 

O 


Ct 

<L b- 


E 

H - 

UJ 


Z UJ 
UI CO 

i <r 

H CO 


CD 

it ct 
O LU o 
uj z ct 
i 5 co 

O Z UJ 


Z X 
— UJ 
CD z 

UJ I- 
> UJ 

<r o 
CD 


H 0. 

<r o 
e 

it h 
o z 
u. UJ 
e 
h ui 
z > 
UJ o 
co e 


Z Q 
UJ UI 
UJEu 
I- UJ UJ 


O Q 
Z 3 — 
~ h ct 


Z Q 
UJ UJ 
E Q 


UJ 


o 


Ct E 


-J UJ 

CD 

z 

UJ 



1- 


UJ 


0. Z 

\ 

E 

fl 




S3 

z > 


E Z 

2 

D 

Ol 



it 

It 

- G 


O D 



G 


E 

u 


E 


G 


O 


u 

UJ 

<1 

Z 

H 

Z 


UJ 

G 

Z 

G 

-J 

Uj 


<X Z 

E 

CD O 

_l 







E E 

D 


CL 

CL 



3 

G 

CL 


3 

B 

it 

h 

UJ 

g 


-I O Q E 

O 3 O 

O I— QC G 

I— HP- CO 

O UJ UJ UJ N 

Z O CD CD <M 


CD 

G 

CO 

u 

I- rs ct 
> a: o 
CQ co 
z a: 


3 u UJ 

o z cc 
ct <r 

_i 

b- 3 -J 
G O <1 
CL CL G 


(J UJ G > 
UJZOu 
Cl - UJ E 


UJ Ci 

z z 
o <r 


_i > 

ct o 

CO E 


G > 
G O 
UJ E 


Ct Z 

> £ 
UJ CO 
CO <1 

<r oq 

CCi GJ 


S 10 CO 

CL - CC 
► E Lt 
N t UJ 
Ct x GJ 


n <r 
ct z 
► <r 
O' ct 
CL J— 
* GJ 


> 3 
-J OaJ 
<100 E Oi 


>0 Ct 

(t u. 

* GJ 


C>l 
>0 E 

Ct 3 
- O 
CO CL 

Ct z 

* GJ 


> o 
o o 

E O 


<1 CL 
- 

CL <i 

o Ct 


ui a 

51 


Ct 

Z 

O' CD CC 

- O 

G O 

G 

Z 



- - 

03 G 

«T - 


s3 

s3 

S3 CL s3 

Ct Z 

CL 0- 



it 

Ct 

Ct O CL 

* an 

O CL 

CL CL 

Ct 

>-< 







UJ 


G CL Q 

> G 

uj a 

CD Q 



CO Z <E 


o o 

E O 


z z 
-3 <r 


I UJ 
s3 h ct 
- CL Ct 
* . D 
s3 M3 G 
Ct Ct GJ 


********0 


oo«r 
« «o 

s3 O sj 
O O O 

UI O CM 
CM 0 0 CO 
CM CM 0-4 

o o o 


G M3 in 
It 03 O 
O CM Hi 
- O G 

s3 

CO CO 
CM CM 
O O 

■ 03 O'- O 

■ H N 03 

> CO CO CO 

> o o o 


M) O 03 O O M3 s3 
03 <X CD <1 - G 
O s3 S3 — O M> CM 
O O O CM O — O 


0 ) 0) 0) 03 <T <T 
CM CM CM CM CM CM CM 

o o o o o o o 


o o 
O N 
CO O' 

o o 

S3 00 
«* 
(N CM 
O O 


s3UJNOUCJ«0OQOUJNiNOM^O^S3OUJ 
CM—OinuiOO<f03<IlLGOM)OCi<IOQM3 — 
CD O O CJ « O 0-1 O - >0 ^ «r -H >0 0j 10 <r — 

GOOOGOOO<TOOU -OOGOOGOO 

c u uj o cm «a-s303<rGUJOCM«rs300<iGUJO 

<* 10 IO 10 10 lO 10 in in S3 S3 S3 S3 -0 s3 s3 S3 N 
CM CM CM CM CM CM CM CM M CM CM CM «.N CS CN CN CM CM CM CM 
OOO OOOOOOOOOOOGOGOOO 


CpOs35s3OsJS3s3Us3Os3iNS3O03O«tGNU.NrsLLNOC>IN 
O' <1 - O ffl N o C O IN H o o 03 O UJ - O t rn O -t 0 C4 o 

(NNCD^CJGMOCDOMN-HOSJNGIfiCNONOOCN 
GCMO-OOOOOOOOO-OOGCMO — OOOOOOO— O 

CM«Ts303<IGUJOCM*-s3G3<XOUJO CM 4t-M3Q3<rOUJO CM «Ts3033: 
r^rxNi s -r^NN00O3O3O3GC000GO'. O^O'OO'O-. o. i><i<i<i<i<r<r 

OJOJCJCNCNC-ICNM CM CM C-J CM CM CM CM CM C-J C-J C-J CM C-J C-J C-J C-J C-J (N C-J C-J 

ooooooooooooooooooooooooooooo 


00 00 03 03 

CO CO CO CO 

o o o o 


IN. 03 O'. O — 

CD 00 03 O' O' 

00 CO CO CO CO 

o o o o o 


C-J IO 
O' O' O' 
CO lO CO 
OOO 


IO M) N 03 O — CM 

O'- O'- O' O'- OOO 

co 03 co co «r «* <»■ 

O O O O OOO 


o <t in M3 h 03 O' o — 

ooooooo — 

t «!■ «r «f «r «r t <f 

ooooooo oo 


o rs 03 ov o 

- - - w4 C-J 

<3- 

OOO o o 


CO ^ If) S3 N 

C-J C-J C-J CM CN 

o o o o o 


It -0 M3 O 

co it g <r 

O CD - M3 

O O <1 o 

G UJ O CM 
<X <1 CQ CD 
CM CM CM CM 

o o o o 

03 O' O 
CM CM CO 

«* <* 

OOO 



u- 

-i 



i- ><r 

UJ 

Ji 

it 


H 

X CD E 

b- 

1 



b- Z 

UJ it 

Zi 

_J 

CL 


<r u 

z a o 

—I 

CD 

<L 


E E 

z u. 

o 

X 


Ct Ul 

o <r 

0) 

ft 

G —1 


G Ct 

b- CL b- 

CD 

IJJ 



It G 

UJ x 

<r 

s 

O H 


Z 

UJ Cl UJ 


'L 

ct z 

in 

H 

D O Z 

ct 

1 

UJ D 

ct 

Z 

Z 

o 

G 

M 

h 

UJ 1- 

-HO 

0) 

0) 

1 UJ 

Z D 

(t <1 

H Z H 

CL 

G 

z S 

- CL 

CL E 

Z UJ 

Z3 

<r h 

G Z 

b- 

3 ct 

GEO 

G 

UJ o 

z - 

X D 

G O 

G UJ G 

b- Z 

1- 

h- O 

It 

Ct 

H 

O’l 

b- z 

Q 

h 

► G 3 

UI 

z o 

UJ o 

- CD 

UI CD 

O Z O 

CD 

- a 

CD G 

3 h 

CD — 

z - z 



UJ 

H UJ 

> H 

G 

O 

Ct 

CD 

G 

N CD 

Ct 

UJ 

H >0 

CD N > 

CD 

z 

<X Ct 

Ct CD 

Z Ct 


E 

CL 

— G 

H 

It Z 

UJ z ct 

G 

G 

O — 

CL - UJ 

Z 

Ci 

It 

CL 3 

E UJ 

Ct 

3 

D J O 

G H 


b- G 

O _J 

—1 G 

H 

Z Ct 

Z G 

G _J 

X 

UJ 

— Z 

G O 

UJ 

ct ct 

Ct - 

CD 

z 

CL O 

3 O 

Q CQ 


D lL 

G U Z 

Z <1 

H 

G 

It E 

<1 

UJ 

x 

l: g 

_J 

O 

b- CD 

H CD J 

3 _J 


UJ c 

JC o 

o <r 

o 

G E 

Cl E G 

Ct G 

G 


I 
UI I- 
I 1=1 


LU UJ 
CD I 
UJ I- 
CL 

h- 
O UJ 
CD CD 


£ 

E 


z X 
G I- 
Q 

0 ) — 

m 3 

H UJ 
— 03 
CD <X 
I UJ 
03 Ct 
G 


a _i 

<i UJ 
CL - 


I 03 
O UJ 

z > 


3 UJ 

O - 

z u 


CM 

jl in * 

<r :z ct <r s 

o - - o 

— ._J it ^ ' 

E * Z Z E - 
CL ro — — CL n 
U. it _1 J It Ct 


UJ :> G G 

Z O Z UJ~ 

■jIhUOJ 


it J— 

E UI J 
“3 0) CD 


If) *■« O it ►- 

CL - - > K 

- E E 03 Z 

CO CO Ct S3 CL Ct >-< 

CL CL It Ct It * «SJ 


G OGCLDG 
Z U1ZEOO 
hOTh-jeO 


E O' E 
CL CL CL 
It * It 


Z 

E 

- E 

0) 

o 

M3 3 

1 fN _J 

CD 


CL O 

M3 Ct O 

n <r 

b- 

► It 

— ► o 

ct ct 

G 

G » 

► 03 - 

* G 

UJ 

Ct M3 

S3 Ct N 

S3 G 

Cf> 

* Ct 

Ct * Ct 

Ct GJ 

(D 





G Q 

GOO 


X 

O Z 

CL O Z 

_J 

H 

e <r 

g e <r 

<t CD 


UD 

Ct 

in h m 

Ct Ct 0) 

it 

(0 

<x 

E 
- 3 

0) 

M3 

CL 

CM 

M3 it 

CL CD 

CM 

M3 

Ct 

it 

CD 

N 

Ct 

<r 

<1 H 
cm <r <o 

- » <1 

<r — 


- <1 


<r 

— ct t 

CO CO E 

in - 

E - 

CO E 

E 

E 

E ► X 

CL CL Z 

e in 

ct in 

Ct CO 

ct in 

CL 

ct in g 

* * Gl 

It ct 

u. ct 

* <&) 

lL ct 

* GJ 

It Ct Gl 

> > G 

a a 

UJ 

> G 

UJ G G G 

CD 

UI > > 

OOO 

UJ z 

z — 

G O 

Z Z G O 

ZOO 

E E G 

~j <r 

“3 _l 

E G 

G — 

UJ G 

GEE 


CD jL 
CM «t CQ 
- Ct CL 


G UJ > O 
UJ z o o 
DOEE 


E E 
CL CL 
Ll Ll 


****»-**o 


O I s - (0 0Q iD CO 
O O G 03 «t O 
O s3 <N If) -< CO 
CO - (J O 0) -H 


N O -h CM O O CO CO CM -0 CM 00 O CM CM O' O 
0000<rCM03<f003UJaUJ-<<IQ<I 
rM00Ns3s)ID-0lf)0-H-0M)lf30 
OCMwOOOOO)hO^GCMO-*Oh 

GUJOCM«*S303<XGUJO CM ^>003<rG 
CQCDGGGGGGGGQQOQCiOO 

00<D0 0000000000000000000 


* * * * * * Q 


CM(0*3-ins3rN 03 O' O -s CM CO ^ If) -o rs 
« -H CM CM CM CM CM CM CM CM 
03 (0 CO CO CO CO 03 CO CO CO 03 CO CO CO CO CO 

O O O O O O OOO ooooooo 


Q30'OCMC0«rif3s:irNCD0'O 
CM CM CO 03 03 CO 03 CC' 03 03 03 
00 CO 03 CO CO 03 03 CC' 03 03 03 03 
OOOOOOOOOOOO 


a>-0Os3Q3NltS3O»rOO 
<>- <r CD It Q «J- 03 G <r U3 S3 CM 
-HOMrNCD^.CMO^S3<'«r-H 

GOOOGOO<IOOOO 

UJOCM^-003«GUJOCM«f 

OUlUJUJUJUJUJUJUJLtLtU. 

oooooooooooo 


03 CO O 03 UJ HI Ll CM liD O CD 

in a si ~ o <r o o o O' 

^--OOOMO-OCMOw 

GGCMOhOOhOOG 

s3(33<IGUJOCM«»S3CD<I 
ULLUUU.O OOOOO 
^ ^ ^ r,( ^ C4 r-j CM CM 

OOOOOOOOOOO 


O G - 
< 1-0 
- O >0 
CM O — 

G UJ O C 
O O - - 
CM CM CM C 
O O O < 


in «* o <r uj in 

00 — <L — O O 

incM — o-o- 

O O CM O — G 


- CM CO 

«t 

CO 03 O.I 
OOO 


in 

03 03 
O O 


03 <> O — CM 03 in s3 N 
<* u*3 in in in in in in in 
0) 03 0) 0)030)0)030) Oi 
OOOOOOOOOO 


03 O' O — CM 

in in s3 s) s3 

03 03 03 03 03 

O O O O O 


UJ 0) <1 CM O It O l_ 

— 0s3s3>0-0 — — O 
QOOOO — GDO 

CGUJO CM «*s3C0«IO 
- -h - CM CM C-l CM CM CM CM 
M CM CM CM CM CM CM CM CM CM 
3000000000 


S3 S3 

0) 03 

o o 


in s3 rs 
S3 S3 S3 
03 03 03 
OOO 


03 O' 
S3 >0 
03 0) 
O O 


O - 


cm o) «*• in 

NNNN 
03 03 03 03 
O O O O 


Number 43 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 
111 





























0 

0 


<1 

0 

H 

D 


Z 

0 

D 

Z 



0 

O 



X 0 

CL 


\- 

CL 

CL 0 

Q 

CL 


<1 

0 D 

a 

O 

0 

X 

H Z 

<E 

0 

1 

\- 

0 

h- Z (L 

0 

0 


H 

D 0 O 

0 

CL 

0 

X 

0X0 

D 


X 

0 

1- H 


CL 

»- 

Z 

3 ^ 

0 

<L 



O 0 0 

0 

0 

1— 

K 

0 0 

0 

0 

0 

0 

0 D x 

0 

0 

o 

O 

- Z 0 



* 


R2 



Q 






N <E 

*1- <1 

I s * 0 

CM * 

<r 


O <0 -• CL Z 

O 0 X 

— - 0<f«N<J-<I 

in cm 0 (/) 

oo in 

«* 

CM 0 CM » <[ 

0 ► V- 

0 0 * 0 CM 0 CM I 

0 CM ► <1 

CM — — 0 X 

X 

X - X Os 0 

» 00 e 

- - — - X - X 0 

* X 05 X 

X - * * 0 

0 

0OO>O0 0»- 

MON0*t 

>oo0<r0N0O 

CO CO 0 0 0 

0 o CO O CO 0 

0 

0 0 0 0*® 

0 0 0 * 0 

00*0000® 

0 0 0*® 

00000® 

® 

h 


oo at 




a > u cl> 

> 0 0 > Q 

> > > m >a 

0 0 > 0 

a 0 0 <t 


0 O Z X O 0 

O 0 0 O Z 

o o o z o hi 0 

z zoo 

UJ Z 0 0 


OX-OXffl 

x 0 0 x <r 

x<rxx"Dx~)cn 

*-*00X0 

OM(i)(fl<rui 

CD 


0 ¥ 
Hi 0 

0 o 

Q 3 
Z 

UJ -J 
X <1 
b- LU 

<x 0 
uj 

0. • 
UJ > 
CL _l 

z 

OO o 
UJ 

-J UJ 
Q D 
2 O 

<r o 

X 

CL 
Z 3 
O t— 
— UJ 

K OO 
O 

UJ 0) 
V) — 



00 x 

0 0l 
* ® 


> o 
o o 
X o 


UJ 
CL CL 
UJ Q 


0 b- 
UJ Z 
CL UJ 

0 

UJ CL 
O 3 
<E O 
CL 

O O 
I- b- 

00 

CL 

0. u 

X b- 
UJ z 


Q 
CM Q 
CL <1 


N 


CO 


® 


<1 CM CL MO 

X <* 0 ► 0 

• 0 •* CM ► 

OOtLO-(»«0«0 
CL CL hi CL CL CL CL CL 


O t- > > <J > 

Z O O O Z O 

hOIXCXhX 


<r 

X 

5c ‘cl 


* * * * * * * 


******* 


<10 0 
- O 00 
O 0 - 

o - o 

UJ O N « 
-NN( 
0 0 0 C 
O O O < 


O>O0^tf( 

ooaiooooo — <fo«r<rao< 
o-oooooooooo<iao. 


co«a-ooo<i'Ooocooocoooouj 

coo<r- 

o 

«j-0Os<r-ooo-*-o>ocM'O- 

Q Ul — — 

0 

--oooocoinos<i cm <»■-•<*-< 

— — o MO 

in 

oo — 0CMO-*ooo<roooo 

0 CM O — 

o 

UIOCM*tM)OO<[0UJOCM*tM)(X) 

<E 0 0 O 

CM 

«rinii'oinininininin'0>oO'0>o 

>0 mO <i N 

N 

ocooooocococococococococooo 

00 CO CO CO 

CO 

OOOOOOOOOOOOOO 

OOOO 

o 


0 <> 

0s Os 


o — cm oo in mo n oo <* 0 —CMC 0 <rinM 0 n co o^ o — cm oo in mo n 

O------- — — — CM CM CM (\| CM CM CM 0 

in in in io in in in m in in in in in in in in in in in 

oooooooo ooooo oooooo 


oooo ooooo 
in in in in ininininin 
oooo —- 


ooooo 


o — CMOo<tinMONooos 
00 0 0 0 0 0 0 0 0 
in in in in in in in in in in 
oooooooooo 


i«os0O>o-N0<tin'O 
■ <* <* <r <»■ in in in in m in in 
iinininininmininininin 
>00000000000 



o O UJ 

o 0 o 

uO CM o 


or* c-. o — cm 0 «r in -o 

u.i in -j <1 -0 *0 -j <> 

> in in in in in in in in 


o 6 o -■ 6 o ‘ 



D • 

0 

0 

— * Z "0 




1- 

0 0 

h- 

D 

►- 0 

X 

K 


<r 

H 0 

<r z 

X 

0 — 0 - 

►— 

D 

o 

X 

D H 

x - 


D - O 

O 

O 

z 

0 

O «I 

0 

X 

X O 0 

z 

0 


o 

\ 0 

o z 


0Z0I- 

0 


0 

0 

h 

0 0 

o 

> OO — M z> 

0 

1- 

1— 


D 0 

0 

z 

0 <1 0 0 


3 

oo 

H 

0 Z 

h 

0 


h- o 

0 


X 

z o 

z o 

0 

b- OO — D 

D Z 

Z 



0 * 

Z CL 

o 

CL 3 


0 UJ 
Ul CL 

CO 

0 • 
UJ UJ 

o 0 
O G 
CL O 
CL 

CL 
Z 3 
O J- 
- LU 
b- 0 

o 

UJ 0) 

0 HI 

0 0 

I X 
K I- 


UJ Z 
CL - 
CL CL 
0 b- 

O 0 

1- CL 
UJ o 
0 0 


0 

<r <r 

CL X 
► 0 


O 
N 0 
CL 0 
► A 
0 - 
CL N 
* CL 


)0>H 
0 U _J h 0 
CL 0 CO 
■ ^ »-< UJ 

: j- a o 

» a _j o 

* Q 0 0 CL 

: <r x ~ 0 


t CL 0 
N CL - <E 

► * 0 X 

N N N CL Ci 

CL CL CL * & 


> a :> a _jo>>o uj 

OZ OZ CCZClOG z 

X<r E <L (fiHEEU 0 


CL 

H »- 

0 <r 


>-<»-» UJ 


> 

o 

X 


0 b- 
- 0 
CL 

0 z 

<r — 


X 

I- 0 

h 

h- 

a 0 0 

<t Q 

O 0 
0 

0 o 

0 

0 

0 0 a 

0 0 

O 0 

OO 

o 

0 O <1 

- 0 


a 
^ <t 
CL Z 

► <r 

0s CL 
0 <* CL *- 
0 0 * <SJ 


CL 0 > 

J JOJ 

o a x 0 


CL CL - s 
- - X - 
N CL N 
CL CL 0 CL 


> > 0 
OOUJh 
X X 0 _l 


0 N > 0 

- 0 0 3 

X - 0 0 

cl 0 <r -j 

U.W QHXMSJ 
0 

0 3 > > 

X 0 o 0 
0 0 x <r x 


o 


o 

E 

Q 


0 



<r 

o 

0 0 


0 

z 

0 

0 

0 

h- h- 


M 


0 

<r 


U 3 




*1 

X 

h 

0 H 

»- 

(J) 

0 

a 

o 

X 

K — 

3 


<1 

O 0 


0 

0 1- 

0 


X 

z a 

h- 

Z 

o CO 

b- 

b- 

o 

- Q 

X 


at 

3 



0 <1 

0 

H 

0 3 

O 

at 

0 

b- 0 

z 

0 

o oo 


i 

0 

oo 


O 


0 

0 

o 

a 

H 


1- D 

z 


h 

oo z 

0 

O 

0 z 


0 

OO 

— <r 

0 

o 

0 <r 

0 



<i - — 

co - - 0 in <r «*■ 

- 0 CL * CL in X 

X - - » - - iL 

0MOOONOOOOX0 
000000U.® 

0 

a > >0 0 

00 O z z 

0x<Ex*-4onm 


X 
CL 
CL 0 

O 

H 0 
0 X 

0 0 


0 X 
IL CL 

* ®J 


SB 

X O 


******* 


in 
Cl 
* o 


******* 


•000 

000 

MO - 

000 

^ mO CO 
0 0 0 
NNN 
OOO 


0<T00NONNN0OO0 

-'tOD>t(l)N0OD0H('l 

-CMO-CMooosinos--oMO 

000000000000 -- 

<i<j0Ocm<*-moqo<io0ocm 
0000000000 o a a 

CM CM CM CM CM CM CM CM CM CM CM CM CM 
OOOOOOOOOOOOO 


- X X X X 

X CL CL CL CL 

0 0 0 0 0 1 

\ s \ \ \ 

0 N0N'OOCM0*-OsO*-N«t0NON0 0Or''.ONOO0'O0fN00UJOUJ*-O 

a <t0Oco<xoooa<io(Dooooo0oouj<rocMO«**-<*<»«ruj>o~«ouj 
— CMOfflO'fl'O^«f-M)ffl-H0(NOONHH-oO5O0OOfin--O«fHNO 
0 OOOOOOOOOOOOO—OCM— 00<ia00s0— OcXQOaO— OOO — 


■x> o 
5 <L 

o o 

10 CM 


mo co <r <j 0 o cm mo oo a o 0 o cm <r mo 

Q QQQQQ0000UI0000000 
CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 
O OOOOOOOOOOOOOOOOO 


0<r00OCM^->o0<r00OCM^*O0 
0000OOOOOOOO — - -- - 
CM CM CM CM l v J O (*) OP) (0 (*) 0) f) (*) (0 O PJ 
OOOOOOOOOOOOOOOOO 


— 0^in*Of^QJOsO-*CM 

co co co cococococo + 't't 

o 0000000000 


co *t in >0 n 0 O' 

^ ^ *1- <#■ «3- <»■ 

»*■ <#■ 

00 ooooo 



Page 30 

112 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 






1 co >o jjom 

> CO 00 n r 

■ - u-< -X- O <N ■: 

: uo uoo< 

> .U O 'N «f -0 i 

: <i uj ot cj ii c 

> (•) co ro co 0!* c 


O -< -N 00 

:• t ' r' n 

:• t*> u*« uo u* 

: o o o o 


' O N N ^ 

• u'- <r ooi 
- -o mo 
o o o o 

i <r <r o uj 

• <t<L<r 

• o > co co co 

• o o o o 


OOr^O(NO(N5fO<X 

>0 CM CO 00 CM 00 O CD *0 <J 
«t-*<0OCMOCQO*O 
OOOOOOOOOO 

OCM«t'000<rOUJO(M 

COOQCQmCDCQQQCQOCj 

COCOCOCOCOCOCOCOCOCO 

oooooooooo 


tcoiiiij.Hini J jocoooo<rooii')«ooo 

OIO«-COOCOOUJ^<r(NUJN<INOU.>ON 

(0^c^o>oincr'-«o>0'0^0'0'0>o^i«j-^ 

OOOO^OOQOOOQOOOO-hOO 

<»■ >0 00 <1 O IUO(N«f'0 0)«OUON«f 
OOOOO OQQQODODQliJUIliJ 
0 - ) CO (0 (0 (0 CO CO CO CO CO CO CO CO CO CO CO CO 

ooooo oooooooooooo 


<JOOOOOOO<JO<JOOOOO 

uo o in O UO O ID O If) O U") O ID O ID o 
oooooooooooooooo 

'Oa><rOlUON«J-'OCD<IOUJOO'l«f 

UJUILjJUJIiJU.LlU.U.Ll.U.U.LlOOO 

CO CO CO CO CO CO CO CO CO 'O CO CO (0 <}■ «J- 

oooooooooooooooo 


ID'ONCDO'O^MCO^f tf) >0 I'' <X> 

<X»C0 00 C0CDO , ‘(>O'O^O'- 0^00^0^ 

ID ID ID ID ID ID ID ID ID UO UO ID UO ID 

OOOOOOOOOO oooo 


NO* 'ONOOO'O^CNCO * ID O N 00 

OOO O O O O ^ 

*0 *0 *C -O'C'OO'O'C'O'C *0 <i >0 >0 >0 

OOO OOOOOOOO OOOOO 


Number 43 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 

113 





££S£S!Q&^^$T£k$S££k£^££2££y^!C 0 ^^^ rao(N(JCOQ,,,<JCOO o ilJ * > oo( , )fvi'Ooo<j-<rin<j'Oinco>o*-of^<j*-m 

r)NomoffiOHjQONOHNOoc ? orjonmo^HO,o^HO- o ^n-oo- J oo^-OHroH-^ooc J o-Hoclow^o^ 

H 0 rt U0(J0U0P1000^OO^O0OO' ,, jO0U^QOO H UO0jO'<H^O0'jOO'<0)O''-OilDOOOO<[<I-"OOCOuOO 


luoMt'OaxroiiJOM^'O 

S-OOOOOOCOaOGOOOOOO'O'O'O' 

ooooooooooooo 


oN«f-oo5<icjuioc-i«t>orocu 

LUlUUJlUliJlUUJUJU.li-ll.U.U.U-li- 

3-«t 

ooooooooooooooo 


NOUOU 
O O LU <X UJ 

oci o «t o «r 
u o o o o 

III O N *f "0 
u. o o o o 
<r in in in in 
o O o o o 


in -o n oo 

cs 

O - CM 

(0 

*t in 

*0 

n n n 

N 

0j 00 00 

0D 

00 00 

CO 

O -0 -0 'O 

o 

>0 >0 -0 

■o 

-0 -0 

■0 

oooo 

o 

ooo 

o 

o o 

o 


N 

00 

o 

— CM 00 «» 

in o n 

CO 

00 

00 O' 

O'- O' O'- O' 

O' O' O'- 

•0 

-0 

>0 >0 

>0 >0 <i <> 

-O >0 <0 

o 

o 

o o 

oooo 

ooo 


CO 

O' O — 

cm 

n «*■ 


O' 

O' O O 

o 

O O 

o o o o o 

>0 

so N N 

rv 

N N 

N n S- N 

o 

OOO 

o 

O O 

o o o o o 


o -now in -os coo-Nowin-ONCo 

- - - — - - - - H WNNINCU-INNN 

S- NNNN NNN S- NNNNNNNNN 

o oooo ooo oooooooooo 


O' 

CM 

N 

o 



Page 32 

114 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 



o 


U 

B 


tO CO — 

oy h 
ic z <r 
UJ <t o 
Nl _| — 
CO Q 

3 2 

o o 

2 Z 

—■ ct 
UJ q O 
x <r x 
<x ui x 

_i LU 

CO 

LT LU X 
ZlCO 
dOlL 

-J 2 

ill (3 N 
— CL 

CO - K- 
LU O UJ 
> Z tO 


Oi m 

<r <r n 

ill CQ X 


UJ X h- 
ZEUJI- 
“5 "J (0 X 


CO o 

X 
UJ UJ 
Z K- 
- O 
K- <1 
X X 
O <1 
CL X 
CQ O 
X 

CO K- 




U. 

o 




CL — 


X 

O 

O 

<r 

o 


CO 

UJ _l 

o 

Z 

1- 


CL 

1- 


CO 

CL I- 

CL 

0. 


CO 

<x 



UJ 

UJ u U. 



£L 

if) 

X 

CL 


CL 

1- HO 

u. 

U_ 

UJ 

^ UJ 

(j 

UJ 


Q 

C CL 

O 


F 

Z CL 


h- 


Q 

<L <Z UJ 


O 

o 

— D 

CL 

o 


<c 

CL 13 

UJ 


<r 

_l Q 

O 

<c 



<1 O _l 

D 


CL 

<1 

Ll 

CL 


* 

x <r 

_J 

UJ 

S ^ 

z 


<1 



UK J j 

<L 

o 

x z 

- UJ 

CL 

X 


O 


> 

<1 

o — 

h 

35 

(J 



CxKUJ 


Ll 

_1 

CL <r 

i— 


o 

O 

LU 2 CL 

UJ 

CL 

H 

to _1 

UJ 

to 

CL 


1- Z» O 

X 

UJ CO 

? W 

3 D 

if) 

<r 


CL 

D CL h- 

B 

1- Z 

CL > 

O 


X 

U 

D 

CL O CL CO 

i- 

z o 

i- <r 

t -1 



> 

1- 

K CL O UJ 

(0 


2 w 

o <r 

Q. 

N 

<1 

UJ 

U CL O CL 

LU 

f- 

o 

CL O 

O 

CC 

to 

to 

O Ul _J 

CL 

UJ <L 



K 




iL 


X CL 

CM 






Z 



X > 
a o 
uj z 



* 








Gy 





o 




CL 

CM 



X 

CM 



o 



CM 




CM 

K- 

CL 

eft 



X 





eft 

q: 

CM 



CL 

CM 

CL 

O 



X 

* 


* 

Z 


z 

X 

z 


»- 

Gy 

UJ 

CJ 

— CL 


UJ 


D 


l— 


- CL D 

X 

K- 

'4 

O 


Gy 

k 

ID <1 f- 

z 

& 

z 

CL 

z 


z 

CL CL X UJ 

u 



3 


o 


O X O CL 

K- 

6 

-i 

Gy 

_j 

CL 

_i 

»- UJ O ®l 

«sy 

X 


> 

> 

> 


X 

3 X X © 

> 

o 


o 

o 

o 


_J Z Z O 

O 

g 

<i 

z 

z 

z 

_i 

CD "J “J Z 

z 

z 


o 

<0 * 

a z 


X UJ 
X > 
*“ « 
x to 


X > 

a o 
uj z 


K- Z 

_ 


* 

w 

—i 

X 


Gy 

CM 

if) X 


CM 


* 


z 



Gy 

h- 

X 

X 

CM 


UJ UJ 

3 




Z CO 

h- 

CM 

X 

CM 


LU 

+ 



1- X 

X 

X 

CO 

X 

X o 

Gy 

D 

X 


O CO 


CQ 

D 

<r 

X X 

X' 

Gy 

CJ 

X 

CD D 

z 

* 

X 

o 


a: z 

o o 

iL >- 

K 

(0 W 

CO CO 

UJ o 


B 

Q 

<r 


LU C 

K- r 
X CL ► 
X O C 
I- IT l 
X CL C 
O UJ 


_1 

- o 

~ CL 


CL CL UJ 
O CL CL 
h- UJ >&J 

CL 

3 Q. > 

jcg 

|X| “J Z 


* * * * * CQ 


*«***: 


CD CM * N CQ 

N u UJ o in 

O MJ O N * 

o - - o o 


* o (» <r o uj 

•O *0 *0 *0 >0 -0 

o o o o o o 


O CM (0 * ID 
* * * * * * 

(» 00 Oj CD CO (0 
o o o o o o 


O rs CO CK 

* * * * 

<» <D 00 CD 

o o o o 


— CM0)*iD*0rNtD0'O 
ID ID ID ID If) ID ID ID ID 'O 
CD CO CO 00 CO CD CO CD OJ CO 

oooooooooo 


OCQCJC&ffiUJCJCJCOaj<IOC4CDOCOOQU 
0-1 o O' <1 C>l O <1 CO CM CO CM O Oi O O O O X UJ 

-oaioNNOcooaoflJocio«roocN 

OOOOOOCJOOOOOOOOO-—O 

o cm * -oaxcoujocN'r-ocDcoujocM 

CM CM CM IN CM 0-1 CM CM CO CD CO CO CO CO CO CD * * 
'O'O'O'O'O-O'O'O'O'O'O'O'O'C'O'O'O'O 

oooooooooooooooooo 



N 00 O- O 
>0 yj >0 N 
w CO CO 00 00 

o o o o o 


UJ 

oocMOCMtnoa 

0 - M ffl O CD U - ) -O U. 
000CQ09 t CO 

oooooooo 

♦ -ocoaoujoM 

******^¥0 

*0'0'0'Q'0'0'0'0 

oooooooo 
— <M co * 

N N fs. f 

00 00 OO 00 C 

o o o o < 


***** 


) N CO O' O — CM 0) * ID 

- C- rv N OJ 00 CO CO CO CD 

) CO CD CD OJ CO OJ CO CO CO 

>000000000 


«*CDOSUJO<rOOOtM<r<rt_>OCMCQO<IIDOCJOtM 
UO O O' O ^<I(DiN<INCJUJNOaiOOOOUJ^NCQ 
2 mgcoo<ioo<ioo*ocQocMO*ooMooo 
ooocjocjooooooocjoooo — uooo 

«t-OIBCOUJOC'Df'OOJCOUJON^-OCO<COUJ 

IDUOIDlDIDlDsO-D'D'O'O'O'O'ONNNNNNNh. 

'C'O'O'O'O'O'O'O'O'C'O‘O'C'C'C'C'C'O^'C'0'0 

oooooooooooooooooooooo 


CM CD * 

O' O'- O 1 - O'- O- 

00 CD 00 CD 00 

o o o o o 


CD 

* « 

o 3 

UJ 

X K- 

o - 


Z CD 

o <t 
3 

a 

Z h- 
X <X 

o x 

X 3 


UJ 
Z X 
CM X 
- I&J 


C-l CM ~ 
- - CD 

cq aci <r 

<1 <1 III 
III III UJ 


CO - 
<1 *0 
LD CL 


a - 
<1 o 

ill OL 


CM 

CD CO CO 

— — I 
CO CQ - 

<i <r -o 

CQ CQ CL 


k- a 

J UJ - 

■o ~) <r 


n 


CO CO 

- - CN - I 

CQ CQ CQ CQ «* 

<i <i <r >0 <r -d 

CQ CQ CQ X CQ lL 


1-OQ.ir CL 
JUJZ_IZ~ 

"0 “o “o o ~j <r 


z <r 

ID \ 
— I 


s? 

CL Z 


o o 

X z 


£L CK a 
- CQ _l 

id <r x 

X CO Gy 


> UJ o 
O Z z 
Z - 


- CD 
CQ - 

<1 to 

CQ Gy 


CL > 

z o 
“0 z 


<3 CD 

UJ Ul 

“ z 


<r - 

CN CD 

<r co 

CQ <SJ 


U! 

z - 

-J o 


<* o -o 

- O CQ 
00 CQ O 

- 00 o 

<r o uj 

OJ C0 CO 

id no no 

o o o 

* ID 

00 00 
N N 

o o 


CD N O 

- - CN 

- CO 0J 

- - 00 

O CM * 
0^ ^ O' 

no no id 

O o o 

O OJ 
0j 00 CO 

o o o 


o o o 

O CM * 
0 0-0 
O O — 

MO 00 <1 
O'- O' O' 

uo no uo 
o o o 


o - a 

0 j * 00 
(MO- 
O O - 

O UJ o 
cn O'- <r 
uo uo no 
o o o 


- 0-00 
OO * - 
(MO- 

o o - 

CM * *0 

<x <r <r 
no uo no 
o o o 


OJ O'- O'- O' O' 

n n n h. 

o o o o o 


IlDO-O 
O C-l UJ OJ 
00 CM U. CM 
-OU.O 

oodunj 
<i <c <x <r 
ID no ID ID 
O O O O 

* ID MJ 
O'- O' O' 

N N I s * 

O O o 


— * >0 
* CO CD 
O — CM 
0—0 

O CM * 
CQ CQ CQ 

id no no 

O O o 

N OJ 
O' O' 

o o 


-0 rx 

* o 

o - 

o — 

>0 CD 

CQ CQ 

no no 
o o 


-0 U. -<J 
O CM O 

00 o * 

— — o 

<iuuj 

CQ CQ CQ 

ID no ID 

o o o 

- O — CM 

- O O o 

• OJ 00 CD 

> o o o 


CQ CQ ill ill CQ CQ CQ 

<i <r <i <z c <i <r 

CQ CQ CQ CQ CQ CD CQ 

O |-J Q O (M U CM N U -O - -0 O CO o - <t - <1 CM <1 UJ <t O fj - O - <0 u bO 

O CM U. CM u. N o - - o O' O - CQ O - MJ no O O - O OO ID O CM o — * * 

-OlL-OlLOOOUOWOduOO-OO-UO-OOOOCOO 

OCM*>OQJ<rCJUJOCM*'OOJ<ECJUJOCM*'OC!J<r<JUJOCM*'0 00 <X(J 
^S?!^.^^y!^9R Q 9 QQQQQUJU,UJUJ,JJUJUJUJ ^LLii-u-^u.u. 
u j ^o no id no no uo n j no no uo no no id uo no uo uo uo no uo no no no no no id no id no 
'-’OOOO-w'OOOOOO OOOOOOOOOO OOOOOOOO o 


»******CQ 


(JUJU -0 

uj <r o co 

— O -0 CM 
0 0 — 0 

UJ O CM * 
U. O o o 
no vj -o -o 
o o o o 


CQ CM U U u Ul OJ 
CM O CM 9 CM <E UJ 
onsONoo 
O—oOGO— 

-o co <r o uj o cm 

OOOOO— — 

vij -O -0 Mj Mj -D -O 

o o o o o o o 


CO * no yj N 

o o o o o 

OJ CO CD OJ CD 

o o o o o 


OJ O' 

o o 

CD OJ 

o o 


o —CM CO* no -ON 


— cm co*uoyjr^QJC "0 — 

CM CM CM CM CM CM CM CM CM CO CO 
CD CO CO 0 j OJ OJ CD OJ OJ CO OJ 

oooooooooo© 


CM CO 
CO CO 
CD CD 

o o 


* ID 
CO CO 
OJ CO 

o o 


•o oj cn 

CO CO CO OJ 

OJ OJ CO OJ 

o o o o 


Number 43 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 

115 


h n n 

<e ce ce 

> > > 

<r <i <r 

WWW 
4J 4) SJ 


• tt 

O C5 (M 

ce * <y a: a: 

> D CE CE (E 

O O _l G G 

e uj o a o 


u u u 

<r <i qi m ot <i <sj 

Q.NN - <t - ** - 

o#»o «o * o 

I- G G CE g ce J(C 

lL 

3 1 L G G 

JEECD uj CD UJ m 

c mo “50 “50 


m <r _i <r <i z 

2 -J o Q. iE _l 

K » o 3 B 8 

CC LE LE CE LC ir 

X X X X X X 

o o o o o o 

<X <Sil CD <SJ <I0J d <8J <L €ti d ®J 

^ > io - *r - - >o - io- 

* o * o * o * o #o * O 

—I 01 -ICE _J CE __J CE _l LE _l CE 


G G G G G G 

UJ CD UJ CD UlCD UJ CD UJ CD UJCQ 

“5 0 "5 0 “5 0 “5 0 "5 0 TO 


<1 CE 

e n <r »h > 

«fc! d CE I CE UJ 

► (N - O - W 
05 * O O CM d 

<E G CE <&J (E OCi 

D G > > 

G Ui O G O 

UJ O ~ E CD Ed 


-*«f(N>OP5a5«*dUJ< 

OdOdOdOdQl 

ffloaiocaocDO'O' 

ooooooooo< 


OQQQQQQD 

'O'O'O'O'O'O'O'O 

OOOOOOOO 


' \ ' \ \ 

'00<r<X)-H-*dCDddUJI0005^00C l 500‘ 

WdOONdCONOWO^U-ONNONCMOCN 

■OdOOMdON-O^OOCDOnCDOncOO 

OGOOOGOOOO-*-* 0 'O-« 0 'O-« 0 'O 

'OCOdOLJGC'I'f'OOJdOUJOCI^’Offld 

LUUJUJUJUJLlU.U.U.LlU_U_U.OGOOOC 

'O'O'O'C'O'O'O'O'O'O'O'O'OfsNNNNfv 

ooooooooooooooooooo 


22S22SdoiiiNouiioitNooH( 

MONJOCO-ON-ONNONnOCOOC 

0)00005a50C5G50P505005000COa50<*< 

^^O^O'O-5'Oh^Oh^O^^Oh' 

OWOM^'OCOdOlUON^'OCOdOlUOC 

rvrsr'Nrvrvfxr^fs.t^rs.rsNNNNrsNNr 

oooooooooooooooooooc 


a* o — c 

10 >0 >0 • 

CN O' O' < 

o O O < 


C5<r*or''0)0'0-*< , >jw«r 

'O'O'O'O'O'ONNNNN 

O'O'O'O'O'O'O'O'CNC^O' 

ooooooooooo 


00 O' O CN CO «flO 

NNWOO 00 00 05 00 

^ ^ ^ ^ 0'^ O' O' 

oooo oo oo 


ivC Z. S' y £ £ £ ^ T ^ ^ u; o rs oo 

00 00 00 00 00 00 00 O'O' O'O' O-O' O-O- O' 

CN O'O' 0'<^ O' O O-O' O'O' O'O' O'O' O' 

o oo oo oo oo oo oo oo o 


O' cs w <r in o 
O' o o o o o o 
O' o o o o o o 

O ^ 


O'O'OO! 
CO O 00 Q O « 
IX ffl O CO - ' 
0030 hU( 

'TVJCOdC 
CO (0 (0 CO ( 

N |>. fs» IV f 

o o o o < 

N 00 O' O CM C 
OOO- - - ■ 

OOOO O O < 


O o CM G 
dCK^f 
>0000 
OOOd 

GUI OCN 
05 05 «r <* 

N IS. N r> 

OOOO 


CE 3 > 

O UJ — 

W Z K 

OE d 
D O _l 


d 


*-« G 

3 


UJ 

»- 

H * 

0. 

W _J 



W h- 

z 

UJ z 

D 

O *-f 

CE 

O 

UJ •- 

UJ 

CE — 

P 

CL 3 

Z W 


CE x 

w 

-J 

UJ 


O Q 

QE 

CL UI 

UJ 

h- 

W 

CE U. 




CE 

o UJ 


O D 

l- lE 

CL 

H CE 

CL 

0. > 


W CD 

►H <1 

D 

D O 


K d 

CL 

CE 

W UJ 

1- 

O. CE 

N 

D W 

O 

D - 

O _l 

UJ 

Z CE 

La 

O 

»- 

O O 

CL G 

W 

UJ 

O 








N 

o 

CE 












CE 

«SM 

(N 






CE UJ U. 

s 

*4 



CE 



(N 


O CE 

K 

(E 

OJ 



* 

<M 



W W 

UJ 





o 


(E 


CE CE v-. 

S 

W 


0. 

E 


CE 


h- 

— 1 o 

<£J 

CE 


O 

UJ 

CE 


C4 

D 

G W UJ 


D 

d 

»- 

H 


-4 qI 

+ 

n* o 

CE Z 


G 

lL 


<SJ 


00 E 

U. 

CE CE 

UI D *-• 

Z 

Q 

D 



Z 

CL CE UJ 

D 

• D 

>Gh 

*“* 

CE 

CD 

4J- 

o 


O CE l- 

CD 

— G 


o 

3 O 

a u. i- ie 

• UJ O I- 

W E W W 

Z DlEdZ 

OWUJlH 

*-« W Hi 

I- d E UJ Q 

O D Z Z 

Z W Z d 

D *-« I- 

U. E D CE 

G D O UJ 

OXEIO 
ZdHfllUl 
w E x j h 

I- d w z 

— • E 

Q CE W 


UJ UJ UJ »-• h- 


15 


O I I D 

E 

CE 

X 

UI UJ l- h- CL 

Z 

»- 

Z 

Jh Z 




o z o . *-« 

G 

II 

G 

W V- l- 


U 


Z D CE 

UJ 

CL 

UJ 

O h- CE CL O 

> 

> 

> 

GDUZ1 

c 

r 

d 

CL _l - 

w 

CE 

w 


W Z _l E 
UJndZD 
_J G G Z 

q a z 
Z z UJ 3 •-* 
d d I o 


> 



lal 



(0 



‘I 


CL 

CO 

> 

D 


UJ 

H 


w 

UJ 

> 

d 

W 

'i 

CQ 

05 


CE 

Ctl 

UJ 

O 


0. 

"5 

iC 

> 

d 

z 

h- 

E 


O Z K 

* — CE 

-i * _i a 


D > 

N 

CL D > 

CE 

3 

G O 

UJ 

EGO 

G 

o 

UJ E 

W 

■5 UJ E 

G 

z 



O 



E 


CE 



D 


>- 




UJ *************0 1 

CQOCW >0 00 O G 00 05 

in>6lL 05 O O' d CO <N 

** <r> -o 03 o d o o 

OOO OOOOOO 

O CM »t -0 00 d O UJ 

05 CO W 00 00 00 05 CO 

>o>0'0 ■O^'OsO'O 

OOO ooooo 

•ON O'O^C'JOO^-in'OrsOOO'O^NW <r l 

O'O' O'OOOOOOOOOO — — — — — 

0505 CDO'O'O'O'O'O'O'O'O'O'O'O'O'O' O' C 

OO OOOOOOOOOOOOOOO o c 


************_ 


******* G 


E dOOCNfflNdNONGUJ^OCDOUJ WCDOGUJ^CMCDOOUJ 

A UJCJOCDONOONffl-OHOOIOOUl OQOdMO'OOOdUJO' 

5 tOfflONO^OOOOO^ff'O^O -OCDONOOOfflO^O 

5 o o o o o o o — a o u o d o o o o ooooooooooo 

r >0WdouJocM<r'000doujoM^'0 oodouio cm «r >o w 

' O'. O'O'O'O'ddddddddOQCDOQCD cd m m m g oooo 

5 'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O'O >0^*0^^ 

5 ooooooooooooooooo ooooo oooo 

^ ® * 8 r! Cl s?. £ *>3 £ 0'0-<CMC*5«riO'ON050'0-*M 05 <* 1/5 >0 fs c 

£ r* 7* £ £ CM CM CM CM £1 CM C-l 05 05 05 05 CO 05 05 05 05 CO <* «T * 

£ O' O' O' O' O'O' O' O'O' O' O'O'O'O'O'O'CNO'O'O'O'O'O'O' O' O' O' O' O' C 

OO O O OOO O OO O OOOOOOOOOOOOOO O OOO O C 


i.f\ (j\ i.f' (.'' (A kA O' O'- tA (?' CA O'- O' 

OOOOOOOOOOOOOO 


05 O' O M 05 ^ t 

<* in in in in io i 

CN O' O' O' O' (N ^ < 

o o o o o o o < 


Page 34 

116 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 



H 




U. 

1 - 



1 





o 



IE 




> 

X 



1 - 

1 



(E 

D 

w 


(L 

I-* 


W 

1 - 

o 

05 


IQ 

o 


D 

Z 

II 

-J 


11 

LE 


(E 

w 

1 “ 

<r 

c 

IE 

9 


h- 


n o 

Ul 

o 

»- 

o 



0 ) 

O O 


II 

1 L 

ii 


n 


II w 

II* 

1 — 

IQ 

h- 

f— 

w 


h- a 

w 

o 


o 

o 

CL 

05 

o 

LL 

(E 05 


IE 

o 

> 


CE 0 ) * 

> 

D W 

o 

9 

UJ 

f- 

X 

D W O 

K 

O > 

Z 

o 

Q 

ffi 

1 - 

O > z 

CD 


> o < j o > 

O W UJ W O 

E 1 Q Q C 


Ui 

- Q 

a: <i ® 
- <n - 

* 

j*a: jq: 


co 


0. D I> G > 

z a o w o 

O LU E O E 


D 

5 

UJ 


* 
a 
a: 
«o i 

* o 

_l <SJ 


(EDO 
-I G 2 

o u - o 


Cl D 

z g 

“5 UJ 


m 

(EDO > 

-J G Z TO 

o w — o -on 


a. d 

Z G 
“5 UJ 


(EDO > 

-J G Z X O 
O W - O “5 Z 


CL D > 
Z G O 
D UJ Z 


-J * * * * 


3 

'0 O 

* z 

_|******* 


J******* 


co^('>j(oouj>oo«'0ujco«a(o«oo<r<r 

<ioociONNHO<i»ro>oNujHiii 

OCO-0>0(aOONOONOCOflQO^ON 

0-0000000-00-00000 


<rouow^o(D<ro 

CNOv(K<r<i<r<i<i<r<r 

oo oooooooo 


UJ O CM *»■ -O 00 

<X CQ Oi di CCl CD 
NNNNNN 

O O O O O o 


»o<rff-oiooitooNUJ 
o co oc> o c-i o w cm <i cm u. o 

♦ MflCDOm-O-O-OON 
OOOCOO — QOOO—o 

<r owocm«t>ooo<io 

CD OlCQOOOOOOO 
N N NNNNNNSN 

o ooooooooo 


fo«f fsjinooooNci 
CJQCOO<NOWC 5 <I<MU.W 
«* N in CD O CD — 0 - 0-0 0 1 "* 
OOOOOO — QOOO — O 

UJ ONff •OOXtOUJO 
O QDuuuuuCUJ 
N NNNNf'vNfsNN 
O OOOOOOOOO 


•OHOLOON'OOd 
OUJCDOCJOUJCJCIfJLU.N- 
^MOCDOfll-O'O-OONOO 
OOOOOO — QOOO — OOO 

CM -0 00 <r O UJ O CM M- >0 CO 
UJ UJ UJ UJ UJ UJ UJ lL u. u. u. u. 

n r^rsi'vNNNNNN r>* n 

O OOOOOOOOO OO 


— cm q »r io 

CO 00 (D CO 00 

o o o o o 


NOOOO- 
OD 00 00 O' O' 

o o o o o 


CO^in-Or'-OOO'O — CM 00 <t 
O'O'O'O'O'O-O'OOOOO 

ooooooo — — — — — 


OMCMCMCMCMCMCOCOCOCOPOC 



WOWO«tOOOCMOOO CM COCOC 
<T'0(Mj.lfiO<ir^«r^«t05 03Of< 

noocon - >0'0oooooinini£io 

OOO—OOOOOCQOOOOO 

WON M--0O5<IOUOCN<f*OCQ 
in in inininininm-o-o-o-o-o 
n r- n NNNNNrvNNNrvN 
OOO OOOOOOOOOoo 


) O' — CM CO 

• — CM CM CM 

* o o o o 


<r in -0 I s * 05 O' O — CM o 
CM CM CM CM CM CM CO OO OO 00 

oooooo oooo 


<r in -o 

00 CO 00 
OOO 


1 ^ oo O' 
00 00 00 
OOO 


ocmo^-o«ooooo<ioocd 
CM <1 «0 <1 « <r w <1 0-1 <E W <1 uo 
OOOOOOOO—O CM 0<f 

oooooooo ooooo 
<iouocM<r-oco<rowocM 

O-O-ONSNSNNNS0CO 

ooooooooooooo 


M-O — OO0OCO-O-CO-O 
WUI (O <t (M O UI 0-1 -OliJO'-OU. 
N — O-0-0«t<OtC0Nt(0 
OQOOOOOOOOOOO 


«f-O0<ruiijofu 

c&oocdcdoocdo'O'O' 

OOOOOOOOO 


<> 00 
O' O' 
N N 

o o 


— cm 05 ^ in -o h* oo O' 

OOOOOOOOO 


in c-* a) o o — cm oo in 
in in min-o-o-o-o-o-o 

O OOOOOOOOO 


r- oo 
•O -O 
O o 


ooM-m-orsooc-o 

rsNNNNNNOO 

oooooooo 


Number 43 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 


117 



iuo:'0*o<r'tooN'0(»oii.«fooo<'0 
O « Mb. <1 u O O O O CO O' O <1 <1 CD C O ffl 

oo-o-(Nnoooooooooo«fcoo 

ooooooooooooooooooo 

- wz a 

y: o: o: a: cm — y « i- 

OJd O D D E H h W z J 

xcriCO^-N CM Oh3>o<[<i<IO 

<iE(ja.i(Lo-(N<iQUJo<rHi-E(Eii: 

rzooooactaQicrcrtrcococoHi-s 


^>touj(M<i<raiiLin(M»oN<ro«r'j-<i 
oiHCjQ^«OHOooo^co<r<iHaiHffi 
O O >0 — CNCDOOOOOOfvOOOOCDO 

ooooooooooooooooooo 

N K CM (0 

o z o: ^ sjO'tiCMQ: 

0- _J <r CO CO DEttltWhOD 

ooiNtoc-in cn 3 :> > <x co <r o 

OOOCL£LQ.E-«yi(MJO<I<IElU(EQ: 

-izoooocLtrtrcEcrtrarcococoHf-z 



N 10 ^ CM 
O' O O — 

o — — — 


CM O OOW-Off 

oo - «*■ - in oo - 

CD 00 O' O O — fv 

o O o — — — o 


00 00 00 ^ CM O O 

oo co «r mo r-i - 

N CO O'- O' O ^ N 

O o o o — — o 


00 >0 CM CM — <t O' 

o-i oo <r >o in o o 

N co O' O' O — r- 

o o o o — — o 

CM ID in O O 0J O' 

o oo n -o in O' o 

N NirO>OON 

O 0 0 0-1-0 


ajoo«ruj<io<iuj<rcoou.ocou.CM(joci 
O — W(XiffiCNOOOO'»N<t<ir)CDOffl 
OOO-CMCMinOOOOOOOOOOCOO 

ooooooooooooooooooo 

(M 

Z Z O iCiCOOJxi- 

*_J3 <r - i- cn — a: cn (L a 

zoo-<rinzo<f co<i>><ie<iq 

— oq:o.q.q.<i — - <rcoiuz<i<iziija: — 
jzzoooo.cnra:ci:ci:Q:oHiurthh3 


iv rv >o *t n 

10 00 O' 

— N 00 N 00 

— O O O O 


CM 0D (M O' O' — 

00 iv >0 IT) O' O' 

>0 O' O O <1 

o o o o — - o 


O-OO'H 00 M o W 0"0 o 

«*■ <r co oi> io fv O'- io oo oo io 

NNIVIV >0 N O O' O O >0 

OOOO o o o o — — o 


O' CM MO 

<* ■» <* 00 

N ID - 00 

O 0-0 


(M O CM CM 

IO N O' CD 

>0 iM O - 

O 0-0 


«0CO>O-O<»-COOOr''IONOO — <fr'0<»<f00 0'. <r«t-0'ONIOIOOONO'.«*'OOOCO—O'.^'O^'OO'C'OOOONIO'OOOO'OO 

r^io — ooooo'oooo'o — N00C000't00rv0000 0'r'00i0r0C0«f«r^-'0io<i'Oiorv0'N0' 00 00 00Oo-rvoooo^-ivoooo 

O'OroNNNOHOOONroNNNNNSNCD-CO-nOOO'O'O'O'O'O'O'O'O'O'O'O'O'O'O'OSNN'O-N-iNO- 

OOOOOOOOOOOOOOOOOOOOOOOO — —OOOOOOOOOOOOOOOOOOOOO — o—o 


CM'OOGCMUJUJ — QOON<roUJyOliJliJ<I'OMO 
0000-U.N<TOOOOOOO<IO'<r<I-OCQCM 
OOOOCMOJOOOOOOOnOOOOOOOO 

oooooooooooooooooooo 


o 

Z 0- UJ CM _l y 

J3 Q- Z « il CC Z J (COO 

Z X o O * * rv oo — O > > O CQ Cl UJ <1 

ui<ra:Q.cLa.Q. — —oonq— i-<r — coq-z 

JEZOOOODCiritllCQCirQCWCOI-hDN 


00 O <* CM -O CD 10 rv N O 10 OO IO N 00 00 — >0 O' CD o <r 

>o iooooo-o-('^'r^«f<r^coooaiNO'«o 
O NOOOOOOOOOOOOOOOOOOrvrvrvNOOOOCOOfvoO 
O OOOOOOOOOOOOOOOOOOOOO 

<1 Z <E Z - Z 

ZOCMCMCDIOIOlO'OrvOJ <I<I - > 

— |fi<3 r «.C0^l>C' OQ 111 LxJ 

o ie m cq m cq cq cq qq cq cq iii cq cq co cq co cq cq co co co co 
o:#<r<r<i<r<r<i<E<r<i<r<i<r<ri<i<r<i<i<r<i<r 

<XQ3CQCQCOCQCQQQQQOQCQCQCQCQCQlOCQCQCQOQCQCQCQ 


-OCMNO'( v )0'OCD'0(DOrvOO-N«t-OrvCMIOiniOCD«r 
(>ininioir»'0>oNr'Nrvco(Doao'0 — — — 0'«t^0 0'0' 
0'0>0'0>0'0>0'0>0'0'0'0'0'0>ONrvrv|vO'0 — ooo 
000000000000000000000-000 

(0 

D <r CQ C_| Q <1 <1 CQ liJ <E CQ :>C 111 

oo—CMC v )«t«r*t^*j-inu‘>>O'O'Oi^ 00 D'O' cq cm id Ol 

CO CQ CQ CO 03 CQ CO CQ CO CO CO CQ CQ CO CQ CD CQ CQ CO Z Z * ■! > U. 
CQ CQ CQ CQ iBCQCQCOCQCOCQCQCQCQCOCQCO CQ f H if* ft ) r Q |t*i rri ra 


o o o o o o 


<r cn o: cq _j — <x <r <r <r o 

eMinoo d u <r <r u. d * uj y z - <i o ci t co - <r o: 

---(D oow-ococq o o_ia:*a:co*<Ninh'Hin--- — cm(nco>oO'HO a «i u. 
cocncncQ(ncocDCQaioQZu.o irirttoQcci-iEairH-EZEzzzzzzw-pxf^D 
c<i<ic<i<iHHHHH3(M<riiiMDEziriZ£i:xzii:Q:£i:Q:ccQ:ccira:z#««#ffi 
£QOQCQOQCQffiOQCQCQOQCQCQOOOOOOOQUiUJliJUJUJU.lJLli.U.li.U.Ll.U.U.LL— _l_J_I _l 


-J X U O CL 

o a uj lu — 

CO <r CC CQ Q 


CDO*OUO'OWOgOO<rO>OOOOCOUJOOC0<»-«IUJCM<ILU'O<r<ICO(DCM«*<XOCO<ILiJL,UJCM 
^QIlCOOO^-OODQ — — 0 0('0(NCO(MlO(M(M — li.U.LUCMO' — OU.CMlOCQ^O'CQCjQ^OUJ 
^ininm'OQ'r^^^oooooooo-oo - — cococoo — cncmcmococo — — -o -o >o r- n n 
oooooooooooooooooooooooooooooooooooooocoo 

<1 — Z W4I-Q 

O 10 N ffl « UJ J £ J Q. J Z CQ QONWNO^'O <E Z 

— — — rv^-ujCM'riOrv (LopooQ.30u.ii-«rM>><i----C'iNC4>ocoD a> <i 
mCQCQCQfflffCQaQfflmZiyOOIXCECirCQOQCQCQQCQeaZZZZEZEZEZOCM'tOG'- 
aCCCCflHnHNnh — ^ZlIID-ZCCCQQCCQJCQCCCCirLQCrCQirCCZ^^^W^ 
CQCQCQmCQmCQCQCQQQCQaiOCJOOOOOQUJliJUJUJUJU.U-LLU-liU.U_LLU.U.«-JJJ.JJ 


<r co — 

CQ - U 
h- CE ifi (£1 


DO UJ > D Z Q 
I GO Z O G I— UJ Z 

-)<rujo d z uj o: 51 uj 


* * * * *C***H 


^OCO<I'OUJCM^«»tUJ(»0<r^U.OO'CM^>OUJ'OCM>0'»-OOCMUJC-l<IOOOO't<IU.*OOUJ'0 
OOUJCOIlQCD'OCO^U.OOOCMCMCMCDU'OCMCQUJOU.CQO'ICOQCMU. — ^■OQCMODOOUJCQcIO' 
cciinininino«t^«f^tnoooooo-oooirj«trt-ooo-NNO«w^-oo-<jNSN 
OOOOO---j. ...--- - 


lOOOOOOl 


>0000-000 CO «* <0 -O O O — CM CM CO <0 <0 — — O O -0 N h' t-* 

JOOOOOOCOOOOOOOOOOOOOOOOOOoO 


z co -o <r <r m uj y 
<x - - ,0 u — ^•io-00'cn 


<i z cr <r co u 

1COUJI- Oil-EO 


<r o oq 
b-y — CMOO'COin 


CM O O O O UJ 
O <1 UJ O -O Q 

CO ♦ -0 00 ■o 

—OOOOO 

do LJ O CM 

u. Ul u. o o 

N rv N 00 00 

OOO o o 


ffNO— QOO<I—Nf ffl 
OCOOOOOUIOOQ-lf/ 

oocmoib — cd — oo — oo<r 
OOO — <1 O PI o — ooo 

O 00 <1 O UJ O CM <*■ <1 

O O O O o o — — — — 

OO 00 00 CO CO *00 OO CO oo oo 

OOOO OOOO oo 


co*- i n *0 cocxo — cMCO«ruo<oiv coo-o- cm co ^ in -o 

ZZ Z Z — 'OyOO-O'O-O 


dlilOOOLJOfflO<J''OONU'J , CQ«rinU.IUddOOUJOU«'0>0'Od^lUd>OCM>0^dO 
CMCDOCO-U-C'linOO^U-OC'-IOiNCMCOCOCOOC'IOCOIOUJ—OOOC'IMO — COD'— NOO — LlCOCXQ 
oinifi^-offf<f<f<r<rcoooooooooo^ - >ooo — — — cmcmcooocd — — oonnnn 
ooooooooooooooooooooooooooooooooooooooooo 

ZZZ JZd CQ<r<I G 

cm io — aa cq o — _i co— — — cm in cd cm in ocz 

---in0'CQO«f«r>00'CM<i ozooz -c-iinco_j<r----c-ioj^r^i--.CM<i<i 


Page 36 

118 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 



CO 

o 


o 


— o 



*0 

O' 


-0 CM 




o 


00 O' 



io 

" H 


o o 



o 

CM 


o CO 

CM 


•O O' 

00 


-0 -4 

oo 


N CO 

O 


00 ^ 

10 


CO - 



o o 

o 


o - 

O' 

CM 

£ 00 XT 

00 


- CO 


O' 

CO — O' 

N 


N CM 

o 

O' 

O N 00 

10 


CO - 


o 

- oo 

o 


o - 


o 

*o n m - 

O' 

o 

O N 


O' 

O' - O' 

o 


CM O 

o 

O' 

O -0 OO 00 

10 

o 

CO - 

*« 

o 

^ o o o 

o 

—■ 

o - 


CM O' 00 0*0 

10 - O' - - 

io O' c* in o 

o o o o - 


O' O 10 ~ CM O' 10 
00 10 O' O' »* O - 
IO 10 00 O' 10 o 
o o o o ^ o ^ 


hh(NOC'CNh^O' 

<rcsnr0'co<roo-oo 

C'ioioco0'0*roo 

OOOOO-O-*-* 


*0 <» <t 10 10 O' CM 

C* N - CO 10 10 O 

•+ >0 CO 00 O IO <*■ 

0000—0 o 


N CM >0 

10 O' -0 

CO CM o 

o O - 


(ONNff (NN'OO'Oh 
OMOO'IOC-GOCOCONCD 
>0>0«tCMC00'O<f0'O 
000000—00— 


<1 OCOO'O'O — —CM'tO'OCO'OIO'O — 1000^10*- — CO — C3 O' CM C» — OODfr^COOIOO^CD 
— i'MCM'OC'OJCMIOIOC-NO'O'O'ON — «r«T*t--OIOCO*'NOG'OOCMCOO!)CX>0'0 — NCMOO*0 
10 10 10 10 IO 10 CM CM CMCMCNCMCMCMCO—CMO'O—O O'-* — O'O'OO—OOOO— O — O— —— O 

oooooooooooooooooooooo — — oo — — — — — — — — — — ——ooo 


I00'*000' — — 00> r-'ONO'lOOOOJO'NOO — OOCMN CM 
O-OON^TIONIOIO -OCO>OCOIOO — — CMCM<TC0O'0' 10 

_o — o — — o — co cocMCMCoco<j-<r«t-<r«t<rmioio - 
OOOOOOOOO OOOOOOOOOOOOOO o 


<Z CO = _ 

OO •* *t 10 10 <0 <1 <1 CHCITZIO 

CM«NCMCMCMCM(0«tlO'0>00*05000'l-r01-*-'<I OCMCffi <1 <X CQ <X CG <1 <1 ll. * 

EIZEEEErEEEEErEZlLZWhEO-HMciO)(0^^«noiO>D'ONN(KDZ2 

aii:ci:a:ccQ:ci:ci:ccccci:iCQ:i£Q:Q;hzzz3MM»#MM««#»«*w*tMH(»#«Mi»#QjiuM 

■l ll ll ll ll ll ll ll ll ll ll ll ll ll ll ll >_< >_ I I I I I I 1 I I I I I I I I II I I I 


O O ¥ 
<r h- E CL Z CO 


EE^zza: 


EIEEEEEEEEEEEEEElLZ(01-EO--CMNO(0-t«r«tlOIO>0 

or i:cQ:£Q:Q:a:Q:Q:a:Q:a:Q:<£a:a:>-zzz:z***** «>«**«*** 

Et. Ia. Lx- Ll Ll. Li_ Ll ll- Li_ Ll. Ll. Ll. Ll. Ljl. Li- CD *—• »—• • 1 1 _J _J _J _J I _J _J _J _J _J _J 


_l _1 _l _J _J _l _l 


oacuuEirctu 

-izrzzzzzo 


a: o ¥ 

<r CQ O Q — *-* co 

«fin'ONNZ<I 


U CJ CL Q. Q. LL a. CL CL Q. 0. Q. Q_ Q_ Q. <1 E O 

O O O O O O O O O O O O O O O Q. CL DC 



-H IS CM OO 

O' O 00 <0 
O 00 CO o 
-• o o - 


O' CM - *0-0 

C* CO CO - o 

o r* io (0 co 

o o o o o 


<rcocoooococoNo cm co o co - O' 

jl K K m ft, m K K Ml-! fk o - 


«03->OCMrvN05C'0'C'«- CMC0O-00O0'0j<fN>0NION<riO-OO-0'OCNCMO'O>0*00'-'0CMC'l0-C00'*0'0CMI00' 

O'C0COCO(OCO(OCOO''O'O'O'O>OIO'ON'ON'ON'O'O «0 00 CO — CO O' O' «t O' CM 10 CM—IOCMIOCM— — C** — — O' — CM—Cd<*00'0r'00 — CMCMOC'Nf'x.oOOO'r'rvNOOO'OOO 

>o>o cm ocM'Oo-ooO'Osjoo-oO'Mj-o cm - -^-cn^cocococococococo co co co <r<*«r<a-<rioinin 

ooooooooooooooooooooooo ooooooooooo ooooooooooooooooooooooooooooooooooooooooo 


<1 Z H J E Z CC CO |2J <1 <1 <r CO f— _l Q 111 — <1 <X <1 CD <_> <L <1 

^-J<IOOO:U.*-«U1_1D_IV-CL^ a DliJ H Z ^ E E OO) is — — h-Q<I—^OO—— CM CM CM CMCWIO'ON 00 00 O' O—CM 

<r oo oo fflffluo(JUJEa.o.a:i.o«j«E<roii: ou.co — — — cm CMO r )^-inin'OC'r'*a)COCM-_j<n<Eir)«i- — — — — — — — — — — — cm cm cm 

t pojircQi-iitirttafliiririritiriritirirMjitD-^MzrEEEEEEEEEEEEErEEr 

j^'HC'itfiij^xiaiiiiiiiiiiiiiiiHuDDj-uiHiQLi.zziEccctcciECiiccCEiEcciEttiEiEiEXMwjzEziziririrctircnrcccccciEccircnrcccccc 

fflUUOOOOO(jOCjOUOOOuO(JOOOuOOOOOQuQQUJliJljJUJUJllJLUllJliJllJliJUJlilllJUJlUUJUJUJlilU.U.U.LLli.li.LLlJ.lLU.lilLllli.L.lJ.U.lj.U.U.U.lLllllli. 


Number 43 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 



N O' 00 O O *0 O CM CM -O If) <0 00 O in O CM 10 O' <• <f O CO 10 N in >0 00 00 

-H m O' N -< ^QO-'Oin-i'OCOO ~NCOC'IO-CN«-N-<OCOCO-<'0 cm * in 00 

*■« OOIO'ON OOCO«J-in>ONNNGD CMCMCM00C0*-<f*-in>0>0N00O OO^UO >0 

-* oooo ooooooooo ooooooooooooo^ ooo o 

£ N O CM O' CNIOOOO'^NOOM^O NCO^-NOO^OOin^COOCO-vCMOO^-vOO CM 

o m o-. n o cooo-<0'inoinooo ~ocQ~<x><v*r^~&-co<r>~noo'*tr) o 

^ 00 10 'ON COOO<t<r«ONNNOO (N(NO'lOOCO'r^<-^IO'ONOOO^(N^MO 10 

-« OOOO OOOOOOOOO 0000000000000^^000 o 

00 ina50'C0C0<f^CM0''0«fr0^O<- •ONCM-*inOON«J'-vO'0COCOCMCOOO''O *0 

O in-*>00-<CMOO-<N«-OinOOO -<'0C0-<NC'l*-N-<C0NC'IO-*'000-<N >0 

-• C010'ONOO(OCO«t«t>ONNNOO CMCM(NCOOO*-<f«*inin'ONCOO-<(N<rm *3- 

** OOOOOOOOOOOOOO 0000000000000-<-<000 o 

~ cmco-<nc’ocmcm-<oO' 0 -<-hcdcm oioroinoM'O^'C-'O'Oojio^Nooo in 

O flCO'OO-OCO-’O^OinNO 0<*NONN<fNONN-'<rNVOvjOO-l O' 

co<r-ONOOcoco^-«j->oNNNco (NNNnm^^tinin-oNNO'HN^in co 
»* OOOOOOOOOOOOOO 00000000000000^000 o 


cO'OinoNinoo'NO'O''OOO^'OC0Oo<30CONCO'OOinoci«j-oin'rN'O<>NWN O' «r 

inco-HOou’)0'*^o>'OocMinO'inNO'Coo'«tNOinM»f'OON>oo'<tcoinui<io cm &. 

O'M O n >0 <0 CO !N Oj <3 ir< 'ONNNCO*HCNCMC'OC’ 0 <*<f'»-inin> 0 >ONOO-<CM( v j in (0 CO 

-<-«00000000000000000000000000000-<000 o o 

oinN<r<fr(M0'^0 r J0!)0GiinNo^-'0’-«fs(\i>0N*-0'<f''0<N<»< v )-Hin00r s '-<'00' cm o in 

'0C'00'Mn0'O00'0ONin0'inNQ'<N0'«tNO<j--«<*-'C>oin'00'«r«rin«tir.>0' oo oo co 

£^ H £|rc' 0 'O<x>(NC' : i<j-«*in'ONNNOO'- , N<NCoco«*<r<*inin'O'ONa>-<<Nco<* cm in co 

o-*ooooooooooooooooooooooooooooo-<ooo o o o 

2-rcoo'inoN'ONNoo«-cMCMCNinoin-'<fO'C'ONC'ocM-<NO'C)ocoinooooin'0«--**r*t , Po oo oo O'** 

CKcoo''0<ro'-'«t'00'^inoocoNo. c>iO'«tNOo^a'^-'Oooii _ Jinco*f«tcocoin^coin-<NN n cm -< inuo 

■o-<N( 0 - 0 " 0 SN( v )o«tif)' 0 NhMXirtCiN^no«t«r»tiri' 0 '< 3 M»«M( 0 ^> 0 N(MMn cod-- ** o*^ 

O-vOOOOOOOOOOOOOOOOOOOOOOOOOOOOO — OOOOOOOO OO o -<-< 


'O co in n 

— 00 O' -« 

VO N 00 N 

o ooo 


in NOW N CO O' 

^ o O' N CO N O' 

-0 N 00 >0 OO O' -< 

o ooo o o o 


*»■ CM <t CM CM N *0 

^ 00 OO N N >0 N 

vO v!i OO CO VO OO O' 

o o o o o o o 


N-O^-O-HlNOON— CO 00 CM 00 -< O ** xj- 

*? ^ ^ ^ in tfo in uo -• co vo -< cm n n n vo n 

% S'O'OOOOOOOQO (OvOvOC-ICO>0 OO O' 

O OG—«—*—•—i-^OO oooooo oo 


VO —« N CO 

O' o OO vO 

-* N CO OO 

o ooo 


co in co ao n 
O' 00 O' o o 

-« N vo CM CM 

o o o o o 


0 - 00000000000000000000000000000 - 000000000000000000000000000000000--00000 


- S £ £! 2 n<in-«n<finy3Nooo-N(oo t-mojo- ot-omtin-oto 
222o- 

OOOOO OOOOOOOOOOOOOOO OOOOO hhhQOOOO 
(0 •— 2 O C<l a i-rt 

* cm uj o —* cm co ** _i ^ ^ v ^ cm S . v 


2 CO CO h- I ft U(fl 

jK 0M WW h0<I33>>>>>>>00^C CQECoSo. 
O'QQiiiiuiUMroohcladccaHHirh cuiwro 
KocfccrcrQrirircrcecrtotococococototooooocfl £ h- h- i-= h- 


-V CM <r h ^ 

Q Q 2 CC D D CO 

<r<r<ruQoo<r 

o:Q:Q:cL»-.Q:a:r 

HHI-D333M 


'OCOOO'OOOO'COCMCMOCO** 
COOCO-*<*NOOO-«'OOOCM 
—'CMCO'O'O'ONNOOCOOOO' 
OOOOOOOOOOOO 


inNvjwinoo'f^oinNco 

ODOCDh^sOW - ** od cm 

—'CMCO'O'O-ONNOOOOOOO' 
OOOOOOOOOOOO 


CO O -< COOO-vCMCM 

8 m oo in o- <* - 

m in o winoo^in 
o o o —< o o -< -< o o 

CM CM 00 N O W CO O' CM 

-« in N CO O O -0 00 ** — 

£i in in o winO'O'f in 

OOO—* oooooo 


^■' 0 m«f(MC 0 (MO 0 '' 0 ' 00 ' 

cooco-wnoooo®^ 

—•CMCMvOVOvONNOOCOGOO' 
OOOOOOOOOOOO 


coincococMCM-<a'Ninin'0 

COON-.CMNOCMOCOOO-* 

-<CM(M'OVJ'ONNOOOOCOO'- 

OOOOOOOOOOOO 


—*—*CMCM-<OOOCQOO—*CM«* 
COO'NCOCMNO'CMCOCON-« 
-<-<CMm'0>0'ONNcoa>0' 
OOOOOOOOOOOO 


^ N ** >0W^ ® 

-• CM N (0 o oo m CO N o 
CMmmo cm <* O' o co in 
ooo-* oooooo 

oo wn mcMO-<«rN 

-«NN- OOOC-IOONO 

^inino n« nn o w in 
ooo—* oooooo 

o^no^t ^■oinNCM'O 
O CO C-l >0 N OO 

<N*a-ino c-i^mooo^- 
ooo-< oooooo 


OO^WO^NMOH-NO'-OW^O'*!' CO»#-<rCMO'<*' 

coo'-<r s '(MmO'-<cocMN-<u'oii'ooo'^0'0 osm/i-o-o 
-*-*(Minvj>0'ONNooooo'-*(MC-i<rinO' CM^mooo^i- 
OOOOOOOOOOOO—‘OOOOO oooooo 


^0'no'0'«comoo'0in<rcoc'i0'0'co w^-wo-no' 
NC0-<'0-<in0'-*in'<N0'C00'O-<inm oo>oC'icoO'0 
-<-<CVin«0>0'ONNCOOOCOv3-<(MCOini> H^lOOW^f 
oooooooooooooooooo ooo-*oo 


ocoN<>oo(MO»v<?'Nin<rooincMO'OOCM 
''C0-*in-*m0'-<^-<'0 0'C00'Ooin00 
-•-<(Min'0'0'ONNcococD'O^CMoinin 

oooooooooooooooooo 


CM CM 00 CO IT 
GO CM —• CO O' 

noino c> 

o o o -• c 


'r'^CONOCMO'COmCOOCMCMOO''0-<C»)-v^NC10^ , N 
'Co-*m-<b')coo*t^'Oo. coo'OomoocococM-*-*0'Tf- 
'-NinxJO-ONNCDCOCDvD-noininO-OinOC^ 

oooooooooooooooooo—*ooo—*oo 



120 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 







BY DAVID E. RAESIDE 

Department of Radiological Sciences 
University of Oklahoma Health Sciences Center 
Oklahoma City, Oklahoma 

This computer program will calculate how much initial 
capital you will need to financially survive a given number 
of retirement years at a given standard of living. Inflation and 
a return on invested capital are accounted for. The retirement 
income is assumed to be made up of two components: a fixed 
component (a fraction of the initial capital) which is not 
indexed to the inflation rate and an inflation indexed com¬ 
ponent (for example, Social Security). 

The program is based upon an article by Edward W. Her old 
entitled “How Inflation Affects Your Retirement Dollar ” 
which appeared in the September, 1979 issue of the IEEE 
magazine Spectrum. Since the program is self-instructional, 
it is not necessary to know anything about it to use it. 




oooooooooooo 


S8o88S8S8S5SSSB55SSSoaaooooooS3S8S88aSc3333^oaaS3ooSSSSQSSSSSSSSSSSSSooooooaoDoS8SSSoS88 


Number 43 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 
121 








A HEX KEYBOARD , 


• • WITH APPLICATIONS . 

* FOR THE 1802 ELF 


BY MARTIN BRONSTEIN 

9925 Zelzah #518 
Northridge, CA 91325 


Martin Bromtein is a 22-year-old senior at California 
State University at Northridge, majoring in chemistry. His 
interest in computers began when he took a programming class 
at school. He was inspired to write this article by Paul Vasser¬ 
man’s floating point mathpack which appeared in DDJ #37. 

Introduction 

Loading programs via a microcomputer’s front panel 
toggle switches is a cumbersome process to say the least. 
The obvious alternative is to use a keyboard. The keyboard 
system presented here provides eight bits of hexadecimal 
data and uses CMOS integrated circuits for low power con¬ 
sumption. Software loader programs are not needed to use 
this keyboard. Best of all, the system can be built for less 
than twenty dollars. 

Circuit Description 

The heart of this keyboard system is IC 1, National Semi¬ 
conductor’s 74C922 sixteen key encoder. Input to the encoder 
comes from sixteen pushbutton switches arranged in column- 
row format. 

Pressing any key causes pin 12 on IC 1 to go high. Providing 
that the KEYBOARD ENABLE line is high, the signal at 
pin 12 is inverted via IC 3a and validates the decoded output 
lines of IC 1 through pin 13. The signal at pin 12 is simulta¬ 
neously sent through R1 and C3, which provide a 1 micro¬ 
second delay, to pin 3 of flip-flop IC 4. The Q output line 
is clocked low to high and this transition is used to clock the 
encoder outputs into IC 5, which is used as a quad latch. 
The 1 microsecond delay is necessary to insure the outputs 
of IC 1 are valid before IC 5 is clocked. 


Pressing a second key initiates the same sequence of events 
as above, except this time the Q line of IC 4 is clocked low to 
high and causes the encoder outputs to be clocked into latch 
IC 6. Thus any two consecutive keystrokes causes eight bits 
of hexadecimal data to appear on the data lines D4-D7 (MSB) 
and D0-D3 (LSB). 

After the second key is pressed, a low to high transition 
appears on the DATA RDY line which can be used to clock 
the data into memory. Only when KEYBOARD ENABLE is 
high will keystrokes intitiate the clock signals. The OUTPUT 
ENABLE line must be high to allow the data from latches IC 5 
and IC 6 to appear on the bus. Operating the CLEAR push¬ 
button resets flip-flop IC 4 and clears latches IC 5 and IC 6. 
CLEAR may be pressed before or after any two keystrokes 
to clear the keyboard. If pressed after the first keystroke 
in order to correct an error, the DATA RDY line will clock 
low to high as IC 4 resets, which may cause problems. /Mi 
example of how to handle this situation appears later on in 
the section on interfacing the keyboard to the 1802 Elf. 

Construction 

Any type of construction may be used, such as vector 
board or printed circuit. IC sockets are advisable since CMOS 
ICs are sensitive to static discharges and should not be placed 
in the circuit until all soldering is complete. 

A suitable keypad may be made from sixteen individual 
momentary-contact pushbutton switches. Complete hex 
keypads are available from various mailorder dealers such as 
Jameco Electronics (1021 Howard Ave., San Carlos, CA 
94020) for about eleven dollars. 

A very inexpensive alternative is to use a surplus calculator 
keypad. The basic four function (+, —, X, -r) type is best. 
These keypads are usually wired in colum-row format already 
and can be bought as surplus for about 1 dollar. One place 
that has them is Computer Components Inc. (5848 Sepulveda 
Blvd., Van Nuys, CA 91411). The keytops can be marked 
with the appropriate numbers and letters using white tape 
and a marking pen. 


Page 40 

122 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 





Interfacing the Elf 1802 

The hex keyboard may be interfaced to the original Elf 
with two simple modifications. 

First, locate the junction of pin 10, on IC 11, and the 
cathode of D5. Break the junction connection to pin 11 of IC 
12 (see fig. 2) and insert the circuit shown in fig. 3. The new 
circuit allows the keyboard DATA RDY signal to clock the 
data on the bus into memory in the same manner as depressing 
the INPUT switch on the Elf. 

The second modification involves locating the connection 
from pin 2 of IC 11 to pins 5, 6, 12, and 13 of 1C 8 and 9 
on the Elf. Break this connection and insert a DPDT toggle 
switch as shown in fig. 4. This switch is used to select opera¬ 
tion of either the keyboard or the Elf’s original toggle 
switches. This is necessary in order to prevent the toggle 
switch’s data from reaching the bus while using the keyboard 
and vice versa. All other connections remain intact. 



Finally, connect the KEYBOARD ENABLE line to the 
N2/LOAD line on the Elf (pin 1 of IC 10 will do) and connect 
RESET to pin 10 of 1C 12 on the original Elf. The bus connec¬ 
tions may be made directly to the microprocessor. All of the 
interface connections are summarized in figure 5. 

The keyboard can now be used to program the Elf. Set 
the selector switch for keyboard operation, set the Elf LOAD 
switch to ON and press any two keys. The data will auto¬ 
matically appear on the display and be loaded into memory. 
All the Elf operating procedures remain the same. 




PARTS LIST 

R1 - 10K y 4 W resistor, 10% 

R2 - 22K y 4 K resistor, 10% 

Cl — 1 mfd 10V. electrolytic capacitor 

C2 — 0.1 mfd mylar or disk capacitor 

C3 — 100 pf disk capacitor 

IC1 - 74C922 16 key encoder 

IC 2,7,8 - 4066 quad analog switch 

IC — 34049 hex inverter 

IC4 - 4013 dual D flip-flop 

IC 5,6 — 74C175 quad latch 

IC 9 — 4023 triple 3 -input NAND gate 

SW 1 — momentary contact push button switch 

D1 — 19914 switching diode 

Misc. — hexadecimal keypad, vector board, etc. 


Page 42 
124 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 







KUDOS FOR JANUARY ISSUE 

Dear Suzanne: 

WOW! SUPER! EXTRAORDINARY! GREAT! 

There are just not enough adjectives available to convey my 
impression of the January 1980 issue. 

I’m sick of TRS-80, PET, APPLE, ATARI, etc. Why do 
they get all the play when the only true universal operating 
system around is CP/M? There must be 1000 mentions of 
TRS-80 to each mention of CP/M in the micro-computer 
press. 

So you can well imagine how happy I was with your 
latest issue. 

Only one request: PLEASE GIVE US LOTS MORE CP/M! 

Thank you, Gramer & Company 

E. E. (Bud) Gramer P.O.Box 35336 

Phoenix, AZ 85069 

Dear Ms. Rodriguez: 

The all-CPM issue was excellent (of course!) and those of 
us who march to different beats will hope for an all-DOS issue 
or whatever. I have one small nit to pick. In your lead editorial 
you state: “Since CP/M is the most popular micro operating 
system in the world ...” but is it really? Radio Shack pumps 
out a hundred thousand or so units each year and more and 
more of these are diskette based. So their DOS might well be 
the champ in terms of total use. If CP/M is the winner it must 
be by the combination of industrial and hobby market sales. 

Our business (which is also our hobby, our crusade, our 
religion etc.) is plagued with these funny blind spots. 
Dr. Dobb’s sometimes acts as if Radio Shack doesn’t exist. 
Most writers on programming subjects ignore the very 
existence of RPG. PASCAL is praised as “structured” and 
COBOL condemned as “unstructured,” and never mind the 
fact that top-down programming is easy in the latter and 
impossible in the former. By no means do I expect everyone 
or even a majority to share my particular likes and dislikes, 
but equal time would be fairer and would in fact make for 
some interesting debates. 

So let’s hear it for all the unloved ones in the land of the 
bit and the byte. Three cheers for Radio Shack, hurrah for 
COBOL, and de facto recognition at least for poor old RPG. 
Even a respectful bow to big bad IBM (or did you think I 
was using a Heathkit typewriter?) 

Cheers, Culleton Group 

John R. Culleton, Jr. 2401 Haight Avenue 

Sykesville, MD 21784 


NEWBERRY ADDENDUMS 

Dear Editor: 

Some corrections to my article “An Overview of CP/M 
Compatible Software” in DDJ #41. 

Page 9, column 1, middle of page, two occurrences of the 
name ‘Sam Singer’ are misspelled as ‘Sam Sinser.’ Page 11, 
column 1, top of page, line 4, change “‘bmfMVI C, IZOtt: 
(or ‘bmfMVI C,l’)” to “‘bmfMVI C, UZOtt ’ (or ‘bmfMVI 
C,lAZOtt.)” 

Page 13, column 1, top of page, PASCAL/Z: I have since 
obtained the up-to-date documenation of PASCAL/Z 
(Version 2) which now has REALs (floating point) and point¬ 
ers, and so is a full spec PASCAL except for the omission of 
variant records and the ability to pass procedures and func¬ 
tions as parameters. 

Finally, I entirely omitted any mention of the TDL/Xitan 
line of software because of the collapse of the company. I have 
since learned that a new firm (Computer Design Labs, 342 
Columbus Avenue, Trenton, N.J. 08629) has been formed to 
maintain and distribute the TDL/Xitan line. Available on 
either 5or 8" disks for standard CP/M, North Star CP/M 
and TRS-80 CP/M, the line requires a Z-80 processor. I par¬ 
ticularly recommend the ZTEL, MACRO II, LINKER and 
ZAPPLE packages as outstanding values. 

Cordially, Newberry Microsystems 

Steve Newberry 24225 Summerhill Ave. 

Los Altos, CA 94022 


POLYMORPHIC 8813 MATH FUNCTIONS 

Dear Suzanne, 

I use a Polymorphic 8813 as a home system (and sometimes 
think I am the only person in the world to own one). As a 
precision buff, I was delighted by their newest release of 
BASIC which among the many other features, has variable 
precision “settable” from 6 to 26 digits. By the way, this 
precision holds for all of the trigonometric and other math 
functions unlike the so-called double precision calculations in 
some other BASICs. 

While playing with some mathematical diversions based on 
repeating fractions, I found a need to do some simple arith¬ 
metic with even greater precision that that already offered. 
After an hour or so of playing around with the disassembler, I 
found a patch to allow a limited amount of calculation to be 
done in precisions up to 62 digits. 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 43 

125 






The following code appears in the system overlay 
“Bdir.OV”. A simple change of one byte on a COPY of the 
overlay using the “Szap” utility on the System Programmer’s 
disc allows the increased precision. 

;The following code resides at 2395H in the overlay area. 


CD XX XX 

CALL 

PARAM 

;get number 

7B 

MOV 

A, E 

;get returned byte 

FE 06 

CPI 

06H 

; see if too small 

OE 32 

MVI 

C, 32H 

;get small error code 

DA XX XX 

JC 

ERROR 

; 3FE5H is error location 

FE IB 

CPI 

1BH 

; test for too large 

;The preceeding two bytes must be changed to “FE 3F” for 
; increased precision operation. 

OE 33 

MVI 

C, 33H 

; large error code 

D2XXXX 

JNC 

ERROR 

; do error 


;etc, etc,. 

It should be noted that the math functions are not guaranteed 
to work well at the increased precision, in fact the trig 
functions will never be better than 26 digit because the con¬ 
stants built into the algorithms are not precise enough. The 
“Emedit” utility can be used to change the error message 
relating to precision limits as desired. The following operations 
have been used with success at 62 digits: 

+, *, /, INPUT, PRINT, PRINTrn, SQRT, ABS, 

SGN, DO-loops and comparisons. 

Hope this may be of help to some other hackers out there. 

Sincerely, 23 Mack Drive 

John W. McGaw Las Vegas, NV 89110 


INVISIBLE PROGRAMMER S LAW 

Dear Suzanne: 

This letter is in reference to my article in DDJ #40, “An 
Interactive Heath H-8 Disassembler.” 

I would like to correct two errors in the article, one in the 
text and the other in the program listing. 

In the 9th line from the end of the text (before the pro¬ 
gram listing), change the word “command” to “comment.” 
My meaning here was to delete the text from the REM state¬ 
ment, but leave the REM. 

In the program listing, line 3010 has a GOTO referencing 
a non-existent line 3150. This line was inadvertently omitted. 
Therefore, insert the following two lines: 

3150 REM 01110110 ‘HLT’ INSTRUCTION 
3160 S$ = “HLT” : GOSUB 6000: RETURN 

These lines are necessary for the disassembly of HLT 
commands. Their omission causes no problem until such a 
command is encountered. Although I had tested this program 
many times before submitting it, I apparently had not dis¬ 
assembled any programs using the HLT command until 
after I had mailed the program to you. I am now convinced 
of the programmer’s law which states that every program 
contains at least one bug that is totally invisible to the pro¬ 
grammer until after the program is published, at which time 
the bug will be immediately obvious to even the most casual 
observer. 


I received a question about line 5530 which may have 
bothered someone else. The inquiry was whether the argu¬ 
ment of CHR$(c) was a “c” or an “o.” This character is a 
“c” and is the same “c” referred to in line 5510. 

I now have a question. Do you know of any policy on 
rights to programs which have been converted from one 
machine to another, where the revision may be extensive 
(up to 50%), but some of the original good ideas have been 
kept? For example, I have converted several machine code 
programs written for the TRS-80 to run on my Heath H-8. 
Since the CPU chips are different and the architecture is quite 
different, the programs required substantial revision. I would 
like to publish these (especially a useful Monitor/Debugger) 
for use by other H-8 owners, since software is not so readily 
available for this machine. However, I don’t want to infringe 
on any copyrights or get into any legal problems. I would 
appreciate any advice from you or your readers on this. 

Thanks for the good job you’re doing with Dr. Dobb’s. 

Sincerely, 3822 Murworth Drive 

Ronald T. Borochoff Houston, Texas 77025 


The following mini program was sent to us by Holger 
Petersen of West Germany, whose Z80 Micro Disassembler 
was published in DDJ #38. 

HOW TO CHESS-MATE MICROCHESS! 

Dear Suzanne: 

I send you this chess note to form a system-tape. 

First step : Have a 16K level II TRS-80 

second step : Have a Microchess-tape and T-BUG 
third step : Load T-BUG, and with the T-BUG : 

fourth step : Load the first take of MICROCHESS 
fifth step : Change the following locations 


4FB3 from 

40 to 

60 

4FCA 


4F 

6F 

4FD9 


C2 

00 

4FdE 


3C 

70 

4FE5 


40 

74 

4FEA 

CD 

48 01 to 

C3 XX YY (jump to your T-I - 

sixth step : 

Load the second take of MICROCHESS by juinpmg 

from T-BUG to 4FA4! 

seventh : 

Insert a short program at 6000 : 

6000 

21 

CO 60 

LDHL 

6003 

11 

CO 40 

LDDE 

6006 

01 

00 10 

LD BC 

6009 

ED 

BO 

LDIR 

600B 

21 

00 70 

LDHL 

600E 

11 

00 3C 

LD DE 

6011 

01 

00 04 

LD BC 

6014 

ED 

BO 

LDIR 

6016 

C3 

FD 41 

JUMP microchess microchess 

eighth step : 

Save all from 

6000 to 73FF on a tape! 


Start address is 6000! 
ninth step: Try it out! 


To note : And how wild you disguise your software, the first part of 
it must come into the machine the normal, vulnerable way! 


Number 43 

126 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Paige 45 




UCSD PASCAL WITH DIGITAL SYSTEMS DDOS 

Dear DDJ: 

After our club made a group purchase of UCSD PASCAL 
over a year ago, I was anxious to try it out. I had enough 
memory, 48K, a Digital Systems (now Digital Microsystems) 
double density floppy disk, and CP/M 1.4, modified by Digital 
Systems to work with either double or single density. 

Tire PASCAL was set up for single density, so following the 
instructions from Digital Systems, I constructed a single den¬ 
sity operating system. It worked just as it was supposed to on 
regular CP/M files, and I was able to get into PASCAL and set 
it up to work with my terminal. 

However, I soon became very frustrated. I could copy a 
complete PASCAL disk; I could change the date—which gets 
written to the disk; but I could not save a workfile or copy a 
file from one disk to another. 

After trying all kinds of things with many suggestions from 
local club members, I despaired of getting PASCAL on my 
system. However, I eventually got a lead to Bruce Sherry in 
California, who had worked on Digital Systems software. He 
provided helpful suggestions that led to the solution of the 
problem. 

The difficulty arises in the CP/M BIOS. Because the version 
from Digital Systems can handle single density in one drive 
and double density in another, a table in the BDOS has to 
be modified depending upon which density is in effect at 
a given time. This is done by the SELDSK routine in the BIOS. 

Unfortunately, PASCAL uses the area normally occupied 
by the CP/M BDOS, so when SELDSK modifies BDOS, it is 
actually modifying part of the PASCAL operating system. As 
long as one is going to use PASCAL only in single density 
mode;, there is no need for SELDSK to modify BDOS. 

Tire cure is easy: simply eliminate a few lines from 
SELDSK, recompile BIOS and patch it into CP/M in the 
normal manner. If you are starting from scratch to make a 
single density operating system, don’t forget to recompile 
BOOT so that the system comes up in single density. 

Here, in condensed form, are the original routine and the 
modification. In the Digital Systems CBIOS version 4.1 
listing, it is located just a few lines below the statement: 
“ ; I/O DRIVERS FOR THE DISK FOLLOW”. 


SELDSK: : 

:SELECT DISK GIVEN BY -REGISTER C 


XRA 

A 

GETDR: 



SETSING: 




LXT 

D.SINGTAB 


JMP 

0VERB0TH <- Dslete this lin° and all following 

SETDOB: 


down through "* * 11 cure * * *" 

OVERROTH 




PUSH 

B 


LXT 

H.BD0S+0FH <- This is tho slue to fch® trouble! 

LP10: 




POP 

B 

* * * our*' * * * 


LD« 

PORT 


ANI 

0F0H ;CLEAR OUT OLD DISK SELECT BITS 


ORA 

C ;PUT TN NEW DISK SELECT BITS 


ST A 
RET 

PORT 


The routine can be shortened even more, but I would gain 
nothing from saving the few bytes involved. After this has 
been tested to your satisfaction, you can construct the single 
disk boot that will take you straight into PASCAL following 
the UCSD instructions. 


If anyone gets PASCAL going with Digital Microsystems 
double density software, I would be very pleased to hear about 
it. 

Yours truly, 381 Poplar St. 

Charles F. Douds, Ph.D. Winnetka, IL 60093 


PET TAPE CUrE 

Dear DDJ: 

As any PET user knows the most annoying part of loading 
from Cassette is waiting for the FOUND ‘ ’ message. 

This is mainly due to the lack of a tape counter, but even 
with a counter you would not know if the PET has passed the 
Program Header. You can sometimes miss the header, wait 
several minutes, only to find you are on blank tape. My 
method is as follows: 

Connect a Soundbox to the user Port Pin 6 (Cassette No. 1 
Read) The Soundbox connection is Pin M (CB2 Line). 

On both SAVE and LOAD you can then hear the 
following: 

a) The Header Tone, b) The Header Token, c) The Header 
‘Title’, d)The Program DATA, e)The ‘Half Way Point’, 
f) Second copy of DATA, g) The end of file Token 

By using the F .FWD, PLAY and REW keys you can then 
locate the header on a multi-program tape, press PLAY, and 
wait. If you do not get the message FOUND ‘ ’ at the 

Header Title stage, rewind slightly and try again. Using this 
method you can CUE the tape to the right position. 

Other advantages are that you can also hear: 

a) DROPOUTS, b) CROSSTALK, c) NOISE, d) VARIA¬ 
TION in PITCH due to tight Cassettes, e) The difference 
between DATA and PROGRAM tapes. 

This is an invaluable aid, and is best implemented by fitting 
a small toggle switch to the cover of the user port connector. 

i.e. Position 1 SOUND (Pin M) 

Position 2 OFF (No Connection) 

Position 3 CASSETTE (Pin 6) 

With Pin N being the ‘earth’. 

For those who like to keep a ‘Working Copy’ of their 
programs in addition to the ‘MASTER’ a separate cassette 
is an advantage. 

I use an Hitachi TRQ 299 which has an automatic level 
control (ALC) and a Cue and Review facility. In my case 
the ALC gives perfect results on the PET recordings every 
time. The Cue and Review facility allows you to fast wind 
using Cue to find the ‘nth’ program on the tape. 

Position the header using Review and transfer the tape to 
your PET Cassette. 

Perhaps somebody will devise a method to convert the 
PET Cassette to ‘Cue and Review’. 

Incidentally, can anybody suggest a method of recovering 
data from a Program tape, on which the header and part of 
the first copy of DATA has been erased? (Caused by pushing 
RECORD instead of PLAY). 

Sincerely, 15 Parkway, 

R. Cason Sawbridgeworth, 

Herts, England 

Number 43 

127 


Page 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 




Dr. DoBB'S JoURNALof 

COMPUTER 

^Calisthenics ^ Orthodontia 

Running Light Without Overbyte 

Number 44 April 1980 Volume 5, Issue 4 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 

An Emphasis on Algorithms! 


An Introduction to Algorithm Design 5 

Jon Louis Bentley 

Algorithm: The first in a Monthly Column About Algorithms 44 

Dennis Allison 

Meta II: A Syntax-Oriented Complier Writing Language 17 

D.V. Schorre 

A Northstar BASIC Cross-Reference Tool 26 

Titus Purdin 

Some Useful Subroutines for a Z-80 Assembler 34 

John W. Carter 

A Fast Fourier Transform for the 8080 39 

Robert D. Fusfeld 


129 






Kn Introduction 
to Algorithm Design 


BY JON LOUIS BENTLEY 

Carnegie-Mellon University 
Pittsburgh, PA 15213 

© 1979, IEEE Computer Society 

“Algorithm design—that’s the field where people talk 
about programs and prove theorems about programs in¬ 
stead of writing and debugging programs.” Statements along 
these lines have been uttered by applications programmers 
and academicians alike. But there are also some who say, 
“No! Proper algorithm design has helped us to save kilobucks 
at our installation every month.” Here we will investigate 
the field of algorithm design (also know as “analysis of algo¬ 
rithms” and “concrete computational complexity,” among 
other names) and better equip the reader to judge the field 
for himself. 

I trust that anyone with even the slightest love for mathe¬ 
matics burning somewhere in his heart (however deeply) 
will want to see how mathematical tools can be applied to the 
problems of programming. But for the other readers (whose 
interest in mathematics was probably squelched in freshman 
calculus), I offer the same bait that hooked me on this field. 
I trace my interest in the design of efficient algorithms to the 
time when I was a business data processing programmer and 
had just finished reading an introductory text on data struc¬ 
tures. A colleague of mine had just had his program can¬ 
celled— the operators, by counting the turning rate of the 
tapes, had estimated that it would take about three hours to 
process his one reel of data. The program itself was fairly short 
and a quick glance told us that the time was spent in scanning 
a 1000-element table. I suggested that instead of scanning 
we try a new-fangled technique I had just read about— 
binary search. We did, and the modified program processed 
the reel of tape in five minutes, and actually spent most of its 
time waiting for the tape! Around that time I was also asked 
to help another programmer who had already spent a month 
producing over a thousand cards of code for a particular pro¬ 
gram. A simple change in data structure and a few days’ work 
allowed us to redo the program in less than two hundred fines 
of code. The redone program was faster than the original 
would have been, used far less code, and was much easier to 
understand. So even if you have no aeasthetic interest in algo¬ 
rithm design (yet), please read on—the practical benefits 
alone are rewarding enough. 


Reprinted with permission from Computer, February 1979. 


Throughout this article I refer only to the discrete aspects 
of algorithm design. I do not address problems in the domain 
of numerical analysis, such as stability, truncation error, and 
error propagation. Even with this restriction, I include some 
matrices, in which almost all elements are zero, and the fast 
Fourier transform. 

A number of survey papers on discrete algorithm design 
have appeared recently. Hopcroft 1 and Taijan 2 both give a 
thorough picture of the field. Weide’s survey 3 concentrates on 
techniques for analyzing discrete algorithms, and accomplishes 
that task expertly. For those who are skeptical of sweeping 
surveys, Knuth’s excellent introductions 4 ’ 5 examine a few 
problems in detail. And if one is ready to become a serious 
student of the field, the standard texts are Aho, Hopcroft, and 
Ullman’s one-semester, graduate-level introduction 6 and 
Knuth’s first three volumes 7 ' 9 of his proposed seven-volume 
definitive work on algorithms. I hope to supplement those 
works by providing a broad survey for the novice. For this 
reason, I have kept my list of references short; both Taijan 
and Weide, cited above, contain excellent bibliographies. 

This survey discusses algorithm analysis from three view¬ 
points. We first examine five problems and some algorithms 
for solving them. Having considered these concrete examples, 
we next take a systematic tour of the field. We then investigate 
some current research directions and conclude with an assess¬ 
ment of the field’s value to practitioners. 

Some problems and fast algorithms 
for solving them 

The five problems presented here serve as background to 
our general discussions of algorithm design. We will not only 
give an algorithm for solving each, but will also mention some 
real-world situations in which our problems could exist and to 
which our algorithms could be applied. We will analyze the 
algorithms’ efficiency and discuss what this analysis shows. We 
will study the first problem—“subset testing”—in detail aid 
then treat the remaining problems at a more superficial level. 
Before moving on to our overview of algorithm design, we will 
consider what all this attention to efficiency gets us. 


Number 44 

130 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Pcige 5 




But first let me offer an explanation of our concern with 
these examples. The subset testing problem will raise familiar 
issues and should cover some old ground for many; it also gives 
us a nice illustration of the tremendous time savings we can get 
by using proper algorithms. The next example—the substring 
searching problem-provides an extremely interesting blend of 
theory and practice. The fast Fourier transform-FFT-is the 
third example. It is known to many, uses some important 
algorithmic techniques, and is eminently practical. Fourth, 
we examine a very old problem-matrix multiplication-and 
a recent and remarkably counterintuitive solution. We con¬ 
clude our examination of specific problems by investigating 
algorithmic aspects of a public-key cryptosystem. This system 
has recently revolutionized the world of cryptography and 
promises to have a substantial impact on “secure” computing. 

Subset testing. Given a set A of size n and a set B of 
size m<n, is B a subset of A? 10 We can state this “subset 
testing” problem as a programming exercise: given an array 
A|[l:«] and B [ 1 :m] ,both of (say) 32-bit words, is every word 
in B also in A? Disguised versions of this problem arise in 
many contexts: set A could be an employee master file, set B 
a list of weekly transactions, and the problem, a question of 
finding whether a master-file record exists for each weekly 
transaction. Or A might be a table of real numbers x with an 
associated table S containing sine x, B then being a set of x 
values at which the sine function is to be evaluated. But even 
though this problem does have many such practical 
applications, that is not our main motive in examining it here. 
Rather, it leads to many of the basic problems in sorting and 
searching, and points to interrelationships between those 
problems. It also exposes us to some common algorithm design 
methods. 

We will examine three solutions to this problem. Finding 
the running time of each, by counting the number of 
comparisons between elements, will enable us to compare the 
solutions. The following may also encourage the reader as he 
follows the different solutions: our first algorithm will require 
over six days of CPU time to solve a sample problem, while 
our final algorithm will solve it in four seconds. 

Brute force. The simplest way to accomplish this task is to 
compare every element in B to each of the elements of A until 
either its equal is found or we have examined all of A and 
determined that every element of B has no equal in A (in 
which case B is not A’s subset); this approach gives a simple, 
two-loop program. If B is indeed contained in A, then each 
scan for an element that is B’s mate in A takes n/2 compari¬ 
sons on the average (you have to look halfway down the list). 
Since there are m such scans made, the total number of 
comparisons made by this program is about m(n/ 2). So if m is 
very close to the size of n, then we will make about n 2 /2 
comparisons on the average. We won’t try to analyze the 
case that B is not a subset of A; to do so we would have to say 
exactly how it is not a subset, and that is very dependent on 
the particular problem. Although this algorithm is excep¬ 
tionally simple to understand and to code, its slow running 
time might prohibit its use in certain appplications. We will 
now turn our attention to a faster algorithm. 

Sorting. If you were given a randomly ordered list of phone 
numbers B (say a list of phone numbers in a town) and 
another randomly ordered list A (say all phone numbers in the 
county) and you were, asked to check whether B was a subset 
of A (make sure every town phone number is included in the 
county Hst), then you might use the brute-force algorithm just 


discussed. If, however, you were handed a town phone book 
and a county phone book and asked to perform the same task, 
then your job would be much easier. Since the two phone 
books are already sorted by name, we can just scan through 
the two books together, ensuring that the county book 
contains all the town names. This of course immediately gives 
us another algorithm for subset testing: sort A, sort B, then 
sequentially scan through the two, checking for matches. 
To analyze the run time of this strategy we observe that the 
scan will take about n comparisons, and we heard somewhere 
that you can sort a hst of size n in about n log 2 n comparisons, 
so the total running time is (n log 2 n) + (m log 2 m) + n com¬ 
parisons. 

We could pull a sorting routine out of thin air, but it is 
not much more difficult to describe one called Mergesort. The 
basic operation of Mergesort is merging two sorted lists of 
numbers, say X and Y, with these lists either stored as arrays 
or linked together with pointers. To do this we compare the 
first element of X with the first element of Y and give the 
smallest as the first element of the new hst, deleting it from its 
source. We repeat this remove-the-smallest step until both X 
and Y are empty. Since we used one comparison for each step, 
if there were a total of m elements in X and Y, we will have 
used about m comparisons. We can now use this tool of 


Mergesort 



EJ0HED0EII0IIE 


The above illustrates the operation of Mergesort applied to a 
list of eight elements. The top row shows the eight elements in 
the order they were presented for sorting. We then view each 
successive pair of elements (31 and 14, 15 and 92, etc.) as pairs 
of one-element lists and merge those lists—this amounts to 
placing the smaller element as the first element in the list of 
length two. The second row depicts this result. We now have 
four lists, each of length two. As the next step of our algorithm, 
we merge the two successive pairs of lists, giving two (sorted) 
lists of length four. As the final step of our algorithm, we merge 
that pair of lists, resulting in the list of all elements in sorted 
order as shown in the bottom row. 

This example had three "levels" of merging, each requiring 
work proportional to the number of elements in the list. In 
sorting an n-element list we will have log 2 t) levels, with work 
proportional to n on each level. Careful analysis shows that if /7 
is a power of two, we will use exactly nlog 2 r?-n + 1 com¬ 
parisons. If we assume that in a program implementing this 
algorithm each comparison costs approximately one micro¬ 
second, then we can sort a million elements in approximately 
20 seconds. Using the well-known bubble sort for the same 
problem could require up to six days. (We can be encouraged by 
the fact that bubble sort will only take three days on the aver¬ 
age-practice saying that with a straight face to your DP 
manager!) 


Page 6 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 44 

131 




merging to Mergesort a set S of n elements. We start by 
viewing S as a set of n sorted one-element lists. We then merge 
adjacent pairs of one-element lists, giving n/2 two-element 
lists. The next step is to merge adjacent pairs of those lists 
giving n/4 four-element lists, and the process continues. After 
log 2 n iterations we have one sorted n -element list, and our 
task is complete. To analyze this we note that we use about n 
comparisons for the merges at each of the log 2 n iterations, so 
the total number of comparisons used is the promised n log 2 n. 

We have thus shown how to solve the subset problem with 
n(log 2 n + 1) + m log 2 /n comparisons. If m is about the same 
size as n then our algorithm takes approximately 2n log 2 n 
comparisons. Can we do better? 

Hashing. Thinking about the phone book problem leads to 
an interesting sorting approach to the subset problem; if we 
rephrase the phone book problem then the “human” approach 
will lead to an even faster subset algorithm. Suppose that the 
county phone book (A) was sorted and the town phone list 
(B) was not; to ensure that A contains B we can “look up” in 
A each number in B by the name of the subscriber. For each 
of the m elements in B we would do a “binary search” among 
the n elements of A. It is not hard to see that a binary search 
in an n -element sorted table takes at most log 2 « comparisons, 
so this algorithm is easily analyzed: it takes n log 2 w + m log 2 n 
comparisons, or approximately 2 n log 2 n if m is the same size 
as n. We therefore have a searching solution to the subset 
problem: store the elements of A in a table, then for each 
element of B ensure that it is in the table. 

Although binary search is the best searching method for 
many problems, there is another strategy-hashing-even more 
appropriate for this problem. By hashing we can store an 
element in a table or check to see if it already is in a table in 
about two comparisons, on the average. For pessimists, 
however, we note that the worst case of hashing is as bad as 
brute force—we might have to look at all of the elements in 
the table. With this approach we will be able to do subset 
testing in In + 2m comparisons -2n to store A and then 2m 
to look up each element of B. To store the n elements of A 
we will have to allocate a hash table— an array of length 
(1.5 )n. We can even use a smaller array; (1.1 )n would probably 
work almost as well. We then store the elements of A in the 
table one-by-one by the use of a hash function. This maps a 
data value into an integer in the bounds of the hash table. 
If that position in the hash table is empty, fine. We insert the 
element. If the position is occupied, however, we have a 
collision and must employ a collision resolution strategy, such 
as scanning up the elements of the array until a free position is 
found. Analysis shows that a proper collision resolution strate¬ 
gy allows us to find an empty spot very quickly-say, in two 
comparisons. When an empty spot is finally found the element 
is inserted. After inserting all of A’s elements into the table we 
then look up all of B’s elements. For any particular element 
we calculate its hash function and look in that position. If 
that position is empty then it is not in A; if the element is 
in the position then we have found it; otherwise we must 
employ the same collision resolution strategy to see where 
it should be. Hashing is something that a human would never 
use in searching (humans are much better at comparing things 
and then looking in one of two directions than at calculating 
weird hash functions), but it leads to a very efficient algo¬ 
rithm. If m is about the same size as n then the hashing 
approach uses only about 4 n comparisons, on the average, to 
do subset testing. 


The subset testing problem, although a very simple one, led 
us straight to some of the fundamental issues in algorithm 
design. We very quickly arrived at searching—the scan of the 
brute force algorithm was just a naive search. From there we 
moved to sorting, then to binary search, and finally to hashing, 
which introduced us to a non-obvious data structure—the 
hash table. A more thorough examination of searching is 
contained in Knuth. 11 The approaches that we used to solve 
the problem are some of the fundamental tools of algorithm 
designers. We have also touched on aspects of algorithmic 
problems such as time and space analysis and worst-case versus 
expected-time analysis, which we will study later. 

But what has all this gained us? Although we may have a 
better understanding of some of the basic computational 
issues, does our understanding make any difference in 
practice? Let’s assume that we are writing a program for subset 
testing where A and B both contain one million elements, and 
that one comparison takes, say, one microsecond of computer 
time. Under these assumptions, the n 2 /2 comparisons 
required by brute force translates to 138 hours, or a little shy 


Binary search 



This figure shows the operation of binary search in 
locating the position of the number 27 in a sorted table. At 
the start of binary search we only know that the element, if 
in the table at all, lies between 12 and 83, inclusive. This is 
denoted by the two "down-arrows" at the top row. We then 
compare the middle element of that sequence—41—27. Since 
27 is less than 41 we can exclude position 41 to 83 from our 
search, denoted by the down-arrows in the second row. Binary 
search continues by always examining the middle element of the 
sequence in which the "target" value is known to lie. We show 
that middle element by an "up-arrow" below it. The binary 
search terminates by either finding the desired element or 
showing that the desired element is not in the table. 

To analyze binary search we note that each time it makes 
a comparison the size of the subtable containing the desired 
elment is cut by one-half. For example, if we search a 1000- 
element table, after one comparison we are down to only 500 
elements, after two comparisons to 250, and so on. After about 
ten comparisons we either find our man or discover he is not in 
the table. In general if there are n elements in the table, binary 
search requires approximately log 2 n comparisons. Thus, if we 
use it to search a one-million-element table, it will rquire only 
20 comparisons, a substantial improvement over the half-million 
comparisons used by the average linear scan. 


Number 44 

132 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 




of six days, of machine time; the 2n log 2 n for sorting will give 
40 seconds; and the 4n of hashing will yield 4 seconds. 
Although we haven’t calculated all the costs of implementa¬ 
tion, this example shows how a simple analysis is sometimes all 
we need to make an informed choice. 

Substring searching. Does a given string contain a specified 
substring pattern, and if so, where? This is the substring 
searching problem, one familiar to most who have used 
computer text editors. As I sat down to type this paragraph, 
for example, I told the editor to find the substring “Substring 
searching.” in my text file so I would know where to begin my 
paragraph. The text editor I use looks at a file as one long 
string of text, sprinkled with special characters representing 
“carriage return.” Information retrieval systems use this same 
operation as they identify abstracts which contain certain key¬ 
words. Similar problems are encountered in many text format¬ 
ting and macro processing programs. 

It is not hard to write a program to solve this problem. We 
first hold pattern's leftmost character under string’s leftmost 
character and start comparing. If all the characters of pattern 
match the characters above them, fine—we have found the 
substring in position 1. If we find a mismatch then we slide 
pattern over one and do the same thing again. This continues 
until we either find a match or come to the end of string. The 
worst-case behavior of this algorithm is very slow—for each n 
positions of string we might have to compare all m positions of 

Matrix multiplication 

1 “1 x r* n. p 

_c dj 1_9 h J Li 1 

We can compute a product matrix in the following (non- 
straightforward) fashion. First we compute the seven "tem¬ 
porary" values by the following seven multiplications: 

fl ={b-d) * (g+h) 
f 2 = (a + rf) * (e + /?) 
r3 = (a -c) * (e + f) 
f4 = (a + c) • ft 
t5 = a * (a - f) 

1 6 = d * (g -e) 
fl = (c + d) * e 

We can now combine these temporary values to yield the pro¬ 
duct matrix: 

p = fl + f2 - f4 + f6 
<jr = f4 + f5 
r = t6 + r7 
S = f2-f3 + f5-r7 

The "high school" method of multiplying two-by-two matrices 
requires eight multiplications and four additions. This method 
requires only seven multiplications, but 18 additions and sub¬ 
tractions. This hardly seems like a worthwhile tradeoff! 

Amazingly enough, however, we can use the above scheme 
recursively to oproduce an algorithm for matrix multiplication 

that is asympototically more efficient than the 0(r? 3 ) high 

2 81 

school algorithm—it requires 0(r? ' ) time. Although the sav¬ 

ings it achieves are offset by the additional overhead in imple¬ 
mentation (it is probably inferior to the high school algorithm 
until the matrix contains at least 10,000 elements), it is remark¬ 
able to find we can multiply faster than people have been doing 
it for the past hundred years. 


pattern. Thus in the worst case we might have to make mn 
comparisons. Strings and patterns that realize this worst-case 
behavior are fairly pathological and the performance of this 
algorithm in practice is fairly good, but the question still 
haunts us—can we design an algorithm that will always do 
better? 

Knuth, Morris, and Pratt 12 offer an algorithm that beats 
the mn performance. They preprocess pattern into a data 
structure that represents a program; that program then looks 
for pattern in string. Preprocessing pattern takes only m 
operations (where m is the length of pattern) and the 
“program” they produce looks at each character of string only 
once, so the total running time of their algorithm is propor¬ 
tional to m + n instead of mn. (Of course if the pattern is in 
the tth position in string, then their algorithm takes time 
proportional to i + m.) This result is exceptionally interesting 
from a theoretical viewpoint, and also provides a faster sub¬ 
string searching algorithm in practice. 

Boyer and Moore 13 recently used the basic idea of the 
Knuth, Morris, and Pratt algorithm to derive an even faster 
method of substring searching. Their method has the same 
worst-case performance (proportional tom + n) but is faster 
on the average. They accomplish this by making it unneces¬ 
sary to examine every element of string. They have 
implemented their algorithm on a PDP-10 so efficiently that 
when string contains typical English text and pattern is a five 
letter word in string, the number of PDP-10 instructions 
executed is less than i + n. This is at least an order of 
magnitude faster than the naive algorithm. 

The history of the substring searching problem provides an 
insight into the relation of theory to practice. Knuth relates 
that his use of a machine from automata theory, the “two- 
way deterministic push-down automaton,” led him to his 
discovery of the algorithm. The easiest way to understand fast 
algorithms is through the use of finite state automata, which 
are commonly used in digital systems design. It is noteworthy 
that in this one problem we can talk about such diverse ideas 
as abstract automata and PDP-10 instructions, with a lot of 
combinatorial analysis in between! 

The fast Fourier transform. The Fourier transform is often 
studied in mathematics and engineering. It can be viewed in 
a number of ways, such as the transformation of a function 
from the “time domain” into the “frequency domain” or as 
the decomposition of a function into its “sinusoidal 
components.” The continuous Fourier transform has a discrete 
counterpart, which applies an operation to one set of n reals 
yielding a “transformed” set of n reals. This problem has 
applications in signal processing, interpolation methods, and 
many other discrete problems. 

The naive algorithm for computing the Fourier transform 
of n reals requires approximately n 2 arithmetic operations 
(adds and multiplies). The fast Fourier transform of Cooley 
and Tukey 14 accomplishes this task in approximately n log 2 n 
arithmetics. It achieves this by doing about n arithmetics on 
each of log 2 n levels; in this sense it is quite similar to the 
Mergesort algorithm discussed earlier. There are many dif¬ 
ferent expositions of the algorithm, such as those in Aho, 
Hopcroft, and Ullman 15 or Borodin and Munro. 16 It is 
interesting to note that in addition to being faster, many of 
the numeric properties of the FFT are better than those of 
the naive transform. 

The fast Fourier transform has had a substantial impact on 
computing. It forms the backbone of many “numeric” 


Page 8 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 44 

133 




programs. Practitioners in diverse fields use the FFT to find 
hidden periodicities of stationary time series. Signal proces¬ 
sing uses it in filters to remove noise from signals and eradicate 
blurring in digital pictures. Numerical analysis utilizes it for 
the interpolation and convolution of functions. Applications 
of the FFT in such diverse areas as electrical engineering, 
acoustics, geophysics, medicine, economics, and psychology 
are listed by Brillinger. 17 Many special-purpose processors 
have been built which implement this algorithm; some are 
multiprocessors which operate in parallel. The FFT is also 
widely used in the design of “discrete” algorithms. It is the 
primary element in many algorithms which operate on poly¬ 
nomials, performing such operations as multiplication, 
division, evaluation, and interpolation. Not surprisingly, it is 
also employed in some of the fastest known algorithms for 
operating on very long integers, such as multiplying two 
1000-bit integers. We will see an application of this problem 
later. 

Matrix multiplication. One of the most common ways of 
representing many different kinds of data is in a matrix, and 
one of the most common operations on matrices is multipli¬ 
cation. How hard is it to multiply two n X m matrices? Using 
the standard high school method takes about 2 n arithmetic 
operations to calculate each of the n 2 elements of the product 
matrix, so the total amount of time required by that algorithm 
is proportional to « 3 . People have been multiplying matrices 
by this method for a century. Surely this must be the best 
possible way to multiply matrices-our intuition tells us that 
we just can’t do any better. 

The high school algorithm for multiplying two-by-two 
matrices uses eight multiplications and four additions. It is 
fairly counterintuitive to leam that the product can be com¬ 
puted using only seven multiplications at the cost of an 
increase of 15 additions. But if that is counterintuitive, then it 
is absolutely mindboggling to find that this fact alone allows 


O-notation 

Algorithm analysts frequently employ the "big-oh" notation 
of mathematics. In this notation we can write an expression like 

T(r>) =6n 2 + 9.3/? = 0(/? 2 ) 

to show the running time—T(/?)—of an algorithm. The more 
accurate expression for T(/?) is much more complicated to ex¬ 
press than the simple 0(/? 2 ); we therefore see a tradeoff between 
the accuracy of the statement and the ease of expressing the 
formula (as well as the ease of deriving the expression). There is 
a well-developed mathematical theory of "order arithmetic" 
that allows derivations to be made without regard to the con¬ 
stant factors of the leading terms. Most calculations in this arith¬ 
metic are very simple. 

"Big-oh" notation is a useful tool for analyzing algorithms. 
The running times of most algorithms to within "big-ohs" are 
much more easily obtained than are the exact analyses of the 
algorithms. If we know that algorithm A takes 0(n 2 ) time and 
that algorithm B takes 0(/7 log/?) time, then regardless of the 
constants "hidden" in the notation, algorithm B will be faster 
than algorithm A for large enough values of n. The "big-oh" 
analysis will therefore be of great help in choosing an algorithm 
that is to process a huge amount of data, as long as we are 
careful not to be caught unaware by the constants hidden in the 
notation. 


us to construct an algorithm for multiplying n X n matrices 
that runs in less than n 3 time! This algorithm, devised by 
Strassen, 18 decomposes each n X n matrix into four (m/2) X 
(m/2) matrices. It does seven multiplications of («/2) X 
(m/2) matrices and then fifteen additions on matrices of that 
size to fmd the product of the original matrices. Notice, how¬ 
ever, that the cost of those additions is proportional to n 2 . If 
we let T(m) be the time required to multiply nX n matrices, 
then T(n) satisfies the recurrence 

T(l)=l, 

T(m) = 7T(m/2) + 0(m 2 ) 

having the solution T(m) = 0(m 2-81 ) (where 2.81 is an approx¬ 
imation to log 2 7). The Strassen algorithm as originally 
presented is less efficient than the high school algorithm until 
n is in the thousands. Recent work, however, shows that it can 
be practical when n is as small as 40. But practice aside, who 
can help but be amazed by the fact that we can multiply 
matrices faster than we thought we could? 

The fast matrix multiplication algorithm provided the 
basis for one of the all-time great revolutions in the history 
of “theoretical” algorithm design, during which a number of 
“best” known algorithms were toppled from their thrones. 
Many of these were m 3 matrix algorithms which we can now 
do in 0(n 2-81 ) time; among these are matrix inversion, LU 
decomposition, solutions to systems of linear equations, 
and calculations of determinants. A number of problems 
which seemed to be totally unrelated to matrices were phrased 
in terms of them. As a result 0(n 2 ' 81 ) algorithms followed 
for such diverse problems as finding the transitive closure of 
a graph, parsing context-free languages (an important problem 
in compilers), and finding distances between n points in 
Euclidean n -space. All of these algorithms stem from the fact 
that two-by-two matrices can be multiplied with seven 
multiplications. 

Public-key cryptography. Communications systems which 
deal with the problem of transmitting a message from a sender 
to a receiver across an insecure and possibly bugged channel, 
while protecting the privacy of the message, are known as 
cryptosystems. Such security needs often arise in military 
applications; they also promise to play an ever increasing 
role in applications such as electronic mail and electronic 
funds transfer. A cryptosystem is usually implemented by 
encoding and decoding algorithms which transform their 
inputs according to keys they are given. To send person X 
message M we use the encoding algorithm and key to produce 
message M', transmitting M' to X across the possibly insecure 
channel. When X receives M' he uses the decoding algorithm 
and key to determine M, while any “eavesdropper” has only 
M'. One difficulty with this system is the distribution of keys 
to the appropriate parties. This must usually be accomplished 
by the use of expensive secure channels such as human 
couriers. 

An alternative, called a public-key cryptosystem, was 
recently invented by Heilman and Diffie. 19 In their system 
each person has an encoding key and a decoding key, as 
before. To send a message to person X we encode it using X’s 
encoding key, and then X can decode it with his decoding key. 
The novel aspect of this system is that we can make the 
encoding key public without revealing the corresponding 
decoding key. We can then view the encoding key as the 
address of X’s mail box, and anyone can put mail into that 


Number 44 

134 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 




box simply by encoding the message. Actually unlocking the 
box, however, requires the decoding key, which only X 
possesses. Although such a system solves almost all of the 
difficulties of previous cryptosystems, one major obstacle 
remains; for most codes knowledge of the encryption key 
immediately reveals the decryption key. Thus all we need to 
complete our public-key cryptosystem is an appropriate 
encoding/decoding algorithm, provided such an algorithm is 
possible. 

A suitable encoding/decoding method was recently 
developed by Rivest, Shamir, and Adleman. 20 Their method is 
based on algorithmic issues in the theory of numbers. They 
view messages as multiprecision (long) integers of 200 decimal 
digits, for example. The coding procedure then transforms 
these messages by sophisticated use of modular arithmetic and 
prime number theory. The transformations require many 
sophisticated algorithms. For instance, the process of key 
selection is based on fast algorithms for multiplying multi- 
precision integers and testing such integers for primality; fast 
mulliprecision exponentiation algorithms then perform 
encoding and decoding. The fact that any method that 
“breaks” the system must essentially find the factors of a very 
large number is the basis of the system’s security. Although no 
one knows precisely how difficult this factoring is, mathema¬ 
ticians have been working on the problem for many centuries, 
and no one yet knows of a fast method. Let me put this in 
perspective: if we deal with 200 decimal digit integers, then 
the key selection, encoding, and decoding algorithms require 
only a few seconds of CPU time; the best known method for 
breaking the system, however, would require ten million 
centuries of CPU time. 

We have only scratched the surface of the fascinating field 
of public-key cryptography. In addition to use in crypto¬ 
systems, these methods can also be used to provide “electronic 
signatures,” i.e., verifications of identity. This cryptosystem is 
another interesting example of the interactions between 
theory and practice. It is based on number theory (perhaps the 
purest of the areas of pure mathematics) and complexity 
theory, yet it promises to revolutionize the practice or 
cryptography. The interested reader should refer to the article 
by Rivest, Shamir, and Adleman, cited above, or the 
exposition in Gardner. 21 Although the algorithms we have 
mentioned do not really solve an existing computational 
problem, they solve a problem in a totally different area by 
casting it in a computational light. 

We have now examined five cases in which proper algorithm 
design has led to a sophisticated algorithm that is much faster 
than a naive algorithm. Algorithm designers have invested a lot 
of work in developing these algorithms—but what difference 
will it all make in practice? 

To be honest, most of the time a fast algorithm makes no 
difference at all. Rnuth has gathered empirical evidence 
showing that most of the run time of a program is spent in 
just three precent of the code. If an algorithm for a problem 
is not in the critical three percent of a code, it makes little 
difference if the algorithm is fast or not. A complicated algo¬ 
rithm is often a Lability rather than an asset. It will usually 
mean more coding and more debugging time, and can some¬ 
times even increase the run time (when the overhead of 
“starting up” a fancy algorithm costs more than the time it 
saves). 

Sometimes, however, a fast algorithm can make all the 
difference in the world. If a certain computation is indeed the 


bottleneck in the system flow, then an algorithm of half the 
running time almost doubles system throughput. Many text 
editors spend a vast majority of their time in string searching; 
the fast algorithm for substring searching can speed up many 
text editors by a factor of five. My experience with the search¬ 
ing program I mentioned in the introduction, where we 
reduced the running time from three hours to five minutes, 
is another good example of an appropriate use for a fast algo¬ 
rithm. In the inner loops of many programs proper algorithm 
design is critical. 

Fast algorithm design, although only occasionally yield¬ 
ing large financial savings, almost always gives us something of 
a different value—a fundamental understanding of our compu¬ 
tation problems. This is usually reflected in cleaner programs; 
but even more important is the understanding of how diffcult 
it is to compute something. After a student has spent a month 
or two investigating the problem of searching, he knows not 
only how to search faster, but also why he can do it that fast 
and why he can’t do it any faster. Such a student has learned 
something of the foundations of his field. 

Algorithm design—a systematic view 

In the section above we saw a number of specific problems 
and specific solutions; here we will show that there is more 
to the field than isolated examples. Algorithm design is a co¬ 
herent discipline—one needs a specific set of concepts to 
define a computation problem and specific set of tools to de¬ 
sign an optimal algorithm to solve it. 

Problem dimensions—a microscopic view. The subset 
testing problem showed that there can be many different 
algorithms for solving a particular problem. In order to say 
which one is best in a particular application we have to know 
certain dimensions along which to measure properties of the 
algorithm. For example, in one application we may need a 
subset algorithm that must be very space-efficient and have 
good worst-case running time; in another context, we might 
have a lot of available space and only require good expected 
running time, not caring if we infrequently must take a lot 
of time. We have thus identified three dimensions of a compu¬ 
tational problem: time analysis, space analysis, and expected 
vs. worst-case analysis. We will now investigate these and 
other dimensions of computational problems. 

Time and space analysis. The two most important re¬ 
sources in real computational systems are time (CPU cycles) 
and space (memory words). These are therefore the two 
dimensions of a problem most frequently studied. Running 
time was the primary subject we examined in the examples 
cited earlier. Most of the algorithms we discussed used very 
little extra space after storing the inputs and outputs—the 
hashing algorithm we used for subset testing was the only 
exception. Since in large computer sytsems we can have huge 
quantities of extra space for the asking and the paying, we 
have often ignored the space requirements of algorithms. 
With the rise in popularity of mini-and microprocessors with 
very small memories, however, space analysis is once again 
an important issue. 

Model of computation. In covering the examples earlier 
in this article, we were able to make reference to the time and 
space requirements of various algorithms without reference to 
their implementation on any particular computer. Our in¬ 
tuitive notions were robust enough to lead to sophisticated 


Page 10 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 44 

135 



algorithms that would certainly beat their naive competitors 
on any existing machine. But to analyze an algorithm in 
detail we must have a precise mathematical model of the 
machine on which the algorithm will run. 

We could choose as our model a particular computer, 
such as an IBM650 or a DEC-PDP-10, and then ask how many 
microseconds of time or bits of storage a particular algorithm 
requires. There are two problems with this approach. First, 
we will problably analyze the expertise of the algorithm’s 
implementer more than we will the algorithm’s intrinsic 
merit; and second, once we have completed an analysis using 
an IBM 650 we still know very little about the algorithm’s 
behavior on a PDP-10. One way of dealing with these diffi¬ 
culties is to invent a representative computer and then com¬ 
pare the performances of competing algorithms on that 
machine. Knuth 22 has described one such machine which he 
named the MIX computer. It has much in common with most 
existing machines without many idiosyncrasies of its own. 
If algorithm A is faster than algorithm B when implemented 
on MIX, then it is likely to be faster on most real machines, 
too. 

Another solution is not to analyze the implementation of 
the algorithm on any particular machine at all, but simply to 
count the number of times the algorithm performs some 
critical operation. For the analysis of the FFT and matrix 
multiplication we chose to count the number of arithmetic 
operations. We know that the FFT uses exactly n log 2 n 
multiplications. To estimate its running time for a given 
implementation we can look up the execution speeds of the 
instructions around the muliplication instruction, sum those, 
and then multiply by n log 2 to get an estimate for the run¬ 
ning time. It is usually easy to determine the running time of a 
particlar program if we know the number of times the critical 
operation is to be performed. We must be careful, however, 
not to ignore certain “bookkeeping” operations that may 
become critical in implementations. Once we have chosen a 
critical operation to count it is very easy to specify a model of 
computation. To count arithmetic operations we usually 
employ the “straight-line program” model in which an algo¬ 
rithm for a particular value of the problem size («) is repre¬ 
sented by a sequence of statements of the form 

Xi*-X } OP x k 

where OP is add, subtract, multiply, or divide. If the sequence 
for a particular value of n is m instructions long then we say 
that the execution time of our program is T(n) = m. If our 
critical operation were comparison, then we would probably 
choose the “decision tree” model. These and other models 
are described by Aho, Hopcroft, and Ullman. 2 3 

The above models allow us to analyze algorithms for their 
suitability as “in-core” programs on single-processor mach¬ 
ines. If a program has very little main memory available and 
must store most of its data on tape, then some tape-oriented 
model such as the Turing machine is the most accurate model 
of the computation. If a program is to be run on a multi¬ 
processor machine then our model must express this fact, 
and the model employed will vary with the multiprocessor 
architecture. The interested reader should refer to Kung 25 
for a discussion of some of these issues from an algorithmic 
viewpoint. Many other models of computation have been 
proposed to describe diverse computing devices. The two 
important things in choosing a model are that it be realistic , 


so the results will apply to the situation it purports to model, 
and that it be mathematically tractable, so we can derive 
those results. 

Exact or approximate analysis. Once we have chosen a 
model of computation we can analyze an algorithm’s perform¬ 
ance by counting the resources (time or space) it uses as a 
function of n, the problem size. How accurately sho.ild we 
do that counting? We could be very precise, calculating the 
answer exactly, or we might settle for an approximate answer. 
There are levels of approximation, all the way from the first 
two terms of the answer to rough upper and lower bounds. 
It is certainly desirable to get the exact answer, but this is 
sometimes very difficult. The first one or two terms of the 
cost function are adequate for most purposes, and in many 
cases we need only the function’s asymptotic growth rate. 
We saw in the subset testing problem an example in which the 
run time for one program was 138 hours while another pro¬ 
gram ook just 4 seconds to carry out the same task. Ewn if 
our analysis had missed a factor of ten, that could not affect 
our choice for large problems. 

We often use the “big-oh” notation to describe the com¬ 
plexity of a problem. No matter what the respective constants 
are, an o(n log 2 n) algorithm will be faster than an 0(n 2 ) 
algorithm for large enough n. As we solve larger and larger 
problems by computer, we are more and more frequently in 
the domain of “large enough n.” Asymptotically fast algo¬ 
rithms also have another advantage. If we get a new machine 
one hundred times faster than our old one, using an 0(n log 2 
n) algorithm will allow us to solve a problem almost one 
hundred times larger in the same period of time. Using an 
0(« 2 ) algorithm will permit the new machine to solve a prob¬ 
lem only ten times larger in that time. Thus, a function’s 
asymptotic growth rate is usually enough to tell us how 
much an increase in problem size will cost under each type 
of algorithm. 

Average or worst-case analysis. Many algorithms perform a 
sequence of operations independent of their input data; the 
FFT and matrix multiplication algorithms are both data- 
independent. The analysis of a data-independent algorithm is 
straightforward—we simply count the number of operations 
used. The operation of algorithms such as those for sorting and 
substring searching, however, are dependent on their input 
data. One algorithm can have very different running times for 
two inputs of the same size. How do we describe the running 
time of such an algorithm? Pessimists want to know the worst- 
case running time over all inputs and realists want to know the 
average running time. (We are rarely concerned with the best- 
case running time, for there are very few optimists in 
computing.) 

Most mathematical analysis of algorithms has been done for 
the worst case. Even in data-dependent algorithms it is usually 
easy to identify the worst possible occurrence and analyze it as 
in a data-independent algorithm. In certain applications (air 
traffic control is often cited) it is important to have an algo¬ 
rithm that never surprises us with a very slow case. For most 
applications, however, we are more interested in what will 
usually happen; expected-time analysis provides this informa¬ 
tion. Relatively little work has been done on expected-time 
analysis. The two major stumbling blocks are in the choice of 
a realistic and tractable probability model of the inputs and in 
the intrinsic difficulty of dealing with expectations instead of 
single cases. It would be desirable to have a single algorithm 
efficient in both expected and worst-case performances. 


Number 44 

136 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 



Upper and lower bounds. Most naive sorting algorithms 
(such as “bubble sort”) require 0 (n 2 ) comparisons in the 
worst case. Earlier we investigated Mergesort, which never uses 
more than 0(nlog 2 n) comparisons. Should we continue our 
search, hoping to find an algorithm that uses perhaps only 
0 (n) comparisons? The answer to this question is no, for we 
can show that every sorting algorithm must take at least 
C)(nlog 2 n) comparisons in the worst case. The proof of this 


Decision trees 



This figure illustrates a decision tree program to sort three 
numbers. The program "starts" at the top node and compares 
the value of a with the value of b. If a is the lesser it goes down 
the left branch of the tree and if a is greater it goes down the 
right branch (we assume for clarity that all elements are dis¬ 
tinct). It continues until it reaches a "leaf" (leaf nodes are de¬ 
picted by rectangles); when we arrive at a "leaf" we know the 
total ordering of a, b. and c. I encourage the reader to study this 
example to see that it correctly sorts the three elements. 

Decision trees accurately model computations based on com¬ 
parisons. Theoretically, we can represent any comparison-based 
program for sorting n numbers with a corresponding decision 
tree. For example, we can "translate" the above tree into a set 
of nested IF statements in a high-level programming language. 
We can use the mathematical properties of decision trees to 
prove lower bounds on the complexity of certain computations. 
Notice that the height of the decision tree (i.e., the maximum 
distance from the root to one of the leaves) corresponds to the 
maximum number of comparisons ever used by the "decision 
tree program." It is a well-known mathematical fact that if a 
binary tree hasm leaves, it must have neight of at least log 2 m. It 
is also known that there are n! (i.e., n*(r»-1)*...*1) dif¬ 
ferent permutations of n elements. Since a sorting program 
must correctly distinguish between all permutations of its 
input variables, its decision tree must have at least n\ leaves. 
Combining these two facts, we see that any decision tree for 
sorting must use at least log 2 n! comparisons, which is ap¬ 
proximately n log 2 n. We thus see that the Mergesort algorithm 
for sorting is very close to the best possible algorithm in terms of 
number of comparisons used. 

We must be very careful in interpreting lower bounds—they 
only apply in the given model of computation. It might be 
possible to sort numbers faster if we use more powerful opera¬ 
tions than comparisons. (In fact, it is!) The lower bound, how¬ 
ever, still serves a useful purpose. It tells us that if we want to do 
something faster, we had better adopt a fundamentally different 
approach to solving the problem. 


theorem uses the “decision tree” model of computation, 
described nicely by Aho, Hopcroft, and Ullman. 24 The 
Mergesort algorithm gave us an upper bound of 0(«log 2 n) on 
the complexity of sorting; this theorem gives us a lower 
bound. Since the two have the same growth rate, we can say 
that Mergesort is optimal to within a constant factor under the 
decision tree model of computation. Notice that we have now 
made the important jump from speaking of the complexity of 
an algorithm to speaking of the complexity of the problem. 

Lower bound results are usually much more difficult to 
obtain than upper bounds. To find an upper bound we need 
only give a particular algorithm and analyze it. For a lower 
bound, however, we must show that in the set of algorithms 
for solving the problem there are none more efficient than the 
lower bound. There are some trivial lower bounds we can 
easily achieve: most problems require examination of all their 
inputs, so we usually have an easy lower bound of the input 
size. The number of nontrivial lower bounds discovered to 
date is very small. 

A precise model of computation is important in proving 
lower bounds. Previously we gave three algorithms we can use 
for testing set equality: brute force, sorting, and hashing. We 
gave them originally for subset testing, but recall that two sets 
are equal if and only if each is a subset of the other. The 
importance of the computational model becomes clear when 
we leam that we can prove each of those algorithms optimal 
under different computational models! Brute force’s 0(n 2 ) 
performance is optimal if only equal/not-equal comparisons 
can be made between elements of the two sets. If the model of 
computation includes only less-than/not-less-than compari¬ 
sons, sorting’s 0(nlog 2 n) comparisons are optimal. If the 
model is a random access computer such as MIX, hashing’s 
average-case linear performance is provably best. 

Exact and approximation algorithms. The best-known 
algorithms for many problems are quite slow, requiring, say, 
0(2”) time. A very few of these problems have actually been 
proved to have exponential lower bounds. Others belong to a 
fascinating class called the NP-complete problems, either all 
solvable in time polynomial in problem size, or all of expo¬ 
nential complexity. Unfortunately, nobody yet knows which, 
but most of the money is on exponential. Examples of NP- 
complete problems include the traveling salesman problem 
(finding a minimal-length tour through a set of cities), bin 
packing, and the knapsack problem. Literally hundreds of 
problems are known to be NP-complete. Lewis and 
Papidimitriou 26 provide an excellent introduction to this class. 
There are other problems, not proven to be hard, for which no 
one has yet been able to design fast algorithms. So when we 
have a problem we don’t know how to solve efficiently, what 
can we do? 

The answer is amazingly simple: don’t solve it. Solve a 
related problem instead. Instead of designing an algorithm 
to produce the exact answer, we can build one to produce an 
approximation to the exact answer. So instead of finding a 
minimal tour for the traveling salesman, we might provide 
him with a tour we know is no more than 50 percent longer 
than the true minimum. Or if someone asks if a number is 
prime or composite, instead of providing the true answer 
we might respond “I don’t know, but I’m 99.999999 percent 
sure that it’s prime.” Problems abound for which the best 
known exact algorithms require exponential time, but for 
which we can quickly find approximate solutions. Garey and 
Johnson 27 examine these issues. 


Pags 12 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 44 

137 







These problem dimensions—such as time analysis, space 
analysis, and expected vs. worst-case analysis—are the 
categories in which algorithm designers think. When someone 
brings a designer a problem, his first task is to understand the 
abstract problem. Next he must understand what kind of solu¬ 
tion the person wants, and he uses the dimensions to describe 
the desired solution. Using the vocabulary introduced here it 
is easy to describe concepts such as a “fast expected time and 
low worst-case storage approximation algorithm for task X, to 
be run on a multiprocessor machine.” There are other infre¬ 
quently used dimensions we have not covered, such as code 
complexity—how long is the shortest program to solve a 
problem? But the dimensions we have examined can describe 
most algorithmic results. 

Problem areas—a macroscopic view. The vocabulary above 
can describe a particular algorithmic problem at a precise level 
of detail. Here we change our perspective and examine large 
classes of problems, but use the same terminology. 

Ordered sets. There are many problems on sets that depend 
only on a “less than” relationship being defined between the 
elements of the set. In many cases the set contains integers or 
real numbers, while in other cases we define a “less than” 
relation between character strings (JONES is less than 
SMITH). The problems discussed earlier in the section on 
subset testing all deal with ordered sets. The algorithms in that 
section are appropriate if the elements of the sets are numbers, 
character strings, or any other type of “orderable” object. 
Knuth 28 provides an excellent introduction to the applications 
of, and algorithms for, ordered sets. 

The “median problem” is another problem defined for 
ordered sets: given an n -element set we are to find an element 
which is less than half of the elements and not less than the 
other half. A naive algorithm would count for each element 
the number of elements less than it, and then report the medi¬ 
an as the element with exactly half the others less than it. This 
algorithm makes approximately n 2 comparisons. We can devise 
an 0(nlog 2 n) algorithm by sorting the elements and then 
reporting the middle of the sorted list. In 1962 C. A. R. Hoare 
described an algorithm for the median problem, with linear 
expected time. For over ten years no one knew if there was an 
algorithm with linear worst-case time; Blum et al. finally 
offered one in 1973. 29 Much additional work has been done 
on this problem, exploring facets such as minimal storage, 
detailed worst-case vs. expected running time analysis (upper 
and lower bounds), and approximation algorithms. 

Algebraic and numeric problems. Many aspects of algebraic 
and numeric problems have a discrete flavor, and discrete algo¬ 
rithm design can play a significant role in such problems. 
Matrix multiplication is perhaps the clearest example: we can 
describe (and appreciate) the fast algorithm without reference 
to any of its numeric properties. We can also view the FFT 
“non-numerically.” Another numeric problem that can 
assume a purely discrete character is sparse matrix manipula¬ 
tion (in a sparse matrix almost all elements are zero). Borodin 
and Munro, cited earlier, describe applications of discrete 
algorithm design to numeric problems such as polynomial 
manipulation, extended precision arithmetic, and multi¬ 
processor implementations of numeric problems. 

Graphs. Graphs can represent many different kinds of 
relations, from the interconnections of an airline system to the 
configuration of a computer system. Taijan’s survey 30 dis¬ 
cusses many computational problems relating to graphs. One 
important problem involves determining if we can imbed a 


given graph in a plane without any edges crossing. We might 
use this to check if we can imbed the connections of a given 
circuit on a printed circuit board or integrated circuit. The 
first algorithms for testing planarity ran in 0(« 3 ) time on 
n-node graphs; after much effort by many researchers, 
Hopcroft and Taijan finally designed a linear-time planarity 
algorithm in 1974. 31 Another graph problem is constructing a 
minimal spanning tree of a weighted graph, i.e., a minimal- 
weight set of edges connecting all nodes. Researchers have 
proposed and analyzed a wide variety of algorithms for tliis 
problem. Some are superior for very dense graphs, others for 
relatively sparse graphs, and still others for planar graphs. Effi¬ 
cient graph algorithms exist for problems such as computer 
program flow analysis and finding maximal flows in networks. 
And since a sparse matrix is usually represented by a graph, 
graph algorithms can apply to sparse matrix problems. 

Geometry. Shamos’ paper 32 is an outstanding introduction 
to computational geometry, the field concerned with 
developing optimal algorithms for geometric problems. Many 
application areas are inherently geometric (such as circuit 
layout) and other problems can be viewed geometrically (such 
as treating a set of multivariate observations as points in a 
multidimensional space). Shamos describes an important 
structure, the Voronoi diagram, which allows many geometric 
problems dealing with n points in a plane to be solved in 
0(«log 2 n) time. Among these are determining the nearest 
neighbor of every point, and constructing the minimal span¬ 
ning tree of the point sets, both important tasks in many data 
analysis procedures and previously requiring 0 (n 2 ) time. 
Many other important problems have been solved after being 
cast in a geometric framework. One result, for example, 
revealed that the standard simplex method of linear pro¬ 
gramming is not optimal for two - and three-variable programs 
with n constraints. The simplex method has worst-case 
running times of 0(n 2 ) and 0(n 3 ), respectively; an 
0(nlog 2 n) method has proved optimal for both the two- and 
three-variable case. 

Other areas. We have glimpsed a few fields studied lay 
algorithm designers. The results in many other areas must go 
unmentioned. These include algorithms for problems in 
compilation, operations research, data base management, 
statistics, and character string handling. These results have led 
both to fast algorithms and to a new algorithmic under¬ 
standing of the various fields. 

The “building blocks” of algorithm design. Wandering 
through a computer room we cannot help but be impressed by 
the complexity of a large-scale computing system. The novice 
might find it hard to believe that the human mind could design 
anything so complicated. Although he is not too far from the 
truth, many undergraduates are able to understand the basics 
of computer organization after only one or two semesters. 
They are able to comprehend the complexity not by sheer 
force of concentration, but rather by understanding the 
“building blocks” from which computers are made. A similar 
experience awaits the novice algorithm designer. The algo¬ 
rithms surveyed above deal with many problem areas, but are 
rather simple to comprehend once we understand the 
“building blocks” of algorithm design. Here we will describe 
three important classes of these “blocks.” 

Data structures. Algorithms deal with data, and the algo¬ 
rithm designer uses data structures as tools to organize data. 
Earlier we saw simple data structures such as arrays and 
matrices, and a fairly complex data structure, the hash table. 


Number 44 

138 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



There are more exotic types, such as linked lists, stacks, 
queues, priority queues, and trees. Each provides an appro¬ 
priate way to structure data for a particular task. Taijan 33 
briefly describes many of these structures; Knuth 34 provides 
detailed descriptions of a large number of interesting 
structures. 

Algorithmic techniques. Structured programming demands 
that a programmer express a complicated sequence of 
commands as a series of refinements by which the program can 
be understood at different levels. In each of these refinements 
the programmer applies a basic, well understood method to a 
well defined problem. Good programmers used this technique 
long before it was verbalized; good algorithm designers use a 
similar strategy even though they infrequently discuss it. The 
constructs available to the algorithm designer are similar to 
those available in structured programming, though somewhat 
more powerful. We will describe some of these constructs very 
briefly; more detail can be found in Taijan 35 and Aho, 
Hopcroft, and Ullman. 36 

We have already seen many common algorithmic con¬ 
structs. Most of the algorithms we described use iteration in 
one form or another—this says “do x over and over until the 
task is accomplished.” Iteration is present in almost all pro¬ 
gramming languages as DO and WHILE loops. A more power¬ 
ful construct is recursion, giving us a way to express recursive 
problem solving in programming languages. To define a 
recursive solution to a problem we say (essentially) “to solve a 
problem of a certain size, solve the same problem of a smaller 
size.” We used recursion to describe a binary search: to binary 
search a table of size n we binary searched a table of size n /2. 
A particular application of recursion, divide-and-conquer, says 
“to solve a problem of size n, first divide it into subproblems 
each of size only a fraction of n, then solve those subproblems 
recursively, and finally combine the subsolutions to yield a 
solution to the original problem.” We can view Mergesort as 
a textbook example of divide-and-conquer: to sort a list of 
n elements we first break the list into two sublists each of 
n/2 elements, then sort those recursively, and finally merge 
those together. The FFT and the 0(n 2M ) matrix multiplica¬ 
tion algorithms are other applications of the divide-and- 
conquer technique. Once we understand the fundamental 
principles of divide-and-conquer algorithms, we can easily 
grasp each of these instances. 

Researchers have identified and studied many other algo¬ 
rithmic techniques. Dynamic programming, a technique from 
operations research, has found many applications in algorithm 
design. Search strategies such as breadth-first search and 
depth-first search have yielded efficient graph algorithms. 
Transformation allows us to turn an instance of one problem 
into another; we saw earlier that there are many transforma¬ 
tions to turn almost totally unrelated problems into instances 
of matrix multiplication. Perhaps the single most important 
algorithmic tecnhique is the use of optimal tools to solve the 
subproblems we create for ourselves in designing a new algo¬ 
rithm. 

Proof techniques. Once an algorithm designer has devised 
an algorithm and “knows in his heart” that it has certain 
properties, he must prove that it does. (Perhaps this separates 
practitioner from theorist.) He must first prove that his algo¬ 
rithm indeed computes what it purports to; he will use many 
of the tools of program verification here. Next he must 
analyze his algorithm’s resource requirements, using many 
different mathematical tools. Finally he must prove his algo¬ 


rithm optimal by giving a lower bound proof. Weide 37 dis¬ 
cusses the different methods of analysis used in these steps. 

Current directions 

Algorithm design has grown rapidly in the past decade. 
Essentially unknown as a field ten years ago, it is not one of 
theoretical computer science’s most active areas and sees wide¬ 
spread use in applications. Continued emphasis on 
performance ensures even more algorithm research. Here we 
will examine some of the directions in which the field is 
moving. 

One constant trend has been from “toy” problems to 
“real” problems. This involves many detailed analyses and 
expected-resource analyses, for in applications we are often 
seriously concerned about 20-percent differences in average 
running time. Much recent work has centered on approxima¬ 
tion algorithms, since many applications do not require exact 
answers. On the theoretical side, the outstanding question is 
the complexity of the NP-complete problems—are they 
exponential or not? Another important theoretical problem is 
the search for some underlying theory of algorithm design; we 
still have no theoretical explanation for what makes a class of 
problems easy or hard. Taijan has mentioned the need for a 
“calculus of data structures”—a set of rules leading to the best 
possible structure for a given situation. 

An outgrowth of this work will be the development of 
“algorithm engineering.” This field will supply the program¬ 
mer with tools similar to those electrical engineering gives the 
circuit designer. Before algorithm design turns into algorithm 
engineering we will need to develop many more specific algo¬ 
rithms and provide a theoretical base for the field. We will 
know that the field has become an engineering discipline as 
soon as theoretical computer scientists assert that designing 
algorithms is no longer bona fide research because “it’s such a 
well-understood process.” 

Algorithm design offers much to individuals involved in 
computing-related activities. The mathematician and theo¬ 
retical computer scientist can view the field as a rich source 
of problems needing precise mathematical treatment. These 
problems are mathematically fascinating and call for some of 
the most powerful tools of discrete mathematics. The applica¬ 
tions programmer with little interest in elegant theorems can 
also benefit, since proper algorithm design occasionally yields 
significant financial savings. But even placing aside benefits to 
specific practitioners, I feel that anyone involved with com¬ 
puting, regardless of his position in the practical-to-theoretical 
continuum, should have some familiarity with the field. The 
study of algorithms is the study of the very heart of 
computing, and it provides us with a new way of thinking 
about our computational problems. 

Acknowledgments 

This paper has profited from the helpful criticism of many 
people; the comments of David Jefferson, Len Shustek, and 
Bruce Weide have been particularly helpful. The research 
described here was supported in part by the Office of Naval 
Research, under Contract N000014-76-C-0370. 


Page 14 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 44 

139 



References 


1. J. E. Hopcroft, “Complexity of Computer Computations,” 
Proc. IF1P Congress 74, Vol. 3, 1974, pp. 620-626. 

2. R. E. Taijan, “Complexity of Combinatorial Algorithms,” SIAM 
Review, Vol. 20, No. 3, July 1978, pp. 457-491. 

3. B. Weide, “A Survey of Analysis Techniques for Discrete Algo¬ 
rithms,” Computing Surveys, Vol. 9, No. 4, Dec. 1977, pp. 
291-313. 

4. D. E. Knuth, “Mathematical Analysis of Algorithms,” IFIP 
Congress 71, Vol. 1, 1971, pp. 135-143. 

5. D. E. Knuth, “Algorithms,” Scientific American, Vol. 236, No. 
4, Apr. 1977, pp. 63-80. 

6. A. V. Aho, J. E. Hopcroft, and J. D. Ullman, The Design and 
Analysis of Computer Algorithms, Addison-Wesley, Reading, 
Mass., 1974. 

7. D. E. Knuth, The Art of Computer Programming, Volume 1: 
Fundamental Algorithms, Addison-Wesley, Reading, Mass., 

1968. * 

8. D. E. Knuth, The Art of Computer Programming, Volume 2: 
Seminumerical Algorithms, Addison-Wesley, Reading, Mass., 

1969. 

9. D. E. Knuth, The Art of Computer Programming, Volume 3: 
Sorting and Searching, Addison-Wesley, Reading, Mass., 1973. 

10. Knuth, Art of Computer Programming, Volume 3, p. 391. 

11. Knuth, Scientific American, Vol. 236, No. 4, Apr. 1977, p. 63ff. 

12. D. E. Knuth, J. H. Morris, and V. R. Pratt, “Fast Pattern Match¬ 
ing in Strings,” SIAM Journal of Computing, Vol. 6, No. 2, June 
1977, pp. 323-350. 

13. R. S. Boyer and J. S. Moore, “A Fast String Searching Algo¬ 
rithm.” CACM, Vol. 20, No. 10, Oct. 1977, pp. 762-772. 

14. J. M. Cooley and J. W. Tukey, “An Algorithm for the Machine 
Calculation of Complex Fourier Series,” Mathematics of 
Computation, Vol. 19, 1965, pp. 297-301. 

15. Aho, Hopcroft, and Ullman, Design and Analysis..., pp. 252- 
276. 

16. A. Borodin and I. Munro, The Computational Complexity of 
Algebraic and Numeric Problems, Elsevier-North Holland Pub. 
Co., N.Y., Theory of Computation Series No. 1, 1975. 

17. D. R. Brillinger, Time Series: Data Analysis and Theory, Holt, 
Rinehart, and Winston, N.Y., 1975. 

18. V. Strassen, “Gaussian Elimination is Not Optional,” Numerishe 
Mathematik, Vol. 13, 1969, pp. 345-356. 

19. W. Diffle and M. Heilman, “New Directions in Cryptography,” 
IEEE Trans. Information Theory, Vol. IT-22, No. 6, Nov. 1976, 
pp. 644-654. 

20. R. L. Rivest, A. Shamir, and L. Adleman, “A Mathod for Obtain¬ 
ing Digital Signatures and Public-Key Cryptosystems,” CACM, 
Vol. 21, No. 3, Feb. 1978, pp. 120-126. 

21. M. Gardner, “A New Kind of Cipher That Would Take Millions 
of Years to Break” (Mathematical Games), Scientific American, 
Vol. 236, No. 8, Aug. 1977, pp. 120-125. 

22. Knuth, Art of Computer Programming, Volume 1, pp. 120-160. 

23. Aho, Hopcroft, and Ullman, Design and Analysis..., pp. 2-41. 

24. Ibid., pp. 24-25. 

25. H. T. Kung, “Synchronized and Asynchronous Parallel Algo¬ 
rithms for Multiprocessors,” in Algorithms and Complexity: 
New Directions and Recent Results, J. F. Traub, Ed., Academic 
Press, N.Y., 1976, pp. 153-200. 

26. H. R. Lewis and C. H. Papidimitriou, “The Efficiency of Algo¬ 
rithms,” Scientific American, Vol. 238, No. 1, Jan. 1978, pp. 
97-109. 

27. M. R. Garey and D. S. Johnson, “Approximation Algorithms for 
Combinatorial Problems: An Annotated Bibliography,” in 
Algorithms and Complexity: New Directions and Recent Re¬ 
sults, J. F. Traub, ed.. Academic Press, N.Y., 1976, pp. 41-52. 

28. Knuth, Art of Computer Programming, Volume 3. 


29. M. Blum, R. Floyd, V. Pratt, R. Rivest, and R. Taijan, ‘Time 
Bounds for Selection,” Journal of Computer and Systems 
Sciences, Vol. 7, No. 4, Aug. 1973, pp. 448-461. 

30. Tarjan, SIAM Review, Vol. 20, No. 3. 

31. J. Hopcroft and R. Taijan, “Efficient Planarity Testing,” JA CM, 
Vol. 21, No. 4, Oct. 1974, pp. 549-568. 

32. M. I. Shamos, “Geometric Complexity,” Proc. Seventh ACM 
Symposium on the Theory of Computing, 1975, pp. 224-233. 

33. Taijan, SIAM Review, Vol. 20, No. 3. 

34. Knuth, Art of Computer Programming, Volume 1. 

35. Taijan, SIAM Review, Vol. 20, No. 3. 

36. Aho, Hopcroft, and Ullman, Design and Analysis..., pp. 44-74. 

37. Weide, Computing Surveys, Vol. 9, No. 4, pp. 291-313. 


Jon Louis Bentley is an assistant professor of computer science and 
mathematics at Carnegie-Mellon University, Pittsburgh, Pennsylvania. 
He worked as a research intern at the Xerox Palo Alto Research Center 
from 1973 to 1974. During the summer of 1975 he was a visiting 
scholar at the Stanford Linear Accelerator Center. From 1975 to 1976 
he was a National Science Foundation graduate fellow. His current 
research interests include the design and analysis of computer algo¬ 
rithms (especially for geometrical and statistical problems) and the 
mathematical foundations of computation. 

A member of the ACM and Sigma Xi, Bentley received the BS in 
mathematical sciences from Stanford University in 1974, and the MS 
and PhD in computer science from the University of North Carolina 
in 1976. 



Number 44 

140 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 



ALL THE SECRETS 
YOU EVER WANTED 
.ABOUT POLY 88 BASIC 


BY MARVIN A. KONOPIK 

American Embassy 
AF'O San Francisco 96503 

I have broken some of the 
secrets of the Poly 88 BASIC 
version A00 that might be help¬ 
ful to others in understanding 
their BASIC as well, or at least 
help to get a handle on it. The 
Poly BASIC Manual contains a 
great deal of technical informa¬ 
tion, but the many ways this 
information can be used is not 
fully explained. After retyping a 
program for the third time, 
I threw in the towel, and decided 
there must be an easier way. 
So, I have listed below some 
short-cuts that make computer 
life a whole new game and a lot 
more fun. 

SCR is a dirty word: type 
SCR or LOAD and all is lost! 
Wrong . . . The key to the prob¬ 
lem is in location 205D and 205E. 
The address listed here tells you 
where BASIC started loading 
your program. Go to that loca¬ 
tion, and scroll ahead. You will 
see several rows of zeros, which 
is what SCR is all about. Scroll 
ahead further and look through 
the memory until you see an 0D. 
This is the Carriage Return in 
Hex. Remember the memory 
| location of the 0D. Put this 
1 location into position 205D, type 
j in the warm start SPJ2003 
and a G and your program is 
up. Restore your program, record 
it onto tape, and after you 
verify it, reload your BASIC 
and continue. I have never re¬ 
loaded my BASIC; it seems to 
operate perfectly with the new 
| starting point, but why take a 
1 chance. You lost the first couple 
of lines, but this is no big deal. 
Next time begin your programs 
with a full REM line of 63 spaces, 
j to minimize your losses in case 
| of an accident. 

If that was easy, then try 
the following hard way for greater 
l program salvage. Using the solu¬ 
tion above, you have lost some 
valuable program material be¬ 
tween the end of the zeros and 
the first 0D. This may have been 
valuable text that SCR or LOAD 
j did not destroy, but which you 
did. If you want to restore your 
program and minimize the losses, 
| call up location 205D to see 


where your program starts. Go to 
the location shown in 205D and 
you should see 0D and several 
lines of zeros. Hit the spacebar 
to go to the next location after 
the 0D. There is probably an 01 
already in that box, but load 2C 
into it. 2C is Hex for 44. Now 
back up until the 0D is in the 
memory window again. Now hit 
the spacebar 44 times and if the 
memory is still full of zeros, 
type in an 0D. Use control H 
or LF back to the location follow¬ 
ing the 2C. You can use any 
number instead of 2C, except that 
44 should be near the last of the 
zeros and it seems to work about 
right. Put in a 01 00 8F and 
fill the remaining locations with 
20 until you reach the 0D that 
you just loaded. As you may have 
guessed, the first 2C was the 
length of the line from 0D to 0D. 
The 01 00 was the wasy BASIC 
stores line number 0001, the 8F is 
what BASIC calls REM when it 
stores it into memory, and the 
20s are all spaces in Hex. You 
have just typed in a REM line 
of 40 or so spaces in BASIC, 
the hard way. Now for line 0002. 
In the next block after the OD of 
line 0001 that you just typed, put 
in FF so you can find it easily 
later. Back up again to the 0D be¬ 
fore the FF and count the number 
of spacebar hits until the next 
0D appears. Write this number 
down. If this number is less than 
64, then continue, if not, read 
on, I’ll help you later. Your 
number, which is less than 64, 
should be converted to HEX 
and put in place of the FF you 
previously loaded as the start 
of line 0002. The next locations 
will be 02 00 8F and the re¬ 
maining zeros should be filled 
with 20’s as you did in line one. 
If you had over 64 in your 
count, then re-do the procedure 
above for line 0001 using 40 
(64 decimal) or some number in 
between, to lengthen line 0001 
until the OD is closer to the end 
of the zeros and the beginning of 
the program to be saved. Another 
way is to make a very short line 
0002 and use 0003 for the first 
partial line to be salvaged. The 
drawback is that 3 could be too 
high if only line 01 was lost, and 
you had line 2 twice. Another way 
out is to renumber the next line 
since you now know how they 


are stored in memory by the 
BASIC program. Now that you 
have filled all the zeros with 
something, type in your warm 
start location, and your program 
should be there with the fust 
partial line of your program 
included on the end of a REM 
line, but at least it is not lost. 
If it did not come up, you simply 
miscounted your line length, so 
go back and count again. If it 
still will not come up, look ahead 
in memory and practice counting 
the lines there between OD’s 
until you have the system down 
pat and then try again. 

Merging programs is a com¬ 
plicated procedure! Not Really. 
Before you load BASIC, Hit 
Cmnd Z, and load the following 
machine program into memory 
starting at location 2000. 97 21 
09 20 77 23 C3 04 20 and then 
SPJ2000 and a G. When the 
screen flashes bright white, all 
memory has been set to zeros. 
Now load in BASIC and your first 
program. Type REN 1,1 and 
LIST your program. Remember 
to copy the last line number on 
a piece of paper so you don’t 
forget it. Hit Cmnd Z and scroll 
through the memory a hundred 
lines or so at a time, starting at 
4A00 until you find the zeros. 
Back up until you find the last 
0D of the program, before the 
zeros start. Write down this 
memory location, and call up 
location 205D. Also remember 
the numbers that are in 205D: 
you will need them later. Load 
the location of the last 0D into 
205D and 205E. Type in SPJ2000 
(cold start) and a G. Load the 
next program just like you did 
the first. Type LIST to see if 
the second program is there. 
RENumber it, but use a number 
higher than the last line of the 
previous program. Do a Cmnd Z 
again, and change location 205D 
back to what it originally was, 
and Warm Start your program 
using 2003. Hit LIST, and be¬ 
hold! Two programs in a row. 
Mark down the new last line 
number, go back to the memory 
to check for the last 0D again, 
change location 205 D to this 
location, cold start 2000, load 
the third program, return 205D 
to its original state, warm start 
on 2003 and you’re up with 
3 programs in a row. 

You bought a printer and now 
you found out that you cannot 
warm start and save either the 
program or the printer/driver! 
It’s simple: change the data at 
location 4A4D from 00 20 to 
03 20 and warm start using 49C0. 
You can re-record BASIC this 
way, but dump from locations 
2000 through at least 4C02 


just to be safe. BASIC will now 
always come on warm, but you 
may occasionally have to do a 
SCR before you can load your 
programs. If you zeroize memory 
before you re-record BASIC, 
it will not load. You may have to 
load a small program to put some 
text in the buffer first, but it’s 
worth the effort to have 2003 
in location 4A4D when you need 
it for a warm start and still retain 
the use of the Printer/Driver. 

Can’t warm start your Assem¬ 
bler? I cannot find this in the 
manual. I guess the Poly people 
thought everybody should go 
around retyping lost programs 
even if it took days. Well I did 
my share of retyping and then 
discovered that when you type 
MNTR you can return to the 
Editor by hitting a G. For this, 
Poly puts the address 20FF in 
the program counter. So if Poly 
can do that, you can too, and 
warm start any time you have a 
lock up by using 20FF. 

Have you ever wanted to 
exchange text in the Editor, or 
switch the end of your Assembler 
program to the beginning and the 
beginning to the end? Rather than 
retype it, let the Editor help you. 
Dump the text on tape and make 
a note of the length of the dump 
as well as the reading of the index 
counter on the recorder. For 
instance, we want the last half 
first and the first half last. KILL 
the old text from memory, 
and back the recorder up half 
way. Now load from that point 
onward to the end. When you hit 
the end, rewind to the beginning 
and start loading again until you 
feel you have loaded all the text 
on tape somewhere at least one 
time. Delete duplicate text and 
tidy it up for use. I am not a 
very fast typist, but watch me go 
with the delete and Cmnd X line 
remover. Using this procedure, 
you can load bits and pieces of 
different programs together into 
one blend. 

So much for the serious part 
of life! Do you want some fun? 
Type ‘flip’ in small letters while 
you are up in BASIC. It reverses 
the keyboard. You, who have to 
use this, probably don’t think 
it’s funny, but it makes.the key¬ 
board the damdest thing you 
have ever tried to type with. 

The data stored at location 
205D shows where BASIC begins 
storing your program in memory. 
I hope somebody can find the 
location where BASIC stores the 
last 0D (CR) of the program, if 
there is a location. 

And so as you see, the discov¬ 
eries go on, and on, and on, 
and each time, life becomes a 
little easier with Poly. 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics 8< Orthodontia, Box E, Menlo Park, CA 94025 


Number 44 

141 









A SYNTAX-ORIENTED 
COMPILER WRITING LANGUAGE 


BY D. V. SCHORRE 

UCLA Computing Facility 
University of California at Los Angeles 
Los Angeles, California 

© 1964, Association for Computing Machinery, Inc. 

Reprinted by Permission 

Introduction 

This classic paper describes a metacompiler developed as a project 
of the Los Angeles Chapter of SIGPLAN, the Association for Com¬ 
puting Machinery’s special interest group in programming languages. 
Several artifacts of the time appear-the use of ”rather than 
and the use of “/" rather than “ I ” is due to the limited character set 
on the IBM 026 keypunch. The original Meta II ran on the IBM 1401, 
a machine with limited resources by today’sstandards. We’ve reprinted 
it here because it is still a good tool for experimenting with languages 
and their implementation. To install a Meta II system on your com¬ 
puter, you must hand-compile the Meta II compiler given in the article 
(an instructive exercise in itself] and write an interpreter for the Meta II 
machine in some suitable language (Microsoft BASIC wouldn't be a bad 
choice). To check the whole thing, the compiler should compile itself 
exactly. If not, fix the bug(s) and try again. In the end, you ’ll have a 
nice tool for experimenting with programming languages and learn a 
bit about the compiling process to boot. - Dennis R. Allison 

META II is a compiler writing language which consists of syntax 
equations resembling Backus normal form and into which instructions 
to output assembly language commands are inserted. Compilers have 
been written in this language for VALGOL I and VALGOL II. The 
former is a simple algebraic language designed for the purpose of 
illustrating META II. The latter contains a fairly large subset of 
ALGOL 60. 

The method of writing compilers which is given in detail in the 
paper may be explained briefly as follows. Each syntax equation is 
translated into a recursive subroutine which tests the input string for a 
particular phrase structure, and deletes it if found. Backup is avoided 
by the extensive use of factoring in the syntax equations. For each 
source language, an interpreter is written and programs are compiled 
into that interpretive language. 

META II is not intended as a standard language which everyone 
will use to write compilers. Rather, it is an example of a simple working 
language which can give one a good start in designing a compiler- 
writing compiler suited to his own needs. Indeed the META II compiler 
is written in its own language, thus lending itself to modification. 


Reprinted from the Proceedings of the 19th National Conference of 
the Association for Computing Machinery, 1964. 


History 

The basic ideas behind META II were described in a series of three 
papers by Schmidt, 1 Metcalf, 2 and Schorre. 3 These papers were 
presented at the 1963 National A.C.M. Convention in Denver, and 
represented the activity of the Working Group on Syntax-Directed 
Compilers of the Los Angeles SIGPLAN. The methods used by that 
group are similar to those of Glennie and Conway, but differ in one 
inportant respect. Both of these researchers expressed syntax in the 
form of diagrams, which they subsequently coded for use on a com¬ 
puter. In the case of META II, the syntax is input to the computer in a 
notation resembling Backus normal form. The method of syntax 
analysis discussed in this paper is entirely different from the one used 
by Irons 6 and Bastian. 7 All of these methods can be traced back to the 
mathematical study of natural languages, as described by Chomsky. 8 

Syntax Notation 

The notation used here is similar to the meta language of the 
ALGOL 60 report. Probably the main difference is that this notation 
can be keypunched. Symbols in the target language are represented as 
strings of characters, surrounded by quotes. Metalinguistic variables 
have the same form as identifiers in ALGOL, viz., a letter followed by 
a sequence of letters or digits. Items are written consecutively to 
indicate concatenation and separated by a slash to indicate alternation. 
Each equation ends with a semicolon which, due to keypunch limita¬ 
tion, is represented by a period followed by a comma. An example of 
a syntax equation is: 

LOGICAL VALUE = ‘. TRUE ’ / ‘. FALSE ’., 

In the versions of ALGOL described in this paper the symbols which 
are usually printed in boldface type will begin with periods, for 
example: 

.PROCEDURE .TRUE .IF 

To indicate that a syntactic element is optional, it may be put in 
alternation with the word . EMPTY. For example: 

SUBSECONDARY = ‘ * ’ PRIMARY / . EMPTY . , 
SECONDARY = PRIMARY SUBSECONDARY . , 


Number 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 17 







By factoring, these two equations can be written as a single equation. 

SECONDARY = PRIMARY (‘ * ’ PRIMARY / . EMPTY)., 

Built into the META II language is the ability to recognize three 
symbols which are: 

1. Identifiers - represented by . ID, 

2. Strings - represented by . STRING, 

3. Numbers — represented by . NUMBER. 

The definition of identifier is the same in META II as in ALGOL, 
viz., a letter followed by a sequence of letters or digits. The definition 
of a string is changed because of the limited character set available on 
the usual keypunch. In ALGOL, strings are surrounded by opening and 
closing quotation marks, making it possible to have quotes within a 
string. The single quotation mark on the keypunch is unique, imposing 
the restriction that a string in quotes can contain no other quotation 
marks. 

The definition of number has been radically changed. The reason 
for this is to cut down on the space required by the machine subroutine 
which recognizes numbers. A number is considered to be a string of 
dijpts which may include imbedded periods, but may not begin or end 
with a period; moreover, periods may not be adjacent. The use of the 
subscript 10 has been eliminated. 

Now we have enough of the syntax defining features of the 
META II language so that we can consider a simple example in some 
detail. 

The example given here is a set of four syntax equations for defining 
a very limited class of algebraic expressions. The two operators, 
addition and multiplication, will be represented by + and * respectively. 
Multiplication takes precedence over addition; otherwise precedence is 
indicated by parentheses. Some examples are: 

A 

A + B 
A + B *C 
(A + B) * C 

The syntax equations which define this class of expressions are as 
follows: 

EX3 = . ID / ‘ (‘ EX1 ’) ’., 

EX2 = EX3 ( * * * EX2 / . EMPTY ). , 

EX1 = EX2 ( ‘ + ’ EX1 / . EMPTY ). , 

EX is an abbreviation for expression. The last equation, which 
defines an expression of order 1, is considered the main equation. 
The equations are read in this manner. An expression of order 3 is 
defined as an identifier or an open parenthesis followed by an expres¬ 
sion of order 1 followed by a closed parenthesis. An expression of 
order 2 is defined as an expression of order 3, which may be followed 
by a star which is followed by an expression of order 2. An expression 
of order 1 is defined as an expression of order 2, which may be fol¬ 
lowed by a plus which is followed by an expression of order 1. 

Although sequences can be defined recursively, it is more con¬ 
venient and efficient to have a special operator for this purpose. For 
example, we can define a sequence of the letter A as follows: 

SEQA = $ ‘ A ’., 

The equations given previously are rewritten using the sequence 
operator as follows: 

EX3 = . ID / ‘ (‘ EX1 
EX2 = EX3 $ (‘ * ’ EX3 ) ., 

EX1 = EX2 $ (‘ + ’ EX2 )., 


Output 

Up to this point we have considered the notation in META II which 
describes object language syntax. To produce a compiler, output 
commands are inserted into the syntax equations. Output from a 
compiler written in META II is always in an assembly language, but not 
in the assembly language for the 1401. It is for an interpreter, such as 
the interpreter I call the META II machine, which is used for all 
compilers, or the interpreters I call the VALGOLI and VALGOLII 
machines, which obviously are used with their respective source 
languages. Each machine requires its own assembler, but the main 
difference between the assemblers is the operation code table. Constant 
codes and declarations may also be different. These assemblers all have 
the same format, which is shown below. 

LABEL CODE ADDRESS 

1- -6 8- -10 12- -70 

An assembly language record contains either a label or an op code of 
up to 3 characters, but never both. A label begins in column 1 and may 
extend as far as column 70. If a record contains an op code, then 
column 1 must be blank. Thus labels may be any length and are not 
attached to instructions, but occur between instructions. 

To produce output beginning in the op code field, we write .OUT 
and then surround the information to be reproduced with parentheses. 
A string is used for literal output and an asterisk to output the special 
symbol just found in the input. This is illustrated as follows: 

EX3 = . ID . OUT (‘ LD ’ * ) / ‘ (‘ EX1 ’) ’., 

EX2 = EX3 $ (‘ * ’ EX3 . OUT ( ‘ MLT ’) ) . , 

EX1 = EX2 $ (‘+’EX2 .OUT(‘ADD’)) . , 

To cause output in the label field we write .LABEL followed by 
the item to be output. For example, if we want to test for an identifier 
and output it in the label field we write: 

.ID .LABEL * 

The META II compiler can generate labels of the form A01, A02, 
A03, ... A99, B01, ... .To cause such a label to be generated, one 
uses *1 or *2. The first time *1 is referred to in any syntax equation, 
a label will be generated and assigned to it. This same label is output 
whenever * 1 is referred to within that execution of the equation. The 
symbol *2 works in the same way. Thus a maximum of two different 
labels may be generated for each execution of any equation. Repeated 
executions, whether recursive or externally initiated, result in a 
continued sequence of generated labels. Thus all syntax equations 
contribute to the one sequence. A typical example in which labels are 
generated for branch commands is now given. 

IFSTATEMENT = ‘. IF ’ EXP ‘ .THEN ’ .OUT (' BFP ’ *1) 
STATEMENT ‘ .ELSE ’ .OUT ( ‘ B ’ *2 ) .LABEL *1 
STATEMENT .LABEL *2 ., 

The opcodes BFP and B are orders of the VALGOLI machine, and 
stand for “branch false and pop” and “branch” respectively. The 
equation also contains references to two other equations which are not 
explicitly given, viz., EXP and STATEMENT. 

VALGOL I — A Simple Compiler Written in META II 

Now we are ready for an example of a compiler written in META II. 
VALGOL I is an extremely simple language, based on ALGOL 60, 
which has been designed to illustrate the META II compiler. 

The basic information about VALGOL I is given in figure 1 (the 
VALGOL I compiler written in META II) and figure 2 (order list of 
the VALGOL I machine). A sample program is given in figure 3. After 
each line of the program, the VALGOL I commands which the 
compiler produces from that line are shown, as well as the absolute 


Page 18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

143 



interpretive language produced by the assembler. Figure 4 is output 
from the sample program. Let us study the compiler written in 
META II (figure 1) in more detail. 

The identifier PROGRAM on the first line indicates that this is the 
main equation, and that control goes there first. The equation for 
PRIMARY is similar to that of EX3 in our previous example, but here 
numbers are recognized and reproduced with a “load literal” command. 
TERM is what was previously EX2; and EXP1 what was previously EX1 
except for recognizing minus for subtraction. The equation EXP 
defines the relational operator “equal,” which produces a value of 0 
or 1 by making a comparison. Notice that this is handled just like the 
arithmetic operators but with a lower precedence. The conditional 
branch commands, “branch true and pop” and “branch false and pop,” 
which are produced by the equations defining UNTILST and 
CONDITIONALST respectively, will test the top item in the stack and 
branch accordingly. 

The “assignment statement” defined by the equation for 
ASSIGNST is reversed from the convention in ALGOL 60, i.e., the 
location into which the computed value is to be stored is on the right. 
Notice also that the equal sign is used for the assignment statement and 
that period equal (.=) is used for the relation discussed above. This is 
because assignment statements are more numerous in typical programs 
than equal compares, and so the simpler representation is chosen for 
the more frequently occurring. 

The omission of statement labels from the VALGOL I and 
VALGOL II seems strange to most programmers. This was not done be¬ 
cause of any difficulty in their implementation, but because of a dislike 
for statement labels on the part of the author. I have programmed 
for several years without using a single label, so I know that they are 
superfluous from a practical, as well as from a theoretical, standpoint. 
Nevertheless, it would be too much of a digression to try to justify 
this point here. The “until statement” has been added to facilitate 
writing loops without labels. 

The “conditional” statement is similar to the one in ALGOL 60, 
but here the “else” clause is required. 

The equation for “input/output,” IOST, involves two commands, 
“edit” and “print.” The words EDIT and PRINT do not begin with 
periods so that they will look like subroutines written in code. “EDIT” 
copies the given string into the print area, with the first character in the 
print position whish is computed from the given expression. “PRINT” 
will print the current contents of the print area and then clear it to 
blanks. Giving a print command without previous edit commands 
results in writing a blank line. 

IDSEQ1 and IDSEQ are given to simplify the syntax equation 
for DEC (declaration). Notice in the definition of DEC that a branch 
is given around the data. 

From the definition of BLOCK it can be seen that what is con¬ 
sidered a compound statement in ALGOL 60 is, in VALGOL I, a 
special case of a block which has no declaration. 

In the definition of statement, the test for an IOST precedes that 
for an ASSIGNST. This is necessary, because if this were not done the 
words PRINT and EDIT would be mistaken as identifiers and the com¬ 
piler would try to translate “input/output” statements as if they were 
“assignment” statements. 

Notice that a PROGRAM is a block and that a standard set of 
commands is output after each program. The “halt” command causes 
the machine to stop on reaching the end of the outermost block, 
which is the program. The operation code SP is generated after the 
“halt” command. This is a completely 1401-oriented code, which 
serves to set a word mark at the end of the program. It would not be 
used if VALGOL I were implemented on a fixed word-length machine. 

How the META II Compiler Was Written 

Now we come to the most interesting part of this project, and 
consider how the META II compiler was written in its own language. 
The interpreter called the META II machine is not a much longer 
1401 program than the VALGOL I machine. The syntax equations 
for META II (figure 5) are fewer in number than those for the 
VALGOL I machine (figure 1). 


The META II compiler, which is an interpretive program from 
the META II Machine, takes the syntax equations given in figure 5 
and produces an assembly language version of this same interpretive 
program. Of course, to get this started, I had to write the first compiler¬ 
writing compiler by hand. After the program was running, it could 
produce the same program as written by hand. Someone always asks 
if the compiler really produced exactly the program I had written 
by hand and I have to say that it was “almost” the same program. 

I followed the syntax equations and tried to write just what the 
compiler was going to produce. Unfortunately I forgot one of the re¬ 
dundant instructions, so the results were not quite the same. Of course, 
when the first machine-produced compiler compiled itself the second 
time, it reproduced itself exactly. 

The compiler originally written by hand was for a language called 
META I. This was used to implement the improved compiler for META 
II. Sometimes, when I wanted to change the metalanguage, I could 
not describe the new metalanguage directly in the current metalan¬ 
guage. Then an intermediate language was created-one which could 
be described in the current language and in which the new language 
could be described. I thought that it might sometimes be necessary to 
modify the assembly language output, but it seems that it is always 
possible to avoid this with the intermediate language. 

The order list of the META II machine is given in figure 6. 

All subroutines in META II programs are recursive. When the pro¬ 
gram enters a subroutine a stack is pushed down by three cells. One cell 
is for the exit address and the other two are for labels which may be 
generated during the execution of the subroutine. There is a switch 
which may be set or reset by the instructions which refer to the input 
string, and this is the switch referred to by the conditional branch 
commands. 

The first thing in any META II machine program is the address 
of the first instruction. During the initialization for the interpreter, 
this address is placed into the instruction counter. 

VALGOL II Written in META II 

VALGOL II is an expansion of VALGOL I, and serves as an il¬ 
lustration of a fairly elaborate programming language implemented in 
the META II system. There are several features in the VALGOL II 
machine which were not present in the VALGOL I machine, and which 
require some explanation. In the VALGOL II Machine, addresses as 
well as numbers are put in the stack. They are marked appropriately 
so that they can be distinguished at execution time. 

The main reason that addresses are allowed in the stack is that, 
in the case of a subscripted variable, an address is the result of a com¬ 
putation. In an assignment statement each left member is compiled into 
a sequence of code which leaves an address on top of the stack. This is 
done for simple variables as well as subscripted variables, because the 
philosophy of this compiler writing system has been to compile every¬ 
thing in the most general way. A variable, simple or subcripted, is 
always compiled into a sequence of instructions which leaves an address 
on top of the stack. The address is not replaced by its contents until 
the actual value of the variable is needed, as in an arithmetic expression. 

A formal parameter of a procedure is stored either as an address or 
as a value which is computed when the procedure is called. It is up to 
the load command to go through any number of indirect address in 
order to place the address of a number onto the stack. An argument of 
a procedure is always an algebraic expression. In case this expression is 
a variable, the value of the formal parameter will be an address com¬ 
puted upon entering the procedure. 

The operation of the load command is now described. It causes 
the given address to be put on top of the stack. If the content of this 
top item happens to be another address, then it is replaced by that 
other address. This continues until the top item on the stack is the 
address of something which is not an address. This allows for formal 
parameters to refer to other formal parameters to any depth. 

No distinction is made between integer and real numbers. An in¬ 
teger is just a real number whose digits right of the decimal point are 
zero. Variables initially have a value called “undefined,” and any 
attempt to use this value will be indicated as an error. 


Number 44 

144 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 19 



An assignment statement consists of any number of left parts 
followed by a right part. For each left part there is compiled a sequence 
of commands which puts an address on top of the stack. The right part 
is compiled into a sequence of instructions which leaves on top of the 
stack either a number or the address of a number. Following the in¬ 
struction for the right part there is a sequence of store commands, one 
for each left part. The first command of this sequence is “save and 
store,” and the rest are “plain” store commands. The “save and store” 
puts title number which is on the top of the stack (or which is referred 
to by the address on top of the stack) into a register called SAVE. 
It then stores the contents of SAVE in the address which is held in the 
next to top position of the stack. Finally it pops the top two items, 
which it has used, out of the stack. The number, however, remains in 
SAVE for use by the following store commands. Most assignment 
statements have only one left part, so “plain” store commands are 
seldom produced, with the result that the number put in SAVE is 
seldom used again. 

The method for calling a procedure can be explained by reference 
to illustrations 1 and 2. The arguments which are in the stack are 
moved to their place at the top of the procedure. If the number of 


xxxxxxxx 

Function 


xxxxxxxx 

xxxxxxxx 

Arguments 


xxxxxxxx 



b 

Word of one blank character 
the end of the arguments. 

to mark 


Body. Branch commands cause control 
to go around data stored in this area. 
Ends with a “return” command. 


Illustration 1 


Storage Map for VALGOL II Procedures 


XXXXXXXX 

XXXXXXXX 

Arguments in reverse order 


xxxxxxxx 

XXX 

XXX 

Flag 

Address of Exit 

procedure 

XXX 


Stack before executing Stack after executing 

the call instruction the call instruction 


Illustration 2 

Map of the Stack Relating to Procedure Calls 

arguments in the stack does not correspond to the number of arguments 
in the procedure, an error is indicated. The “flag” in the stack works 
like this. In the VALGOL II machine there is a flag register. To set a 
flag in the stack, the contents of this register is put on top of the stack, 
then the address of the word above the top of the stack is put into the 
flag register. Initially, and whenever there are no flags in the stack, the 


flag register contains blanks. At other times it contains the address of 
the word in the stack which is just above the uppermost flag. Just be¬ 
fore a call instruction is executed, the flag register contains the address 
of the word in the stack which is two above the word containing the 
address of the procedure to be executed. The call instruction picks up 
the arguments from the stack, beginning with the one stored just above 
the flag, and continuing to the top of the stack. Arguments are moved 
into the appropriate places at the top of the procedure being called. 
An error message is given if the number of arguments in the stack does 
not correspond to the number of places in the procedure. Finally the 
old flag address, which is just below the procedure address in the stack, 
is put in the flag register. The exit address replaces the address of the 
procedure in the stack, and all the arguments, as well as the flag, are 
popped out. There are just two op codes which affect the flag register. 
The code “load flag” puts a flag into the stack, and the code “call” 
takes one out. 

The library function “WHOLE” truncates a real number. It does 
not convert a real number to an integer, because no distinction is 
made between them. It is substituted for the recommended function 
‘ENTIER” primarily because truncation takes fewer machine instruc¬ 
tions to implement. Also, truncation seems to be used more frequently. 
The procedure ENTIER can be defined in VALGOL II as follows: 

.PROCEDURE ENTIER(X) ., 

.IF 0 .L = X .THEN X .ELSE 
IF WHOLE(X) = X .THEN X .ELSE 
WHOLE(X) -1 

The “for statement” in VALGOL II is not the same as it is in 
ALGOL. Exactly one list element is required. The “step ... until” 
portion of the element is mandatory, but the “while” portion may 
be added to terminate the loop immediately upon some condition. 
The iteration continues so long as the value of the variable is less than 
or equal to the maximum, irrespective of the sign of the increment. 
Illustration 3 is an example of a typical “for statement.” A flow chart 
of this statement is given in illustration 4. 


.FOR I = 0 .STEP 1 .UNTIL N .DO 



[statement] 



SET 


Set switch to indicate first time through. 

A91 

LD 

1 



FLP 

] 

Test for first time through. 


BFP 

A92 J 



LDL 

0 1 



SST 


i Initialize variable. 


B 

A93 ) 


A92 

LDL 

1 ) 

Increment variable. 

’ 


ADS 

1 


A93 

RSR 

1 

Compare variable to maximum. 


LD 

N 



LEQ 




BFP 

A94 J 



[statement] 



RST 


Reset switch to indicate not first time 


through. 

B A91 

A94 


Illustration 3 

Compilation of a typical “for statement” 
in VALGOL II 


Page 20 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

145 













It can back-up the input and output and return false. The advantages 
of backup are as follows: 



Illustration 4 

Flow chart of the “for statement” 
given in figure 12 

Figure 7 is a listing of the VALGOLII compiler written in META II. 
Figure 8 gives the order list of the VALGOL II machine. A sample 
program to take a determinant is given in figure 9. 

Backup vs. No Backup 

Suppose that, upon entry to a recursive subroutine, which repre¬ 
sents some syntax equation, the positions of the input and output 
are saved. When some non-first term of a component is not found, the 
compiler does not have to stop with an indication of a syntax error. 


1. It is possible to describe languages, using backup, which cannot be 
described without backup. 

2. Even for a language which can be described without backup, the 
syntax equations can often be simplified when backup is allowed. 

The advantages claimed for non-backup are as follows: 

1. Syntax analysis is faster. 

2. It is possible to tell whether syntax equations will work just by 
examining them, without following through numerous examples. 

The fact that rather sophisticated languages such as ALGOL and 
COBOL can be implemented without backup is pointed out by various 
people, including Conway, 5 and they are aware of the speed advant¬ 
ages of so doing. I have seen no mention of the second advantage of 
no-backup, so I will explain this in more detail. 

Basically one writes alternations in which each term begins with 
a different symbol. Then it is not possible for the compiler to go down 
the wrong path. This is made more complicated because of the use of 
“.EMPTY”. An optional item can never be followed by something that 
begins with the same symbol it begins with. 

The method described above is not the only way in which backup 
can be handled. Variations are worth considering, as a way may be 
found to have the advantages of both backup and no-backup. 

Further Development of META Languages 

As mentioned earlier, META II is not presented as a standard 
language, but as a point of departure from which a user may develop 
his own META language. The term “META Language,” with “META” 
in capital letters, is used to denote any compiler-writing language so 
developed. 

The language which Schmidt 1 implemented on the PDP-1 was 
based on META 1. He has now implemented an improved version of 
this language for a Beckman machine. 

Rutman 9 has implemented LOGIK, a compiler for bit-time simula¬ 
tion, on the 7090. He uses a META Language to compile Boolean 
expressions into efficient machine code. Schneider and Johnson 10 
have implemented META 3 on the IBM 7094, with the goal of pro¬ 
ducing an ALGOL compiler which generates efficient machine code. 
They are planning a META langauge which will be suitable for any 
block structured language. To this compiler-writing language they give 
the name META 4 (pronounced metaphor). 

References 

1. Schmidt, L., “Implementation of a Symbol Manipulator for Heuristic 
Translation,” 1963 ACM Natl. Conf., Denver, Colo. 

2. Metcalfe, Howard, “A Parameterized Compiler Based on Mechan¬ 
ical Linguistics,” 1963 ACM Natl. Conf., Denver, Colo. 

3. Schorre, Val, “A Syntax-Directed SMALGOL for the 1401,” 
1963 ACM Natl. Conf., Denver, Colo. 

4. Glennie, A., “On the Syntax Machine and the Construction of a 
Universal Compiler,” Tech. Report No. 2, Contract NR 049-141, 
Carnegie Inst, of Tech., July, 1960. 

5. Conway, Melvin E., “Design of a Separable Transition-Diagram 
Compiler,” Comm. ACM, July 1963. 

6. Irons, E.T., The Structure and Use of the Syntax-Directed Com¬ 
piler,” Annual Review in Automatic Programming, The Macmillan 
Co., New York. 

7. Bastian, Lewis, “A Phrase-Structured Language Translator,” 
AFCRL- Rept-62-549, Aug. 1962. 

8. Chomsky, Noam, “Syntax Structures,” Mouton and Co., Publishers, 
The Hague, Netherlands. 

9. Rutman, Roger, “LOGIK, A Syntax Directed Compiler for Com¬ 
puter Bit-Time Simulation,” Master Thesis, UCLA, August 1964. 

lO.Schneider, F.W., and G.D. Johnson, “A Syntax-Directed Com¬ 
piler-Writing Compiler to Generate Efficient Code,” 1964 ACM 
Natl. Conf., Philadelphia. 


Number 44 

146 


Dr. Dobb's Journal of Computer Calisthenics 8t Orthodontia, Box E. Menlo Park, CA 94025 


Page 21 




THE VALGOL 1 COMPILER WRITTEN IN META II LANGUAGE 
FIGURE 1 


A PROGRAM AS COMPILED FOR TmE VALGOL I MACHINE 
FIGURE 3 


•SYNTAX PROGRAM 

PRIMARY - .10 .OUTf'LO • *> / 

• NUMBER «OUT(*LOL* •! / 

•t• EXP •)• •• 

TERM - PRIMARY *(••• PRIMARY •OUTCMLT*! I •• 

EXP1 • TERM *!•♦• TERM .OUT!•ADD*I / 

TERM .OUT(•SUB*I ) •• 

EXP - EXP1 I •.-• EXP 1 «OUTI•EQU'I / .EMPTY) •• 

ASSIGNST - EXP .ID .OUTMST • •) .. 

UNTILST • ••UNTIL' .LABEL •! EXP '.DO* .OUTI'BTP* *21 
ST .OUT(*8 ' *1) .LABEL *2 •• 

CONDITIONALST - '•IF* EXP '.THEN' .OUTt'BFP* «1| 

ST '.ELSE* .OUT I•8 • *2) .LABEL «1 

ST .LABEL *2 •• 

IOST - 'EDIT* EXP .STRING 
•OUT(•EOT• *> •)• / 

•PRINT' .OUT I * PNT•I •» 

I0SE01 - .ID .LABEL • .OUTI'BLK 1*1 •• 

IOSEQ • IDSE01 *('•• I0SE01) •• 

DEC • '.REAL* .OUTI•B • *1) IDSEO .LABEL *1 •• 

BLOCK - ••BEGIN* IDEC *••* / .EMPTY) 

ST *(•.»• ST) '.END* .i 

ST - IOST / ASSIGNST / UNTILST / 

CONDITIONALST / BLOCK •• 

PROGRAM - BLOCK .OUTI'HLTO 

•OUT I•SP 1•) .OUT I'END*) .. 


• BEGIN 

.REAL X •• 0 - X .» 

B A01 
X 

BLK 001 

A01 

LOL C 
ST K 

•UNTIL X .« 3 .00 .BEGIN 
A02 

LO X 
LOL 3 

SOU 

BTP A53 

EDIT! X«X * 10 ♦ I. 
LO X 
LO X 
MLT 

LDl 10 
MLT 
LDL 1 
ADO 

EOT 01'*' 
PNT 
LD X 
LDL 0.1 
ADO 
ST X 


0000 G 0012 

0004 

0004 

0012 

0012 A 

0021 B 0004 

0023 

0025 0 CO04 
002* A 
00’£ c 
0029 K 0047 
PR.INT ..X*0.1*X 

00*3 O 00C4 
0047 0 OC r -4 
OOtl Z 
00! c A 
00B1 E 
OC62 A 
0071 C 
0072 I 
00 74 0 
0075 0 0004 
0077 A 
0085 C 
0087 o 0004 

0093 G 0C25 
0097 


OROER LIST OF THE VALGOL 1 MACHINE 
FIGURE 2 


OUTPUT FROM TME VALGOL I PROGRAM GIVEN IN FIGURE 3 
FIGURE 4 


MACHINE COOES 


LDL NUMBER LOAO LITERAL 


ST AAA STORE 


ADO ADD 


SUB SUBTRACT 


MLT MULTIPLY 


EQU EQUAL 


8 AAA BRANCH 

BFP AAA BRANCH FALSE 

AND POP 


BTP AAA BRANCH TRUE 
AND POP 


EOT STRING EDIT 


PUT THE CONTENTS OF THE ADDRESS AAA 
ON TOP OF THE STACK. 

PUT THE GIVEN' NUMBER ON TOP OF 
THE STACK. 

STORE THE NUMBER WHICH IS ON TOP 
OF THE STACK INTO THE AODRESS AA* 
AND POP UP TME STACK. 

REPLACE THE TWO NUMBERS WHICH ARE 
ON TOP OF THE STACK WITH THEIR 
SUM. 

SUBTRACT TME NUMBER WHICH IS ON 
TOP OF THE STACK FROM TME NUMBER 
WHICH IS NEXT TO THE TOP. THEN 
REPLACE THEM By THIS DIFFERENCE. 

REPLACE THE TWO NUMBERS WHICH ARE 
ON TOP OF THE STACK WITH THEIR 
PRODUCT. 

COMPARE THE TWO NUMBERS ON TOP OF 
TME STACK. REPLACE THEM BY THE 
INTEGER 1. IF THEY ARC EQUAL. OR BY 
THE INTEGER 0. IF THEY ARE UNEQUAL. 

BRANCH TO THE ADORESS AAA. 

BRANCH TO THE ADDRESS AAA IF THE 
TOP TERM IN TME STACK IS THE 
INTEGER 0. OTHERWISE. CONTINUE 
IN SEQUENCE. IN EITHER CASE. 

POP UP TME STACK. 

BRANCH TO THE AODRESS AAA IF THE 
TOP TERM IN THE STACK IS NOT THE 
INTEGER 0. OTHERWISE. CONTINUE 
IN SEQUENCE. IN EITHER CASE. 

POP UP THE STACK. 

RO0ND THE NUMBER WHICH IS ON TOP OF 
THE STACK TO THE NEAREST INTEGER N. 
HOVE THE 6IVEN STRING INTO THE 
PRINT AREA SO THAT ITS FIRST CHAR¬ 
ACTER FALLS ON PRINT POSITION N. 

IN CASE THIS WOULO CAUSE CHARACTERS 
TO FALL OUTSIDE THE PRINT AREA. NO 
MOVEMENT TAKES PLACE. 


PRINT A LINE. THEN SPACE AND CLEAR 
THE PRINT AREA. 


HALT HALT. 

CONSTANT ANO CONTROL CODES 


BLK NNN BLOCK 


N - 1—9. CONSTANT COOE PRODUCING 
N BLANK SPACES. 


PROOUCES A BLOCK OF NNN EIGHT 
CHARACTER WORDS. 


DENOTES THE ENO OF THE PROGRAM. 


THE META II COMPILER WRITTEN IN ITS OWN LANGUAGE 
FIGURE 5 


OUT 1 • ••!• .OUTI'GNl'l / »»2* .OUT<*£>N2»J / 

••• .OUT(•Cl*) / .STRING .OUT(*CL • *).. 

OUTPU ' - I•.CUT• 'I* 

* OUT1 •»» / •.LABEL• •OUTI'LB*) 0071! .OUTf'OUT') •• 

EX3 • .ID .OUT ( »CLL» •> / .STRING 

• OUTI • TST • *) / • • ID• .OUTCMD'I ' 

•.NUMBER* .OUT*'NUN') / 

••STRING* .OUTC•SR•1 / •!• EXl •)• / 

••EMPTY* .OUT!'SET*) / 

•*• ..LABEL *1 EX3 

.OUT I'BT • *11 .OUT I'SET•1•. 

EX2 - (EX3 .OUT(•8F • •!» / OUTPUT > 

SCEX3 .OUT(•BE'I ✓ OUTPUT) 

.LABEL *1 •• 

EXl - EX2 SC'/' .OUTI'BT • *1) EX2 I 
•LABEL *1 •• 


ST ■ .ID .LABEL • 
'.»• .OUT I*R•)•• 


PROGRAM - '.SYNTAX' .ID .OUT!'ADR* •) 
S ST '.END* .OUT(•END*I•» 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 




ORDER LIST OF THE META II MACHINE 
FIGURE 6 


MACHINE COOES 

TST STRING TEST AFTER DELETING INITIAL BLANKS IN 

THE INPUT STRING* COMPARE IT TO THE 
STRING GIVEN AS ARGUMENT* IF THE 
COMPARISON IS MET. OELETE THE 
MATCHED PORTION FROM THE INPUT AND 
SET SWITCH. IF NOT MET. RESET 
SWITCH. 


ID IDENTIFIER AFTER DELETING INITIAL BLANKS IN 

THE INPUT STRING. TEST IF IT BEGINS 
WITH AN IDENTIFIER. IE.. A LETTER 
FOLLOWED BY A SEOUENCE OF LETTERS 
AND/OR DIGITS. IF SO. DELETE THE 
IDENTIFIER AND SET SWITCH. IF NOT. 
RESET SWITCH. 

NUM NUMBER AFTER DELETING INITIAL BLANKS IN 

THE INPUT STRING, TEST IF IT BEGINS 
WITH A NUMBER. A NUMBER IS A 
STRING CF DIGITS WHICH MAY CONTAIN 
IM3EDED PERIODS. BUT MAY NOT BEGIN 
OR EnD WITH A PER 100. MOREOVER. NO 
TWO PERIODS MAY BE NEXT TO ONE 
ANG r *ER. IF A NUMBER IS FOUND. 
DELETE IT AND SET SWITCH. IF NOT. 
RESET SWITCH. 

SR STRING AFTER DELETING INITIAL BLANKS IN 

THE INPUT STRING, TEST IF IT BEGINS 
WITH a STRING. IE., A SINGLE OUOTE 
FOulCwED BY A SEOUENCE OF ANY 
CHARACTERS OTHER THAN SINGLE QUOTE 
FOLLOWED BY ANOTHER SINGLE QUOTE. 

! r A s’RInG IS FOUND. DELETE IT AND 
SET Sw!?Cn. IF NOT. RESET SWITCH. 

CLL AAA CALL E*'THE SUBROUTINE BEGINNING IN 

wDCAMGm aAa. if THE TOP TWO TERMS 
OF the STACK ARE BLANK, PUSH THE 
STACK DOWS B" ONE CELL. OTHERWISE. 
PUSH IT down 8y THREE CELLS. SET A 
FLAG IN The stack TO INOICATE 
V"ETHE* IT h-*S BEEN PUSHED BY ONE 
CR ThPEE CELLS. THIS FLAG ANO THE 
EXIT ADDRESS GO INTO THE THIRD 
CELw CLEAR THE TOP TWO CELLS TO 
FLANKS TO INDICATE THAT THEY CAN 
ACCEPT ADDRESSES WHICH MAY BE 
GENERATED WITHIN ThE SUBROUTINE. 


Pigure 6.1 


R RETURN RETURN TO THE EXIT ADDRESS. POPPING 

UP THE STACK BY ONE OR THREE CELLS 
ACCORDING TO THE FLAG. IF THE 
STACK IS POPPED BY ONLY ONE CELL. 
THEN CLEAR THE TOP TWO CELLS TO 
BLANKS. BECAUSE * HeY WERE BLANK 
WHEN THE SUBROUTINE WAS ENTEREO. 

SET SET SET BRANCH SWITCH ON. 

B AAA BRANCH BRANCH UNCONDITIONALLY TO LOCATION 

AAA. 

BT AAA BRANCH IF TRUE BRANCH TO LOCATION AAA IF SWITCH IS 

ON. OTHERWISE. CONTINUE IN SEQ¬ 
UENCE. 

BF AAA BRANCH IF FALSE BRANCH TO LOCATION AAA IF SWITCH 

IS OFF. OTHERWISE. CONTINUE IN 
SEOUENCE. 

BE BRANCH TO ERROR HALT IF SWITCH IS OFF, OTHERWISE. 

IF FALSE CONTINUE IN SEOUENCE. 

CL STRING COPY LITERAL OUTPUT THE VARIABLE LENGTH STRING 

GIVEN AS THE ARGUMENT. A BLANK 
CHARACTER WILL BE INSERTED IN THE 
OUTPUT FOLLOWING THE STRING. 

Cl COPY INPUT OUTPUT THE LAST SEOUENCE OF CHAR¬ 

ACTERS DELETED FROM THE INPUT 
STRING. THIS COMMAND MAY NOT FUNC¬ 
TION PROPERLY IF THE LAST COMMAND 
WHICH COULD CAUSE DELETION FAILED 
TO DO SO. 

GNl GENERATE 1 THIS CONCERNS THE CURRENT LABEL 1 

CELL. IE.. THE NEXT TO TOP CELL IN 
THE STACK. WHICH IS EITHER CLEAR OR 
CONTAINS A GENERATED LABEL. IF 
CLEAR. GENERATE A LABEL AND PUT IT 
INTO THAT CELL. WHETHER THE LABEL 
MAS JUST BEEN PUT INTO THE CELL OR 
WAS ALREADY THERE. OUTPUT IT. 
FINALLY, INSERT A Bt.AMK CHARACTER 
IN THE OUTPUT FOLLOWING THE LABEL. 

GN2 GENERATE 2 SAME AS GNU EXCEPT THAT IT CON¬ 

CERNS THE CURRENT LABEL 2 CELL. 

IE., THE TOP CELL IN THE STACK. 

LB LABEL SET THE OUTPUT COUNTER TO CARO 

COLUMN 1. 

OUT OUTPUT PUNCH CARD AND RESET OUTPUT COUNTER 

TO CARD COLUMN 8. 


Figure 6.2 


CONSTANT AND CONTROL CODES 

ADR IDENT ADDRESS PROOUCES THE ADDRESS WHICH IS 

ASSIGNED TO THE GIVEN IDENTIFIER AS 
A CONSTANT. 

END END DENOTES THE ENO OF THE PROGRAM. 


Figure 6.3 


VALGOL II COMPILER WRITTEN IN META II 
FIGURE 7 


•SYNTAX PROGRAM 

ARRAYPART - •(.' EXP •#»• .OUT('AIA') •• 

CALLPART - • « • .OUT ( ' IDF • ) IEXP »('.' EXP) / 

•Emptyi .outmcll') •• 

VARIABLE • .ID .OUTI'LO • *) I ARRAYPART / .EMPTY! «• 

PRIMARY - ‘WHOLE' •!» EXP •)» .OUTt'WHL'l / 

•ID .OUT(•LO • •) (ARRAYPART / CALLPART / -EMPTY) / 
'.TRUE* .OUT1 1 SET•) / '.FALSE' .OUTI'RSTM / 

•0 • .OUT(•RST•I / *1 ' .OUT('SET') / 

•NUMBER .OUTI'LDL* *) / 

•I* EXP •)• .» 

TERM • PRIMARY * I'*' PRIMARY .OUTI'MLT't / 

•/• PRIMARY .OUTI•DIV•) / 

'•/.' PRIMARY .OUT('DIV') .OUT('WHL') ) •* 

EXP2 - •-• TERM .OUTI'NEG'I / 

TERM / TERM .. 

EXP1 - EXP2 *!•♦' TERM .OUT('ADD') / 

TERM .OUT(•SUB•11 •• 

RELATION ■ EXP 1 I 

•.L»* EXPl .OUT I'LEO•) / 

'.L' EXP 1 .OUT('LES') / 

EXPl .OUT('EQU') t 
EXPl .OUT('EOU') .OUT('NOT•) t 
'.G-* EXPl .OUT('LES') .OUT('NOT') / 

•.G* EXPl .OUT!'LEO') .OUTI'NOT'I / 

•EMPTY) .. 

BPR1MARY - ••-' RELATION .OUT('NOT') / 

RELATION •• 

STERN • BPRIMARY S <••„' .OUTI'BF • *1) 

.OUT('POP') BPRIMARY) 

•LABEL *1 «• 

BEXPl - BTERM At '.V' .OUTCBT • *11 
•OUT(•POP•) BTERM) 

•LABEL *1 •• 

IMPLICATION! ■ '.IMP' .OUT('NOT') 

• OUT I • BT • Ml .OUTt'POP') 

BEXPl .LABEL M .. 

IMPLICATION - BEXPl % IMPLICATION! •• 


Figure 7.1 


EOUlV - IMPLICATION tC.EO' .OUT('EOU') ) •* 

EXP - '.IF* EXP '.THEN* .OOTI'BFP' *1) 

EXP .OUTl'B • *2) .LABEL *1 
'.ELSE* EXP .LABEL "2 ✓ 

EOUIV .• 

ASSIGNPART • '•' EXP I ASSIGNPART .OUT!'ST*I / 

•EMPTY .OUTI'SST') ) .. 

ASSIGNCALLST • .10 .OUTCLD • •) (ARRAYPART ASSIGNPART / 
ASSIGNPART / (CALLPART / .EMPTY 
• OUTOLDF'I .OUT!'CLL* ) I 
•OUT('POP') ) •» 

UNTILST • '.UNTIL* .LABEL M EXP 
'.DO* .OUTI'BTP' Ml ST 
•OUT('B ' *1) .LABEL *2 •• 

WMILECLAUSE « '.WHILE' .OUT (• BF ' M) 

.OUT('POP') EXP .LABEL »1 / .EMPTY •• 

FORCLAUSE • VARIABLE '•« .OUTI'FLP'I 
•OUT('BFP* *1) EXP '.STEP' 

•OUT(•SST•) .OUTl'B • *2) 

•LABEL M EXP '.UNTIL' .OUT('AOS') 

•LABEL "2 .OUTI•RSR') EXP 
•OUT('LEQ') WHILCCLAUSE '.DO* •• 

FORST • '.FOR* .OUT!'SET') .LABEL M 
FORCLAUSE .OUTC'BFP' *2) ST 
•OUT!'RST') .OUTl'B • •!) 

•LABEL M •• 

IOCALL • 'READ' VARIABLE '.' EXP •)• .OUT('REO') / 

•WRITE' VARIABLE EXP •»« .OUT('WRT') / 

•EDIT' •I' EXP ••' .STRING 

•Out i• edt' m •)• / 

•PRINT' .OUTCPNT'I ✓ 

'EJECT* .OUTI'EJT'I •• 


Number 44 

148 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 23 




IOSEQI . .ID .LABEL* .OUTC'BLK 1»> •• 

IDSEQ • IOSEQI •(••• IOSEQI) •• 

TYPEDEC - *.REAL* IDSEQ .. 

APRAYl • .10 .LABEL * •(.• 'O' •••* .HUMBER 
•OUTCBL^ l') .OUTI 'BLK' *> •• 

ARRAYOEC - • .ARRAY* ARRAY 1 S( •*' ARRAY1) •• 

PROCEDURE - ‘.PROCEDURE* .10 .LABEL * 

•LABEL *1 .OUTC'BLK 1') 'I' 

< IDSEQ / .EMPTY) *»• .OUTCSP l'l 
ST .OUTI»R • *1) •* 

^lgUTB 7*2 


OEC • TYPEDEC / ARRAYOEC / PROCEDURE .« 

BLOCK - '.BEGIN* .OUT(*8 • *1) StOEC '..') 

.LABEL *1 it SC.*' STJ *.END' 

(•ID / .EMPTY) •• 

UNCONOITIONALST • IOCALL / ASSIGNCAU-ST / 
BLOCK .. 

CONDST - '.IF* f.XP '.THEN* .OUTCBFP* *1) 

(UNCOHO!TIOHALST C.CLSS' .OUT('3 ' *2) 

• LABEL *1 ST «LABEL S .EMPTY 

• LABEL *i) / < C 0R$7 ,• UNTiLST) 

•LABEL *1) .» 

ST - CONCST / UHCOMOITIOHALST / FO«ST / 

UNI I LSI / ■uMPTV .. 

program - block 

• OUT ( 'MLT * ) .OUTCSP 1') .OUT C END') . v 


Figure 7.3 


ORDER LIST OF THE VALGOL II MACHINE 
FIGURE S 


MACHINE CODES 

L D AAA LOAD PUT THE ADORESS AAA OH TOP OF THE 

STACK. 

LDL HUMBER LOAD LITERAL PUT THE GIVEN HUMBER OH TOP OF 

THE STACK. 

SET SET PUT THE IHTEGER 1 ON TOP OF THE 

STACK. 

RST RESET PUT THE INTEGER 0 OH TOP OF THE 

STACK. 

ST STORE STORE THE CONTENTS OF THE REGISTER. 

STACKl. IN THE ADORESS WHICH IS OH 
TOP OF THE STACK. THEN POP UP THE 
STACK. 

ADD THE HUMBER OH TOP OF THE STACK 
TO THE HUMBER WHOSE ADORESS IS NEXT 
TO THE TOP. AND PLACE THE SUM IN 
THE REGISTER. STACKl. THEN STORE 
THE CONTENTS Or THAT REGISTER IN 
THAT ADORESS. AND POP THE TOP TWO 
ITEMS OUT OF THE STACK. 

PUT THE HUMBER OH TOP OF THE STACK 
INTO THE REGISTER. STACKl. THEN 
STORE THE CONTENTS OF THAT REGISTER 
IN THE ADORESS WHICH IS THE NEXT 
TO TOP TERM OF THE STACK. THE TOP 
TWO ITEMS ARE POPPED OUT OF THE 
STACK. 

RSR RESTORE PUT THE CONTENTS OF THE REGISTER. 

STACKl. OH TOP OF THE STACK. 

ADD ADO REPLACE THE TWO NUMBERS WHICH ARE 

NOTE 2 OH TOP OF THE STACK WITH THEIR 

SUM. 

SUB SUBTRACT SUBTRACT THE HUMBER WHICH IS OH 

NOTE 2 TOP OF THE STACK FROM THE HUMBER 

WHICH IS NEXT TO THE TOP. THEN 
REPLACE THEM BY THIS DIFFERENCE. 

MLT MULTIPLY REPLACE THE TWO NUMBERS WHICH ARE 

NOTE 2 ON TOP OF THE STACK WITH THEIR 

PRODUCT. 

DIV DIVIDE DIVIDE THE NUMBER WHICH IS NEXT TO 

NOTE 2 THE TOP OF THE STACK BY THE NUMBER 

WHICH IS ON TOP OF THE STACK. THEN 
REPLACE THEM BY THIS OUOTIENT. 

Figure 8.1 


ADS ADO TO STORAGE 

NOTE 1 


SST SAVE ANO STORE 

NOTE 1 


NEG 

WHL 


NEGATE CHANGE THE SIGN OF THE NUMBER ON 

NOTE 1 TOP OF THE STACK. 

WHOLE TRUNCATE THE NUMBER WHICH IS ON 

TOP OF THE STACK. 

NOT IF THE TOP TERM IN THE STACK IS THE 

INTEGER 0. THEN REPLACE IT WITH THE 
INTEGER 1. OTHERWISE. REPLACE IT 
WITH THE INTEGER 0. 

LESS THAN OR EQUAL IF THE NUMBER WHICH IS NEXT TO 

NOTE 2 THE TOP OF THE STACK IS LESS THAN 

OR EQUAL TO THE HUMBER ON TOP OF 
THE STACK. THEN REPLACE THEM WITH 
THE INTEGER l. OTHERWISE. REPLACE 
THEM WITH THE INTEGER 0. 


LESS THAN 
NOTE 2 


EQU EQUAL 

NOTE 2 


B AAA BRANCH 

BT AAA BRANCH TRUE 


BF AAa -DRaMCM FALSE 


BTP AAA BRANCH TRUE 
AND POP 


BFP AAA BRANCH FALSE 
AND POP 


EOT STRING EDIT 

NOTE l 


PNT 

EJT 

RED 


PRINT 

EJECT 

READ 


IF THE NUMBER WHICH IS NEXT TO 
THE TOP OF THE STACK IS LESS THAN 
THE NUMBER ON TOP OF THE STACK. 

THEN REPLACE THEM WITH THE 
INTEGER 1. OTHERWISE. REPLACE THEM 
WITH THE INTEGER U. 


COMPARE THE TWO NUMBERS ON TOP OF 
THE STACK. REPLACE THEM BY THE 
INTEGER 1. IF THEY ARE EOuAl. OR By 
THE INTEGER 0. IF THEY ARE UNEQUAL. 

BRANCH TO THE ADORESS AAA. 

BRANCH TO THE ADDRESS AAA IF THE 
TOP TERM IN THE STACK IS NOT THE 
INTEGER G. OTHERWISE. CONTINUE 
IN SEQUENCE. 00 NOT POP UP THE 
STACK, 

BRANCH TO THE ADDRESS AAA IF THE 
TOP TERM IN THE STACK IS THE 
iN EGcr! 0. OTHERWISE. CONTINUE 
IN SEQUENCE. DO NOT POP UP THE 

1 :ACK* 

ESANCH TO Th£ ADDRESS AAA IF THE 
TOP TERM IN THE STACK IS NOT THE 
INTEGER 0. OTHERWISE. CONTINUE 
IN SEQUENCE. IN EITHER CASE. POP 
UP Tn£ ST'.CK. 

60ANCW TO THE ADDRESS AAA IF THE 
TOO TERM IN TH= STACK IS THE 
INTEGER 0. OTHERWISE. CONTINUE 
IN SEQUENCE• IN EITHER CASE* 

POP UP THE STACK. 


ARRAY INCREMENT 
ADORESS 


Figure 8.2 


ENTER A PROCEOURE AT THE ADORESS 
WHICH IS BELOW THE FLAG. 

PUT THE ADDRESS WHICH IS IN THE 
FLAG REGISTER ON TOP OF THE STACK. 
ANO PUT THE ADORESS OF THE TOP OF 
THE STACK INTO THE FLAG REGISTER. 

RETURN FROM PROCEDURE. 

INCREMENT THE ADDRESS WHICH IS NEXT 
TO THE TOP OF THE STACK BY THE 
INTEGER WHICH IS ON TOP OF THE 
STACK, AND REPLACE THESE BY THE 
RESULTING ADORESS. 

INTERCHANGE THE TOP TWO TERMS OF 
THE STACK. 

POP UP THE STACK. 

ROUND THE NUMBER WHICH IS ON TOP OF 
THE STACK To THE NEAREST INTEGER N. 
MOVE THE GIVEN STRING INTO THE 
PRINT AREA SO THAT ITS FIRST CHAR¬ 
ACTER FALLS ON PRINT POSITION N. 

IN CASE THIS WOULD CAUSE CHARACTERS 
TO FALL OUTSIDE THE PRINT AREA. NO 
MOVEMENT TAKES PLACE. 

PRINT A LINE. THEN SPACE AND CLEAR 
THE PRINT AREA. 

POSITION THE PAPER IN THE PRINTER 
TO THE TOP LINE OF THE NEXT PAGE. 

READ THE FIRST N NUMBERS FROM A 
CARD AND STORE THEM BEGINNING IN 
THE ADDRESS WHICH IS NEXT TO 
THE TOP OF THE STACK. THE INTEGER 
N IS THE TOP TERM OF THE STACK. 

POP OUT BOTH THE ADORESS ANO THE 
INTEGER. CAROS ARE PUNCHED WITH UP 
TO 10 EIGHT DIGIT NUMBERS. DECIMAL 
POINT IS ASSUMED To BE IN THE 
MIDDLE. AN 11-PUNCH OVER THE 
RIGHTMOST DIGIT INDICATES A NEG¬ 
ATIVE NUMBER. 


Pigure 8.3 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

149 





EXAMPLE PROGRAM IN VALGOL II 
FIGURE 9 


WRT WRITE PRINT A LINE OF N NUMBERS BEGINNING 

IN THE AOORESS WHICH IS NEXT 10 
THE TOP OF THE STACK. THE INTEGER 
N IS THE TOP TERM OF THE STACK. 

POP OUT BOTH THE ADDRESS AND THE 
INTEGER. TWELVE CHARACTER POSI¬ 
TIONS are allowed for each number. 

THERE ARE FOUR DIGITS BEFORE AND 
FOUR DIGITS AFTER THE 0EC1MAL. 
LEADING ZEROES IN FRONT OF THE 
DECIMAL ARE CHANGED TO BLANKS. 

IF THE NUMBER IS NEGATIVE. A MINUS 
SIGN IS PRINTED IN THE POSITION 
BEFORE THE FIRST NON-BLANK CHARACT¬ 
ER. 

MLT HALT HALT. 


SP N 

BLK NNN 

END 


CONSTANT AND CONTROL CODES 

SPACE H • 1—9. CONSTANT CODE PRODUCING 

N BLANK SPACES. 

BLOCK PRODUCES A BLOCK OF NNN EIGHT 

CHARACTER WORDS. 

END DENOTES THE ENO OF THE PROGRAM. 


NOTE 1. IF THE TOP ITEM IN THE STACK IS AN ADDRESS. IT IS 
REPLACED BY ITS CONTENTS BEFORE BEGINNING THIS 
OPERATION. 

NOTE 2. SAME AS NOTE 1. BUT APPLIES TO THE TOP TWO ITEMS. 


Figure 8.4 


•BEGIN 

• PROCEDURE DETERMINANT I A. N) .. 

•8EGIN 

•PROCEDURE DUMPi) .» 

•BEGIN 
•REAL D •• 

•FOR D - 0 .STEP 1 .UNTIL N-l .DO 
WRITEIPATRIXI• N*D N) •• 

PRINT 

•END DUMP .• 

.PROCEDURE ABS(X) •• 

ABS - .IF 0 .L- X .THEN X .ELSE -X •• 

•REAL PRODUCT. FACTOR. TEMP. R, I. J •» 

PROOUCT - l .♦ 

•FOR R - 0 .STEP 1 .UNTIL N-2 

• WHILE PRODUCT .— 0 .DO .BEGIN 

I - R .. 

•FOR J • R»1 .STEP 1 .UNTIL N-l .DO 
• IF ABSC AI• N*I ♦ R .1 ) .L 
ABS( A|. N•J ♦ R •I | .THEN 
I - J •» 

•IF AC. N*I ♦ R .1 .- 0 .THEN 
PRODUCT • 0 

• ELSE 

•IF I R .THEN .BEGIN 

PRODUCT - -PRODUCT •• 

•FOR J • R .STEP 1 .UNTIL N-l .DO 
•BEGIN 

TEMP ■ AC. N*R ♦ J •) .. 

AC. N*R ♦ J .1 ■ AC. N* 1 + J •! • 
AC. N*I ♦ J - TEMP .END .ENO •• 
TEMP • AC. N*R ♦ R .1 •• 

.FOR I ■ RM .STEP 1 .UNTIL N-l .DO 
•BEGIN 

FACTOR • AC. N* I ♦ R .) / TEMP .. 

•FOR J • R .STEP 1 .UNTIL N-l .DO 

AC. N*I ♦ J •I ■ AC. N*I ♦ J •) 
-FACTOR • AC. N*R ♦ J .1 .. 

DUMP 

•END .END .. 

•FOR I - 0 .STEP 1 .UNTIL N-l .00 

PROOUCT • PRODUCT • AC. N*I ♦ I •) .. 

DETERMINANT « PRODUCT 

• ENl- DETERMINANT .. 

•REAL M. W. T .» .ARRAY MATRIX C. 0 •• 24 .) M 
•UNTIL .FALSE .DO .BEGIN 

EDI TCI. 'FIND DETERMINANT OF' I .» PRINT.. PRINT.. 
REAO'M. II .» 

•FOR W * 0 .STEP 1 .UNTIL H-l .00 .BEGIN 
READC MA CRIX C. M*w •)• Mi .. 

WRITECMATRIX I. M*W •). Ml .END •• 

PRINT •• T ■ DETERMINANT. CMATRIX. Ml •• 

WRITECT. II .. PRINT.. PRINT .ENO 
•END PROGRAM 



Number 44 

150 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 25 



| A Northstar BASIC 
L_Cross-Reference Tool 


BY TITUS PURDIN 

5901 JFK # 101 

N. Little Rock, Arkansas 72116 


In the course of two years of micro computing, I cannot 
count the number of times friends and acquaintances have 
offered me copies of programs they have written, only to be 
disappointed because their BASIC and my BASIC were so 
vastly different. In many cases, when the offered programs 
were just too good to pass up, I have locked myself in the 
study for an evening and made the necessary conversions. It 
isn’t a job that I relish. And while I haven’t found an easy way 
to accomplish it, I have developed, over time, some tools to 
ease the burden. 

This particular program accepts programs in BASIC on 
Northstar disks and compiles cross-reference lists for all varia¬ 
bles, string variables, array variables, and line numbers. I have 
found this to be a valuable assist when converting programs 
from one BASIC to another and when compacting a program 
by placing multiple statements on a single line. Additionally, 
I have discovered that such lists, annotated with the purpose 
of each variable, are excellent pieces of documentation. 

This program is written in 8080 assembly language and 
requires 13.4K of RAM to accommodate the program and the 
table space. The program itself requires 1.64K, and 12K is 
allocated for space in which to build the cross-reference 
tables. This latter space is more than sufficient for the largest 
programs I have. It could be reduced if necessary to save space 
by changing the allocation in line 5090 and changing the byte 
against which the high order byte of the address is compared 
at line 0945 to agree with the space allocated. 

The program is designed to run at 2A00H and use the I/O 
and disk drivers currently in your Northstar DOS. References 
to these drivers are contained in the EQU vectors at the 
opening of the assembly language listing for ease in changing 
them if your drivers or your COS are not standard. 

The program creates four separate lists: 

1. Variables 

2. String variables 

3. Array variables 

4. Line # references 


Each of these are supported as linear linked lists in alphabetic 
soft order. The storage areas SYTOP, STTOP, ARTOP, and 
NMTOP are the top pointers for these four lists, and the 
marker BBH is used to mark the end of each of these lists. 


SYTOP 

STTOP 

ARTOP 

NMTOP 

1 I 

1 1 

1 1 

1 1 

T 

T 


T 

list of 

list of 

list of 

list of line 

variables 

string 

variables 

array 

variables 

#references 


Each entry in each of the four lists has an accompanying 
top pointer for its associated list of line numbers. The mark 
CCH is used to mark the end of each line number list. A typi¬ 
cal variable item looks like this: 



variable — stored LO/HI — for 
example the variable A1 would be 
stored 3141H 

link to next variable in this list in 
alphabetic order - stored in typi¬ 
cal LO/HI address format - will 
be BBH for last item 

ignored — 2 bytes 

top pointer to list of line numbers 
associated with this particular 
variable 


The list of line numbers associated with each variable in 
each list is constructed in a similar, but simpler, fashion: 



line number in which variable was 
referenced — stored LO/HI 

link to next line number in this 
list - stored LO/HI — will be 
CCH for last item in the list 


Pacie 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

151 



The entire program is read from the disk, one 256 byte 
block at a time, and scanned for the purpose of constructing 
these lists. When this is completed, the lists are followed in 
order from beginning to end and the stored variables and line 
numbers are formated and printed to produce the cross- 
reference lists. Each list is printed with its own header, i.e. 
STRING VARIABLES. And the entry NULL LIST is printed 
for any list that is empty. 

The diagram below represents the multi-list structure in 
somewhat stylized fashion: 


SYTOP STTOP ARTOP NMTOP 



The variables which were found in the program are stored 
in ASCII in the appropriate list so their conversion for printing 
is straightforward. The line numbers that are placed in the 
lists, however, are stored as two byte LO/HI binary values. 
The algorithm used to convert these to ASCII for printing is 
fairly simple, if somewhat bulky. Taking the binary value as 
an ordered 16 bit field, the program uses a 5 byte work area 
to construct the resulting decimal number. A table is provided 
(BASE:) which represents, as 5 single digits, the decimal num¬ 
ber associated with each bit position of the 16 bit binary 
value. If a bit in the binary value is “on,” then the five digits 
associated with that bit position are added to the five byte 
work area along with any necessary “carry’s” from byte to 
byte. If, on the other hand, a bit in the binary value is “off,” 
then the pointer into the table (BASE:) is bumped down 5 to 
point to the next series of 5 values. When this process is 
complete, 30H is added to each byte of the 5 byte work area 
to yield the desired ASCII value. 

This program has proven useful in its own right. But it is 
worth mentioning that a modification of this same idea, 
directed solely at line number references, would be the basis 
for a program which would “compact” BASIC programs by 
removing unnecessary line numbers. Similarly, this sort of 
cross-reference compilation would form the basis of “pass 
one” of more sophisticated software such as a compiler. 
A compiler! Now there’s an idea. 


Listing 




0005 

; 

THIS PROGRAM PROVIDES SOFTWARE SUPPORT FOR 



0010 

; 

PROGRAMS WRITTEN IN NORTHSTAR BASIC. IT COMPILES 



0015 

; 

AND PRINTS 

FOUR LISTS* 1)A LIST OF VARIABLE NAMto 



0020 

; 

USED AND LINES IN WHICH EACH OF THEM OCCURS* 2)h 



002S 

; 

LIST OF STRING VARIABLE NAMES USED AND LINES IN 



0030 

j 

WHICH EACH 

OCCURS. 3)A LIST OF ARRAY VARIABLE 



0035 

; 

NAMES AND LINES IN WHICH EACH OCCURS* AND 4) A 



0040 

; 

LIST OF LINE NUMBERS REFERENCED IN GOTO AND GOSUo 



0045 

; 

STATEMENTS 

AND LINE NUMBERS IN WHICH THEY ARE 



0050 

; 

REFERENCED 




0055 

; 



2A00 


0060 


ORG 

2A00H 

2A00 

214233 

0065 


LXI 

H* STACK*49 

2A03 

F9 

0070 


SPHL 


2010 


0075 

ClN s EQU 

2010H 

200C 


0080 

COUTt EQU 

200DH 

20 1C 


0085 

DIRCK* EQU 

20 1CH 

2022 


0090 

RDCSKi EQU 

2022H 

2028 


0095 

EXITi EQU 

2028H 



0100 

i 





0105 

; 

PRINT HEADER 



0 1 10 

; 



2A04 

0E1F 

0115 

START* MV1 

C* 31 

2A06 

218730 

0120 


LXI 

H* HDR 1 

2A09 

CD5E30 

0125 


CALL 

PRINT 

2A0C 

CD6830 

0 130 


CALL 

CRLF 



0 135 

; 





0 140 

; 

PRINT FILE 

NAME PROMPT 



0045 

; 



2A0F 

0EI 1 

0150 

ASKFLs MVI 

C* 17 

2A11 

21A630 

0155 


LXI 

H*HDR2 

2A14 

CD5E30 

0 160 


CALL 

PRINT 

2A17 

0E0A 

0165 


MVI 

C* 10 

2A19 

218731 

0170 


LXI 

H* PNAME 



0175 






0180 

; 

BLANK PROGRAM NAME AREA 



0 185 

; 



2A1C 

3620 

0190 

BLNAM* MVI 

M* 20H 

2A1E 

23 

0195 


I NX 

H 

2A1F 

0D 

0200 


DCR 

C 

2A20 

C21C2A 

0205 


JNZ 

BLNAM 

2A23 

0E09 

0210 


MVI 

C* 9 

2A25 

218731 

0215 


LXI 

H* PNAME 



0220 

; 





0225 

; 

ACCEPTS FILE NAME. USES REG C AS COUNTER AND 



0230 

; 

ACCEPTS UP 

TO 8 CHARACTERS. TAKES CARE OF 



0235 

; 

BLANKING CHAR IN RESPONSE TO BACKSPACE <5FH). 



0240 

; 

ROUTINE TERMINATES WHEN CR <0DH) IS ENCOUNTERED. 



0245 

; 



2A28 

CD1020 

0250 

1NF1L * CALL 

CIN 

2A2B 

32B232 

0255 


STA 

HOLDT 

2A2E 

FE0D 

0260 


CPI 

0DH 

2A30 

CA6F2A 

0265 


JZ 

INUNT 

2A33 

FE5F 

0270 


CPI 

5FH 

2A35 

C2542A 

0275 


JNZ 

STORE 

2A38 

3E09 

0280 


MVI 

A* 9 

2A3A 

B9 

0285 


CMP 

C 

2A3B 

CA282A 

0290 


JZ 

INFIL 

2A3E 

3AB232 

0295 


LDA 

HOLDT 

2A41 

2B 

0300 


DCX 

H 

2A42 

0C 

0305 


INR 

C 

2A43 

47 

0310 


MOV 

B* A 

2A44 

CD0D20 

0315 


CALL 

COUT 

2A47 

0620 

0320 


MVI 

B* 20H 

2A49 

CD0D20 

0325 


CALL 

COUT 

2A4C 

065F 

0330 


MVI 

B* 5FH 

2A4E 

CD0D20 

0335 


CALL 

COUT 

2A51 

C3282A 

0340 


JMP 

INFIL 



0345 

; 





0350 

1 

PLACES CHARACTERS FROM INFIL* SEQUENTIALLY 



0355 

; 

INTO AREA CALLED 'PNAME' TO BUILD INPUT 



0360 

; 

FILE NAME. 

PRINTS'’NAME'TOO LONG* ERROR 



0365 

; 

IF 8 CHARACTERS ARE EXCEEDED. 



0370 

; 



2A54 

77 

0375 

STORE* MOV 

M* A 

2A55 

47 

0380 


MOV 

B* A 

2A56 

CD0D20 

0365 


CALL 

COUT 

2A59 

23 

0390 


1NX 

H 

2A5A 

0D 

0395 


DCR 

C 

2A5B 

C2282A 

0400 


JNZ 

INFIL 

2A5E 

CD6830 

0405 


CALL 

CRLF 

2A6 1 

0E10 

0410 


MVI 

C* 16 

2A63 

211031 

0415 


LXI 

H*HDR7 

2A66 

CD5E30 

0420 


CALL 

PRINT 

2A69 

CD6830 

0425 


CALL 

CRLF 

2A6C 

C30F2A 

0430 


JMP 

ASKFL 



0435 

; 





0440 

; 

ACCEPTS DISK UNIT NUMBER. CHECKS TO MAKE 



0445 

; 

SURE INPUT 

IS ASCII 1* 2* OR 3. 



0450 

; 



2A6F 

0E0C 

0455 

INUNT* MVI 

C* 12 

2A7 1 

21B730 

0460 


LXI 

H*HDR3 

2A7 4 

CD6830 

0465 


CALL 

CRLF 

2A77 

CD5E30 

0470 


CALL 

PRINT 

2A7A 

219131 

0475 


LXI 

H*DRIVE 

2A7D 

CD1020 

0480 


CALL 

CIN 

2A80 

47 

0485 


MOV 

B* A 

2A8 1 

CD0D20 

0490 


CALL 

COUT 

2A84 

FE31 

0495 


CPI 

31H 

2A86 

CAA42A 

0500 


JZ 

GETCR 

2A89 

FE32 

0505 


CPI 

32H 

2A8B 

CAA42A 

0510 


JZ 

GETCR 

2A8E 

FE33 

0515 


CPI 

33H 

2A90 

CAA42A 

0520 


JZ 

GETCR 



0525 

; 




Number 44 

152 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 27 






0530 

; 

PRINTS ’INVALID UNIT’ ERROR IF INPUT fl 

U 2B40 AF 

1085 

NEVLN: XRA 

A 




0535 

; 

IS NOT EQUAL TO ASCII 1j 2, OR 3. ( 

J 2B41 329732 

1090 

STA 

MARK 




0540 

; 


r 

) 2B44 3C 

1095 

INR 

A 


2A9 3 

CD6830 

0545 

ERUNTs CALL 

CRLF J 

) 2B45 EB 

1100 

XCHG 



2A96 

0E0C 

0550 


MVI 

C, 12 ( 

) 2B46 BE 

1 105 

CMP 

M 


2A96 

212031 

0555 


LX I 

H.HDR8 ( 

1 2B47 CABC2D 

1 1 10 

JZ 

FRTRN 


2A9B 

CD5E30 

0560 


CALL 

PRINT j 

j 2B4A EB 

1115 

XCHG 



2A9E 

CD6830 

0565 


CALL 

CRLF j 

) 2B4B CD7330 

1 120 

CALL 

NXTCR 


2AA1 

C36F2A 

0570 


JMP 

INUNT ) 

J 2B4E 1A 

1 125 

LDAX 

D 




0575 




J 2B4F 32A232 

1130 

STA 

LOLIN 




0580 


TRIMS ASCII INPUT UNIT # TO BINARY VALUE ( 

j 2B52 CD7330 

1135 

CALL 

NXTCR 




0585 


AND STORES 

IT IN AREA CALLED ’DRIVE’. ACCEPTS ft 

J 2B55 1A 

1 140 

LDAX 

D 




0590 


CR TO CONTINUE. ANY OTHER INPOT CAUSES ft 

J 2B56 32A332 

1 145 

STA 

HIL1N 




0595 


’INVALID UNIT’ ERROR. PUTS ADDRESS OF PROGRAM ( 

) 2B59 AF 

1150 

XRA 

A 




0600 


NAME IN REG H7L AND VALUE OF DRIVE t IN REG ft 

) 2B5A 32A132 

1 155 

STA 

LNTAB 




0605 


A. CALLS DOS DIRECTORY LOOKUP ROUTINE ) 

) 2B5D CD7330 

1160 

CALL 

NXTCR 




0610 


AT 201CH. 

IF CARRY BIT IS SET ON RETURN ft 

j 2B60 62 

1165 

NEVL1: MOV 

H. D 




0615 


•NO PROGRAM’ ERROR IS PRINTED. ft 

\ 2B61 6B 

1170 

MOV 

Lj E 




0620 



} 

) 2B62 3E20 

1175 

MVI 

Aj 20H 


2AA4 

E60F 

0625 

GETCRt AN1 

0FH ) 

j 2B64 BE 

1 180 

CMP 

M 


2AA6 

77 

0630 


MOV 

Mj A ) 

\ 2B65 CAB62B 

1 185 

JZ 

NEVL6 


2AA7 

CD 1020 

0635 


CALL 

CIN ) 

( 2B68 3E8F 

1 190 

MVI 

Aj 8FH 


2AAA 

47 

0640 


MOV 

Bj A / 

j 2B6A BE 

1 195 

CMP 

M 


2AAB 

CD0D20 

0645 


CALL 

COUT ( 

) 2B6B C2732B 

1200 

JNZ 

NEVL2 


2AAE 

FE0D 

0650 


CPI 

0DH ) 

j 2B6E 3E01 

1205 

MVI 

Aj 1 


2ABB 

C2932A 

0655 


JNZ 

ERUNT ( 

j 2B70 329732 

1210 

STA 

MARK 


2AB3 

0 60A 

0660 


MVI 

Bj 0 AH ( 

) 2B73 3E22 

1215 

NEVL2: MVI 

Aj 22H 


2AB5 

CD0D20 

0665 


CALL 

COUT 

( 2B75 BE 

1220 

CMP 

M 


2AB8 

3A9131 

0670 


LDA 

DRIVE 

( 2B76 C2902B 

1225 

JNZ 

NEVL4 


2ABB 

218731 

0675 


LX I 

HjPNAME 

j 2B79 3A9732 

1230 

LDA 

MARK 


2ABE 

37 

0680 


STC 

|j 

2B7C FE02 

1235 

CPI 

02H 


2ABF 

3F 

0685 


CMC 

j 

2B7E C2882B 

124e 

JNZ 

NEVL3 


2AC0 

CD1C20 

0690 


CALL 

D1RCK ( 

2B81 AF 

1245 

XRA 

A 


2AC3 

D2D42A 

0695 


JNC 

CKTYP 

2B82 329732 

1250 

STA 

MARK 


2 AC 6 

0E19 

0700 


MVI 

Cj 25 <i 

2B85 C3B62B 

1255 

JMP 

NEVL6 


2AC8 

21C330 

0705 


LX I 

H.HDR4 

2B86 3E02 

1260 

NEVL3: MVI 

Aj 2 


2ACB 

CD5E30 

0710 


CALL 

PRINT 

2B8A 329732 

1265 

STA 

MARK 


2ACE 

CD6830 

0715 


CALL 

CRLF <1 

2B8D C3B62B 

1270 

JMP 

NEVL6 


2AD1 

C30F2A 

0720 


JMP 

ASKFL 

2B90 3A9732 

1275 

NEVL4: LDA 

MARK 




0725 

; 


| 

2B93 FE00 

1280 

CPI 

0H 




0730 

; 

CHECKS FILE TYPE TO INSURE IT IS TYPE 2. ft 

2B95 C2B62B 

1285 

JNZ 

NEVL6 




0735 

; 


|| 

2B98 3E9A 

1290 

MVI 

Aj 9AH 


2AD4 

3600 

0740 

CKTYPl MVI 

B, 0 

2B9A BE 

1295 

CMP 

M 


2AD6 

2 E04 

0745 


MVI 

Cj 4 

2B9B C2A42B 

1300 

JNZ 

NEVL5 


2AD8 

09 

0750 


DAD 

B 

2B9E CDC82B 

1305 

CALL 

STNUM 


2AD9 

3E02 

0755 


MVI 

A. 2 

2BA1 C3B62B 

1310 

JMP 

NEVL6 


2ADB 

BE 

0760 


CMP 

M 

2BA4 3E40 

1215 

NEVL5: MVI 

Aj 40H 


2ADC 

CAED2A 

0765 


JZ 

STADD 

2BA6 BE 

1320 

CMP 

M 


2ADF 

I3E1 2 

0770 


MVI 

Cj 18 

2BA7 D2B62B 

1325 

JNC 

NEVL6 


2AE1 

21DC30 

0775 


LX I 

HjHDRS 

2BAA 3E5A 

1330 

MVI 

Aj 5 AH 


2AE4 

CD5E30 

0780 


CALL 

PRINT 

2BAC BE 

1335 

CMP 

M 


2AE7 

CD6830 

0785 


CALL 

CRLF 

2BAD DAB62B 

1340 

JC 

NLWL6 


2AEA 

C30F2A 

0790 


JMP 

ASKFL 

2BB0 CDEA2E 

1345 

CALL 

GETSY 




0795 

I 



2BB3 C3B92B 

1350 

JMP 

NEVL7 




0800 

l 

STORES DATA FROM DISK DIRECTORY FOR THE FILE 

2BB6 CD7330 

1355 

NEVL6: CALL 

NXTCR 




0805 

l 

IN AREA CALLED ’DIR*. | 

2BB9 3E0D 

1360 

NEVL7: MVI 

Aj0DH 




08 10 

l 



2BBB 21A 132 

1365 

LXI 

HjLNTAB 


2 AEL 

2B 

08 15 

STADDi DCX 

H ( 

2BBE BE 

1370 

CMP 

M 


2AEE 

2B 

0820 


DCX 

H ( 

2BBF C2602B 

1375 

JNZ 

NEVL1 


2AEF 

2B 

0825 


DCX 

H ( 

2BC2 CD7330 

1380 

CALL 

NXTCR 


2AF0 

2B 

0830 


DCX 

H ( 

2BC5 C3402B 

1385 

JMP 

NEVLN 


2AF 1 

OE08 

0835 


MVI 

Cj 8 


1390 

; 



2AF 3 

110933 

0840 


LXI 

D. DIR ( 


139 5 

; EXTRACTS A 

LINE NUMBER 

REFERENCE 

2AF 6 

7E 

0845 

STADli MOV 

AjM | 

J 

1400 

; AND PLACES 

IT IN ’VALHI 

’ AND ’VALLO 

^F7 

.2 

0850 


STAX 

D 

A 

1405 

i THEN CALLS 

THE SEARCH AND INSERT 

2AF8 

23 

0855 


INX 

H 

A 

1410 

i NODE ROUTINES 


2AF9 

13 

0860 


I NX 

D 

A 

1415 

; 



2AFA 

(ID 

0865 


DCP. 

C 

A 2BC8 CD7330 

1420 

STNUM : CALL 

NXTCR 


2AFB 

C2F62A 

0870 


JNZ 

STAD1 

A 2BCB 1A 

1425 

LDAX 

D 




0875 

J 



A 2BCC 32A532 

1430 

STA 

VALLO 




0880 

; 

SETS LINKS 

IN AREA CALLED ’TABLE’. INITIALIZES 

A 2BCF CD7330 

1435 

CALL 

NXTCR 




0885 

; 

THE TOP POINTERS FOR THE FOUR LISTS ’SYTOP’j 

A 2BD2 1A 

1440 

LDAX 

D 




0890 

; 

* STTOP * j ’ 

ARTOP * * AND ’ NMTOP ’ . IN1TIALIZES " THE 

A 2BD3 32A432 

1445 

STA 

VALHI 




0895 

; 

Availability pointer ’Avail*. 

\ 2BD6 AF 

1450 

XRA 

A 




0900 

; 


> 

\ 2BD7 32A132 

1455 

STA 

LNTAB 


2AFE 

2600 

0905 


MVI 

Hj 0 > 

\ 2BDA 2AAC32 

1460 

LHLD 

NMTOP 


2B00 

2E00 

0910 


MVl 

Lj 0 ) 

< 2BDD 22B032 

1465 

SHLD 

TOP 


2B02 

224333 

09 15 


SHLD 

ADDR ) 

< 2BE0 CD7A2C 

1470 

CALL 

SERCH 


2B05 

0600 

0920 


MVI 

Bj 0 ) 

{ 2BE3 2AB032 

1475 

LHLD 

TOP 


2B07 

0E04 

0925 


MVI 

C j 4 > 

< 2BE6 22AC32 

1480 

SHLD 

NMTOP 


2B09 

1 18F33 

0930 


LXI 

Dj TABLE*2 ) 

< 2BE9 C9 

148 5 

RET 



2B0C 

2A4333 

0935 

SLINK: LHLD 

ADDR ) 

* 

1490 

; 



2B0F 

23 

0940 


INX 

H ) 

\ 

1495 

; EXTRACT A SYMBOL AND DETERMINE VHIC1 

2B10 

3E0C 

0945 


MVI 

A* 0CH 


1500 

; LIST IT BELONGS IN. CALLS THE 

2B12 

DC 

0950 


CMP 

H 


1505 

J SEARCH AND 

INSERT NODE 

ROUTINES. 

2B13 

CA232B 

0955 


JZ 

STOPS 


1510 

; 



2B16 

224333 

0960 


SHLD 

ADDR 

< 2BEA 3E20 

1515 

GETSY: MVI 

Aj 20H 


2B 19 

62 

0965 


MOV 

HjD 

< 2BEC 32A532 

1520 

STA 

VALLO 


2B1A 

6B 

0970 


MOV 

Lj e 

< 2BEF 32A432 

1525 

STA 

VALHI 


2B1B 

09 

0975 


DAD 

B 

< 2BF2 1A 

1530 

LDAX 

D 


2B1C 

EB 

0980 


XCHG 


< 2BF3 32A432 

1535 

STA 

VALHI 


2B1D 

73 

0985 


MOV 

Mj E 

( 2BF6 CD7330 

1540 

CALL 

NXTCR 


2B1E 

23 

0990 


INX 

H 

( 2BF9 3E0D 

1545 

MVI 

Aj0DH 


2B1F 

72 

0995 


MOV 

MiD } 

/ 2BFB 21A132 

1550 

LXI 

HjLNTAB 


2B20 

C30C2B 

1000 


JMP 

SLINK \ 

j 2BFE BE 

1555 

CMP 

M 


2B23 

3EFF 

1005 

STOPS: MVI 

Aj0FFH V 

j 2BFF C2082C 

1560 

JNZ 

GETS 1 


2B25 

23 

1010 


INX 

H V 

j 2C02 CD4A2C 

1565 

CALL 

STRSY 


2B26 

77 

1015 


MOV 

Mj A V 

j 2C05 C3492C 

1570 

JMP 

GETS5 


2B27 

2 6BB 

1020 


MVI 

Hj 0BBH V 

( 2C08 62 

1575 

GETS 1 : MOV 

HjD 


2B29 

2 EBB 

1025 


MVI 

Lj 0BBH V 

( 2C09 6B 

1580 

MOV 

LjE 


2B2B 

22A632 

1030 


SHLD 

SYTOP V 

( 2C0A 3E2F 

158 5 

MVI 

Aj 2FH 


2B2E 

22A832 

1035 


SHLD 

STTOP V 

( 2C0C BE 

1590 

CMP 

M 


2B31 

22AA32 

1040 


SHLD 

ARTOP V 

( 2C0D D22C2C 

1595 

JNC 

GETS2 


2B34 

22AC32 

1045 


SHLD 

NMTOP \ 

j 2C10 3E39 

1600 

MVI 

Aj 39H 


2B37 

218F33 

1050 


LXI 

HiTABLE+2 V 

( 2C12 BE 

1605 

CMP 

M 


2B3A 

22AE32 

1055 


SHLD 

AVAIL V 

( 2C13 DA2C2C 

1610 

JC 

GETS2 


2B3D 

CD2F30 

1060 


CALL 

RDBLK V 

{ 2C16 1A 

1615 

LDAX 

D 




1065 

; 


y 

j 2C17 32A532 

1620 

STA 

VALLO 




1070 

; 

BEGINS PROCESSING FOR A LINE OF BASIC CODE. 

( 2C1A CD7330 

1625 

CALL 

NXTCR 




1075 

; 

STORES LINE NUMBER AND LINE LENGTH. 

( 2C1D 3E0D 

1630 

MVI 

Aj 0DH 




1030 

; 


> 

{ 2C1F 21A132 

1635 

LXI 

HjLNTAB 







y 

j 2C22 BE 

1640 

CMP 

M 







> 

( 2C23 C22C2C 

1645 

JNZ 

GETS2 



Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

153 





2C26 CD4A2C 
2C29 C3492C 
2C2C 62 
2C2D 6E 
2C2E 3E24 
2C30 BE 
2C31 C23A2C 
2C34 CD5A2C 
2C37 C3492C 
2C3A 3EE0 
2C3C BE 
2C3D C2462C 
2C40 CD6A2C 
2C43 C3492C 
2C46 CD4A2C 
2C49 C9 


2C4A 2AA632 
2C4D 22B032 
2C50 CD7A2C 
2C53 2AB032 
2C56 22A632 
2C59 C9 


2C5A 2AA832 
2C5D 22B032 
2C60 CD7A2C 
2C63 2AB032 
2C66 22A832 
2C69 C9 


2C6A 2AAA32 
2C6D 22B032 
2C70 CD7A2C 
2C7 3 2AB032 
2C76 22AA32 
2C79 C9 


2C7A 229C32 
2C7D EB 
2C7E 229E32 
2C81 3EBB 
2C83 329832 
2C86 329932 
2C89 2AAE32 
2C8C 229A32 
2C8F 2B 
2C90 3AA432 
2C93 77 
2C94 2B 
2C95 3AA532 
2C98 77 
2C99 23 
2C9A 23 
2C9B 3EBB 
2C9D 77 
2C9E 23 
2C9F 77 
2CAB 23 
2CA1 23 
2CA2 23 
2CA3 7E 
2CA4 32AE32 
2CA7 3ECC 
2CA9 77 
2CAA 23 
2CAB 7E 
2CAC 32AF32 
2CAF 3ECC 
2CB1 77 
2CB2 2A9C32 
2CB5 3EBB 
2CB7 BC 
2CB8 C2C92C 
2CBB BD 
2CBC C2C92C 
2CBF 2A9A32 
2CC2 22B032 
2CC5 CD752D 
2CC8 C9 
2CC9 2B 
2CCA 56 
2CCB 3AA432 
2CCE BA 
2CCF CA322D 
2CD2 D2FB2C 


2CD5 2A9A32 
2CD8 3A9C32 
2CDB 77 
2CDC 23 
2CD0 3A9D32 
2CE0 77 

SCSI 2A9832 
2CE4 3EBB 
2CE6 BC 
2CE7 C2EE2C 
2CEA BD 


Number 44 

154 


1650 

CALL 

STRSY 

J) 2CEB 

CABF2C 

2215 

JZ 

SERC1 

1655 

JMP 

GETS5 

J) 2CEE 

3A9A32 

2220 DGRTli 

LDA 

PRSNT 

1660 GETS2I 

MOV 

Hi D 1 

J) 2CF1 

77 

2225 

MOV 

Ms A 

1665 

MOV 

Li E l 

J) 2CF2 

23 

2230 

I NX 

H 

1670 

MVI 

A.24H 1 

}) 2CF3 

3A9B32 

2235 

LDA 

PRSNT* 1 

1675 

CMP 

M 1 

J) 2CF6 

77 

2240 

MOV 

Ms A 

1680 

JNZ 

GETS3 l 

J) 2CF7 

CD752D 

2245 

CALL 

LNNUM 

1685 

CALL 

STRST 1 

J) 2CFA 

C9 

2250 

RET 



1690 JMP GETS5 

1695 GETS3: MVI As0E0H 
1700 CMP M 

1705 JNZ GETS4 

1710 CALL STRAR 

1715 JMP GETS5 

1720 GETS4I CALL STRSY 
1725 GETS5: RET 
1730 ; 

1735 J SETS SYMBOL LIST TOP POINTER AND CALLS 
1740 ; SEARCH AND INSERT NODE ROUTINES. 

1745 ; 


1750 STRSYi 

LHLD 

SYTOP 

1755 

SHLD 

TOP 

1760 

CALL 

SERCH 

1765 

LHLD 

TOP 

1770 

SHLD 

SYTOP 


1775 
1780 ; 
1785 I 
1790 J 
1795 ; 
1800 
1805 
1810 
18 15 
1820 
1825 
1830 
1835 
18 40 
1845 


SETS TOP POINTER TO STRING LIST TOP AND 
CALLS SEARCH AND INSERT NODE ROUTINES. 


STRSTl LHLD 

STTOP 

SHLD 

TOP 

CALL 

SERCH 

LHLD 

TOP 

SHLD 

STTOP 

RET 



SETS TOP POINTER TO ARRAY LIST TOP AND 
CALLS SEARCH AND INSERT NODE ROUTINES. 


1850 

STRAR» LHLD 

ARTOP 

1855 

SHLD 

TOP 

1860 

CALL 

SERCH 

1865 

LHLD 

TOP 

1870 

1875 

1880 

SHLD 

RET 

; 

ARTOP 

1885 

1890 

; SEARCH AND 
; 

STORE 1 

1895 

1900 

SERCHi SHLD 
XCHG 

NEXT 

1905 

SHLD 

POINT 

19 10 

MVI 

As0BBH 

1915 

STA 

LAST* 

1920 

STA 

LAST*1 

1925 

LHLD 

AVAIL 

1930 

SHLD 

PRSNT 

1935 

DCX 

H 

1940 

LDA 

VALHI 

1945 

MOV 

Ms A 

1950 

DCX 

H 

1955 

LDA 

VALLO 

1960 

MOV 

Ms A 

1965 

I NX 

H 

19.70 

I NX 

H 

1975 

MVI 

As 0BBH 

1980 

MOV 

Ms A 

1985 

INX 

H 

1990 

MOV 

Ms A 

1995 

INX 

H 

2000 

INX 

H 

2005 

INX 

H 

2010 

MOV 

AsM 

2015 

STA 

AVAIL 

2020 

MVI 

As 0CCH 

2025 

MOV 

Ms A 

2030 

INX 

H 

2035 

MOV 

AsM 

2040 

STA 

AVAIL* 

2045 

MVI 

As 0CCH 

2050 

MOV 

Ms A 

2055 

LHLD 

NEXT 

2060 

MVI 

As 0BBH 

2065 

CMP 

H 

2070 

JNZ 

SERC2 

2075 

CMP 

L 

2080 

JNZ 

SERC2 

2085 

SERCH LHLD 

PRSNT 

2090 

SHLD 

TOP 

2095 

2100 

CALL 

RET 

LNNUM 

2105 

SERC21 DCX 

H 

21 10 

MOV 

DsM 

2115 

LDA 

VALHI 

2120 

CMP 

D 

2125 

JZ 

DEQUA 

2130 

2135 

JNC 

DLESA 

2140 

; SETS THE LINKS IN 

2145 

; TO REFLECT 

THE PRl 

2150 

2155 

i CURRENT ITEM. 

; 

2160 

DGRTAi LHLD 

PRSNT 

2165 

LDA 

NEXT 

2170 

MOV 

Ms A 

2175 

INX 

H 

2180 

LDA 

NEXT*1 

2185 

MOV 

Ms A 

2190 

LHLD 

LAST 

2195 

MVI 

As 0BBH 

2200 

CMP 

H 

2205 

JNZ 

DGRT1 

2210 

CMP 

L 


2D75 
2D78 
2D79 
2D7 A 
2D7B 
2D7C 
2D7E 
2D7F 
2D82 
2D8 3 
2D84 
2D87 
2D88 
2D8B 
2 DSC 
2D8D 
2D90 
2D9 1 
2D94 
2D95 
2D96 
2D99 
2D9A 
2D9B 


2A9A32 

23 

23 

23 

23 

3ECC 

BE 

C2B52D 

23 

BE 

C2B42D 

2B 

3AAE32 

77 

23 

3AAF32 

77 

2AAE32 

2B 

2B 

3AA232 

77 

23 

3AA332 


2255 

2260 

2265 

2270 

2275 


CONTINUES TO SEARCH THE APPROPRIATE 
LIST FOR THE PROPER PLACE IN WHICH 
TO INSERT THE CURRENT ITEM. 


2CFB 

3 EBB 

2280 

DLESA« 

MVI 

As 0BBH 

2CFD 

2A9C32 

2265 


LHLD 

NEXT 

2D00 

BC 

2290 


CMP 

H 

2D0 1 

C2182D 

2295 


JNZ 

DLES2 

2D04 

BD 

2300 


CMP 

L 

2D05 

C2162D 

2305 


JNZ 

DLES2 

2D08 

2A9832 

2310 

DLES1l 

LHLD 

LAST 

2D0B 

3A9A32 

2315 


LDA 

PRSNT 

2D0E 

77 

2320 


MOV 

Ms A 

2D0F 

23 

2325 


INX 

H 

2D 1 0 

3A9B32 

2330 


LDA 

PRSNT* 1 

2D 1 3 

77 

2335 


MOV 

Ms A 

2D 14 

CD752D 

2240 


CALL 

LNNUM 

2D 1 7 

C9 

2345 


RET 


2D 16 

2A9C32 

2350 

DLES2 l 

LHLD 

NEXT 

2D 1B 

229832 

2355 


SHLD 

LAST 

2D 1E 

5E 

2360 


MOV 

EsM 

2D1F 

23 

2365 


INX 

H 

2D20 

56 

2370 


MOV 

DsM 

2D2 1 

EB 

2375 


XCHG 


2D22 

229C32 

2380 


SHLD 

NEXT 

2D25 

3 EBB 

2385 


MVI 

As 0BBH 

2D27 

BC 

2390 


CMP 

H 

2D28 

C2C92C 

2395 


JNZ 

SERC2 

2D2B 

BD 

2400 


CMP 

L 

2D2C 

C2C92C 

2405 


JNZ 

SERC2 

2D2F 

C3062D 

2410 


JMP 

DLES1 



2415 

; 





2420 

; CHECKS TO 

SEE IF T1 



2425 

i IS ALREADY 

IN THE i 



2430 

; 



2D32 

2B 

2435 

DEQUA: 

DCX 

H 

2D33 

56 

2440 


MOV 

DsM 

2D34 

3AA532 

2445 


LDA 

VALLO 

2D37 

BE 

2450 


CMP 

M 

2D38 

CA412D 

2455 


JZ 

DEQU1 

2D3B 

D2FB2C 

2460 


JNC 

DLESA 

2D3E 

C3D52C 

2465 


JMP 

DGRTA 

2D41 

2AAE32 

2470 

DEQU1: 

LHLD 

AVAIL 

2D44 

2B 

2475 


DCX 

H 

2D45 

2B 

2460 


DCX 

H 

2D46 

2B 

2485 


DCX 

H 

2D47 

3AAF32 

2490 


LDA 

AVAIL*] 

2D4A 

77 

2495 


MOV 

Ms A 

2D4B 

2B 

2500 


DCX 

H 

2D4C 

3AAE32 

2505 


LDA 

AVAIL 

2D4F 

77 

2510 


MOV 

Ms A 

2D50 

2B 

2515 


DCX 

H 

2D51 

2B 

2520 


DCX 

H 

2D52 

2B 

2525 


DCX 

H 

2D53 

EB 

2530 


XCHG 


2D54 

2AAE32 

2535 


LHLD 

AVAIL 

2D57 

2B 

2540 


DCX 

H 

2D58 

2B 

2545 


DCX 

H 

2D59 

2B 

2550 


DCX 

H 

2D5A 

2B 

2555 


DCX 

H 

2D5B 

22AE32 

2560 


SHLD 

AVAIL 

2D5E 

EB 

256 5 


XCHG 


2D5F 

3AAF32 

2570 


LDA 

AVAIL*1 

2D62 

77 

2575 


MOV 

Ms A 

2D63 

2B 

2580 


DCX 

H 

2D64 

3AAE32 

2585 


LDA 

AVAIL 

2D67 

77 

2590 


MOV 

Ms A 

2D68 

22AE32 

2595 


SHLD 

AVAIL 

2D6B 

2A9C32 

2600 


LHLD 

NEXT 

2D6E 

229A32 

2605 


SHLD 

PRSNT 

2D7 1 

CD752D 

2610 


CALL 

LNNUM 

2D7 4 

C9 

2615 


RET 




2620 

; 




2625 
2630 
2635 
2640 
2645 
2650 
2655 
266e 
2665 
2670 
2675 
2680 
2685 
2690 
2695 
2700 
2705 
2710 
2715 
2720 
2725 
27 30 
2735 
274e 
2745 
2750 
2755 
2760 
2765 
2770 
2775 


INSERTS THE LINE NUMBER FOR THE 
CURRENT ITEM IN THE LINE NUMBER 
LIST FOR THAT ITEM. THE NEW 
LINE NUMBER IS ADDED AT THE END 
OF THE LIST SINCE THEY ARE ENCOUNTERED 
IN ORDER. 


LHLD 

PRSNT 

INX 

H 

INX 

H 

INX 

H 

INX 

H 

MVI 

As 0CCH 

CMP 

M 

JNZ 

LNNU3 

INX 

H 

CMP 

M 

JNZ 

LNNU2 

DCX 

H 

LDA 

AVAIL 

MOV 

Ms A 

INX 

H 

LDA 

AVAIL* 

MOV 

Ms A 

LHLD 

AVAIL 

DCX 

H 

DCX 

H 

LDA 

LOLIN 

MOV 

Ms A 

INX 

H 

LDA 

HILIN 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 29 


2D9S 

77 

2780 


MOV 

Ms A 

2D9 7 

23 

2785 


INX 

H 

2 DAO 

7E 

2790 


MOV 

AsM 

2DA1 

32AE32 

2795 


STA 

AVAIL 

2DA4 

3ECC 

2800 


MVI 

As 0CCH 

2 DA 6 

77 

2805 


MOV 

Ms A 

2DA7 

23 

2810 


INX 

H 

2 DAG 

7E 

2815 


MOV 

AsM 

2DA9 

32AF32 

2820 


STA 

AVAIL* 1 

2DAC 

3ECC 

2825 


MVI 

As 0CCH 

2 DAE 

77 

2830 


MOV 

Ms A 

2DAF 

2A9E32 

28 35 


LHLD 

POINT 

2DB2 

EB 

2840 


XCHG 


2DB3 

C9 

2845 


RET 


2DB<i 

2B 

28 50 

LNNU21 

DCX 

H 

2DB5 

5E 

2855 

LNNU3l 

MOV 

EsM 

2DB6 

23 

2860 


INX 

H 

2DB7 

56 

2865 


MOV 

DsM 

2 DBG 

EB 

2870 


XCHG 


2DB9 

C37C2D 

2875 


JMP 

LNNU1 



2880 

; 




2885 ; PRINTS THE NECESSARY HEADERS AND 
2890 ; LOADS THE APPROPRIATE LIST TOP POINTERS 
2895 ; FOR USE BY THE SEARCH AND PRINT ROUTINES. 
2900 ; 


2 DBG 

0E12 

2905 

PRTRNl MVI 

Cs 18 

2 DBF. 

214131 

29 10 

LXl 

HsHDRl1 

2DCI 

CD6830 

2915 

CALL 

CRLF 

2DC4 

CD5E30 

2920 

CALL 

PRINT 

2DCT 

CD6830 

2925 

CALL 

CRLF 

2 DC A 

2AA632 

2930 

LHLD 

SYTOP 

2DCD 

22B032 

2935 

SHLD 

TOP 

2DDC 

3E0 1 

2940 

MVI 

As 1 

2DD2 

329732 

2945 

STA 

MARK 

2DD5 

CD2F2E 

2950 

CALL 

FNDSY 

2DD8 

CD6830 

2955 

CALL 

CRLF 

2 DDE 

0E10 

2960 

MVI 

Cs 16 

2DDD 

215331 

2965 

LXI 

HsHDR12 

2DE0 

CD5E30 

2970 

CALL 

PRINT 

2DE3 

CD68 30 

2975 

CALL 

CRLF 

2DE6 

2AA832 

2980 

LHLD 

STTOP 

2DE9 

22B032 

2985 

SHLD 

TOP 

2DEC 

3E02 

2990 

MVI 

As 2 

2DEE 

329732 

2995 

STA 

MARK 

2DF 1 

CD2F2E 

3000 

CALL 

FNDSY 

2DF4 

CD6830 

3005 

CALL 

CRLF 

2DF7 

0E0F 

3010 

MVI 

Cs 15 

2DF9 

216331 

3015 

LXI 

Hs HDR13 

2DFC 

CD5E30 

3020 

CALL 

PRINT 

2DFF 

CD6830 

3025 

CALL 

CRLF 

2E02 

2AAA32 

3030 

LHLD 

ARTOP 

2E05 

22B032 

3035 

SHLD 

TOP 

2E08 

3E03 

3040 

MVI 

As 3 

2E0A 

329732 

3045 

STA 

MARK 

2E0D 

CD2F2E 

3050 

CALL 

FNDSY 

2E10 

CD6630 

3055 

CALL 

CRLF 

2E13 

0E0C 

3060 

MVI 

Cs 12 

2E15 

217231 

3065 

LXI 

Hs HDR 1 4 

2E18 

CD5E30 

3070 

CALL 

PRINT 

2E1B 

CD6830 

3075 

CALL 

CRLF 

2E1E 

2AAC32 

3080 

LHLD 

NMTOP 

2E2 1 

22B032 

3085 

SHLD 

TOP 

2E24 

3E04 

3090 

MVI 

As 4 

2E26 

329732 

3095 

STA 

MARK 

2E29 

CD2F2E 

3000 

CALL 

FNDSY 

2E2C 

C32820 

3105 

JMP 

EXIT 


3110 ; 

3115 J THIS SECTION USES THE CENTENTS OF 'TOP* 
3120 ; AND FOLLOWS THE LINKS FOR THE APPROPRIATE 
3125 ; LIST. AT EACH ELEMENT IT LOADS ’HOLDT' 

3130 ; WITH THE LINE FOR THE LINE NUMBER 

3135 ; REFERENCES AND FOLLOWS THAT LI ST* PRINTING 

3140 i THE NUMBERS AS IT GOES. 

3145 ; 

2E2F 2AB032 3150 FNDSY* LHLD TOP 

2E32 3EBB 3155 MVI A* 0BBH 

2E34 BC 3160 CMP H 

2E35 C24B2E 3165 JNZ FNDS1 

2E38 BD 3170 CMP L 

2E39 C24B2E 3175 JNZ FNDS1 

2E3C 0E09 3180 MVI Cs9 

2E3E 217E31 3185 LXI HsHDRl5 

2E41 CD6830 3190 CALL CRLF 

2E44 CD5E30 3195 CALL PRINT 

2E47 CD6830 3200 CALL CRLF 

2E4A C9 3205 RET 

2E4B CD2130 3210 FNDSll CALL BLKLN 

2E4E 2AB032 3215 LHLD TOP 

2E51 5E 3220 MOV Es M 

2E52 23 3225 INX H 

2E53 56 3230 MOV DsM 

2E54 2B 3235 DCX H 

2E55 EB 3240 XCHG 

2E56 229C32 3245 SHLD NEXT 

2E59 3A9732 3250 LDA MARK 

2E5C FE04 3255 CPI 4 


2E5E 

C28B2E 

3260 

JNZ 

FNDS3 

2E61 

IB 

3265 

DCX 

D 

2E62 

1A 

3270 

LDAX 

D 

2E63 

32A432 

3275 

STA 

VALHI 

2E66 

IB 

3280 

DCX 

D 

2E67 

1A 

3285 

LDAX 

D 

2E68 

32A532 

3290 

STA 

VALLO 

2E6B 

CD842F 

3295 

CALL 

CONVR 

2E6E 

214533 

3300 

LXI 

HsPLINE 

2E7 1 

EB 

3305 

XCHG 


2E72 

21B432 

3310 

LXI 

HsNUMBR 

2E7 5 

0E05 

3315 

MVI 

Cs 5 

2E77 

7E 

3320 FNDS21 

MOV 

AsM 

2E78 

12 

3325 

STAX 

D 

2E79 

23 

3330 

INX 

H 

2E7A 

13 

3335 

INX 

D 

2E7B 

0D 

3340 

DCR 

C 





2E7C 

C2772E 

3345 


JNZ 

FNDS2 

2E7F 

2AB032 

3350 


LHLD 

TOP 

2E82 

EB 

3355 


XCHG 


2E8 3 

IB 

3360 


DCX 

D 

2E84 

IB 

3365 


DCX 

D 

2E85 

CDDB2E 

3370 


CALL 

LSTNM 

2E88 

C3C12E 

3375 


JMP 

FNDS7 

2E8B 

214533 

3380 

FNDS31 

LXI 

HsPLINE 

2E8E 

IB 

3385 


DCX 

D 

2E8F 

1A 

3390 


LDAX 

D 

2E90 

77 

3395 


MOV 

Ms A 

2E9 1 

23 

3400 


INX 

H 

2E92 

IB 

3405 


DCX 

D 

2E9 3 

1A 

3410 


LDAX 

D 

2E94 

FE20 

3415 


CPI 

20H 

2E96 

CA9B2E 

3420 


JZ 

FNDS4 

2E99 

77 

3425 


MOV 

Ms A 

2E9A 

23 

3430 


INX 

H 

2E9B 

3A9732 

3435 

FNDS4i 

LDA 

MARK 

2E9E 

FE02 

3440 


CPI 

2 

2EA0 

C2AC2E 

3445 


JNZ 

FNDS5 

2EA3 

3E24 

3450 


MVI 

As 2 AH 

2EA5 

77 

3455 


MOV 

Ms A 

2EA6 

CDDB2E 

3460 


CALL 

LSTNM 

2EA9 

C3C12E 

3465 


JMP 

FNDS7 

2EAC 

FE03 

3470 

FNDS5* 

CPI 

3 

2EAE 

C2BE2E 

3475 


JNZ 

FNDS6 

2EB1 

3E2S 

348 0 


MVI 

As 28H 

2EB3 

77 

3485 


MOV 

Ms A 

2EB4 

23 

3490 


INX 

H 

2EB5 

3E29 

3495 


MVI 

As 29H 

2EB7 

77 

3500 


MOV 

Ms A 

2EB8 

CDDB2E 

3505 


CALL 

LSTNM 

2 EBB 

C3C12E 

3510 


JMP 

FNDS7 

2EBE 

CDDB2E 

3515 

FNDS6I 

CALL 

LSTNM 

2EC 1 

2A9C32 

3520 

FNDS7i 

LHLD 

NEXT 

2EC4 

3EBB 

3525 


MVI 

As 0BBH 

2EC6 

BC 

3530 


CMP 

H 

2EC7 

C2CF2E 

3535 


JNZ 

FNDS8 

2ECA 

BD 

3540 


CMP 

L 

2ECB 

C2CF2E 

3545 


JNZ 

FNDS8 

2ECE 

C9 

3550 


RET 


2ECF 

CD6830 

3555 

FNDS8 l 

CALL 

CRLF 

2ED2 

2A9C32 

3560 


LHLD 

NEXT 

2ED5 

22B032 

3565 


SHLD 

TOP 

2ED8 

C34B2E 

3570 


JMP 

FNDS1 


3575 ; 

3580 ; FOLLOWS EACH LINE NUMBER LIST AND PRINTS 

3585 J THE FORMATED NUMBERS. 

3590 i 

2EDB 13 3595 LSTNMi INX D 

2EDC 13 3600 INX D 

2EDD 13 3605 INX D 

2EDE 13 3600 INX D 

2EDF 13 3615 INX D 

2EE0 13 3620 INX D 

2EE1 13 3625 INX D 

2EE2 13 3630 INX D 

2EE3 13 3635 INX D 

2EE4 13 3640 INX D 

2EE5 AF 3645 LSTNU XRA A 

2EE6 329432 3650 STA TAB 

2EE9 3E08 3655 MVI As 8 

2EEB 329232 3660 STA LINCT 

2EEE 3E0C 3665 MVI As 12 

2EF0 329332 3670 STA CHRCT 

2EF3 215133 3675 LXI HsPLINE*12 

2EF6 22B232 3680 SHLD HOLDT 

2EF9 IB 3690 LSTN21 DCX D 

2EFA 1A 3695 LDAX D 

2EFB 32A432 3700 STA VALHI 

2EFE IB 3705 DCX D 

2EFF 1A 3710 LDAX D 

2F00 32A532 3715 STA VALLO 

2F03 13 3720 INX D 

2F04 13 3725 INX D 

2F05 1A 3730 LDAX D 

2F06 329832 3735 STA LAST 

2F09 13 3740 INX D 

2F0A 1A 3745 LDAX D 

2F0B 329932 3750 STA LAST*1 

2F0E CD842F 3755 CALL CONVR 

2F11 2AB232 3760 LHLD HOLDT 

2F14 EB 3765 XCHG 

2F15 21B432 3770 LXI HsNUMBR 

2F18 0E05 3775 MVI Cs5 

2F1A 7E 3730 LSTN3* MOV AsM 

2F1B 12 3785 STAX D 

2F1C 23 3790 INX H 

2F1D 13 3795 INX D 

2F1E 0D 3800 DCR C 

2F1F C21A2F 3805 JNZ LSTN3 

2F22 13 3810 INX D 

2F23 13 3815 INX D 

2F24 EB 3820 XCHG 

2F25 22B232 3825 SHLD HOLDT 

2F28 219332 3830 LXI HsCHRCT 

2F2B 3E07 3835 MVI As 7 

2F2D 86 3840 ADD M 

2F2E 329332 3845 STA CHRCT 

2F31 3A9232 3850 LDA LINCT 

2F34 3D 3855 DCR A 

2F35 CA4E2F 3860 JZ LSTN4 

2F38 329232 3865 STA LINCT 

2F3B 2A9832 3870 LHLD LAST 

2F3E EB 3875 XCHG 

2F3F 3ECC 3880 MVI As0CCH 

2F41 BA 3885 CMP D 

2F42 C2F92E 3890 JNZ LSTN2 

2F45 BB 3895 CMP E 

2F46 C2F92E 3900 JNZ LSTN2 

2F49 3E01 3905 MVI As 1 

2F4B 329432 3910 STA TAB 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

155 



2F4E 

3A9332 

39 15 

LSTN4: 

LDA 

CHRCT 

2F5 1 

4F 

3920 


MOV 

C, A 

2F52 

214533 

3925 


LX I 

H,PLINE 

2F55 

CD5E30 

39 30 


CALL 

PRINT 

2F58 

CD6830 

3935 


CALL 

CRLF 

2F5B 

3A9432 

3940 


LDA 

TAB 

2F5E 

FE0 1 

3945 


CPI 

1 

2F60 

C26A2F 

3950 


JNZ 

LSTN6 

2F63 

2A9C32 

3955 

LSTN5: 

LHLD 

NEXT 

2F66 

22B032 

3960 


SHLD 

TOP 

2F69 

C9 

3965 


RET 


2F6A 

2A9832 

3970 

LSTN6: 

LHLD 

LAST 

2F6D 

3ECC 

3975 


MV1 

A, 0CCH 

2F6F 

BC 

3880 


CMP 

H 

2F70 

C27A2F 

3985 


JNZ 

LSTN7 

2F73 

BD 

3990 


CMP 

L 

2F7 4 

C27A2F 

3995 


JNZ 

LSTN7 

2F77 

C3632F 

4000 


JMP 

LSTN5 

2F7A 

CD2130 

4005 

LSTN7: 

CALL 

BLKLN 

2F7D 

2A9832 

4010 


LHLD 

LAST 

2F80 

EB 

40 15 


XCHG 


2F8 1 

C3E52E 

4020 


JMP 

LSTN1 



4025 

; 




4030 ; CONVERTS EACH NUMBER IN THE LINE NUMBER 
4035 ; LISTS FROM HEX TO DECIMAL (ASCII). THIS IS 
4040 ; DONE BY INSPECTING EACH BIT OF THE STORED 
4045 ; LINE NUMBER BEGINNING WITH THE HIGH ORDER 
4050 i BIT. IF THE BIT IS ON, THE APPROPRIATE VALUE 
4055 ; (5 DIGITS) FROM THE DATA CALLED 'BASE:* ARE 
4060 ; ADDED DECIMALLY, ONE DIGIT AT A TIME, TNTO 
4065 i AN ACCUMULATOR AREA CALLED 'NUMBRi'. 




4070 

; 



2F84 

0E05 

4075 

CONVR: 

MVI 

C, 5 

2F86 

AF 

4080 


XRA 

A 

2F87 

21B432 

4085 


LX I 

H,NUMBR 

2F8 A 

77 

4090 

CONV1: 

MOV 

M, A 

2F8B 

23 

4095 


INX 

H 

2F8C 

0D 

4100 


DCR 

C 

2F8D 

C28A2F 

4105 


JNZ 

CON VI 

2F90 

AF 

41 10 


XRA 

A 

2F9 1 

329432 

4115 


STA 

TAB 

2F94 

210833 

4120 


LX I 

H,BASE-*79 

2F97 

EB 

4125 


XCHG 


2F98 

3AA432 

4130 


LDA 

VALHI 

2F9B 

47 

4135 

C0NV2: 

MOV 

B, A 

2F9C 

0E08 

4140 


MVI 

C, 8 

2F9E 

78 

4145 

C0NV3: 

MOV 

A, B 

2F9F 

E680 

4 150 


AN I 

80H 

2FA 1 

C2AC2F 

4155 


JNZ 

C0NV4 

2FA4 

IB 

4160 


DCX 

D 

2FA5 

IB 

4165 


DCX 

D 

2FA6 

IB 

4170 


DCX 

D 

2FA7 

IB 

4175 


DCX 

D 

2FA8 

IB 

4180 


DCX 

D 

2FA9 

C3DD2F 

4185 


JMP 

C0NV8 

2FAC 

2 IBS32 

4190 

C0NV4: 

LX I 

H,NUMBR*4 

2FAF 

AF 

4195 


XRA 

A 

2FB0 

329532 

4200 


STA 

CARRY 

2FB3 

3E05 

4205 


MVI 

A, 5 

2FB5 

329632 

4210 

C0NV5: 

STA 

COUNT 

2FB8 

1A 

4215 


LDAX 

D 

2FB9 

86 

4220 


ADD 

M 

2FBA 

77 

4225 


MOV 

M, A 

2FBB 

3A9532 

4230 


LDA 

CARRY 

2FBE 

86 

4235 


ADD 

M 

2FBF 

FE0A 

4240 


CPI 

0 AH 

2FC 1 

CACC2F 

4245 


JZ 

C0NV6 

2FC4 

D2CC2F 

4250 


JNC 

C0NV6 

2FC7 

77 

4255 


MOV 

M, A 

2FC8 

AF 

4260 


XRA 

A 

2FC9 

C3D12F 

4265 


JMP 

C0NV7 

2FCC 

D60A 

4270 

C0NV6: 

SUI 

0AH 

2FCE 

77 

4275 


MOV 

M, A 

2FCF 

3E0 1 

4280 


MVI 

A, 1 

2FD1 

329532 

428 5 

C0NV7: 

STA 

CARRY 

2FD4 

2B 

4290 


DCX 

H 

2FD5 

IB 

4295 


DCX 

D 

2FD6 

3A9632 

4300 


LDA 

COUNT 

2FD9 

3D 

4305 


DCR 

A 

2FDA 

C2B52F 

4310 


JNZ 

C0NV5 

2FDD 

0D 

4315 

C0NV8: 

DCR 

C 

2FDE 

CAE72F 

4320 


JZ 

C0NV9 

2FE1 

78 

4325 


MOV 

A, B 

2FE2 

07 

4330 


RLC 


2FE3 

47 

4335 


MOV 

B, A 

2FE4 

C39E2F 

4340 


JMP 

C0NV3 

2FE7 

3A9432 

4345 

C0NV9: 

LDA 

TAB 

2FEA 

FE0 1 

4350 


CPI 

1 

2FEC 

CAFA2F 

4355 


JZ 

CON 10 

2FEF 

3E01 

4360 


MVI 

A, 1 

2FF1 

329432 

4365 


STA 

TAB 

2FF4 

3AA532 

4370 


LDA 

VALLO 

2FF7 

C39B2F 

4375 


JMP 

C0NV2 

2FFA 

0E05 

4380 

CON 10: 

MVI 

C, 5 

2FFC 

21B432 

4385 


LX I 

H, NUMBR 

2FFF 

7E 

4390 

CON 1 1: 

MOV 

A, M 

3000 

C630 

4395 


ADI 

30H 

3002 

77 

4400 


MOV 

M, A 

3003 

3A9432 

4405 


LDA 

TAB 

3006 

FE0 1 

4410 


CPI 

1 

3006 

C21B30 

4415 


JNZ 

CON 13 

300B 

3E30 

4420 


MVI 

A, 30H 

300D 

BE 

4425 


CMP 

M 

300E 

C21730 

4430 


JNZ 

CON 12 

3011 

3E20 

4435 


MVI 

A, 20H 

3013 

77 

4440 


MOV 

M, A 

3014 

C31B30 

4445 


JMP 

CON 13 

3017 

AF 

4450 

CON 12: 

XRA 

A 

3018 

329432 

4455 


STA 

TAB 

30 IB 

23 

4460 

CON 13: 

INX 

H 

30 1C 

0D 

4465 


DCR 

C 

30 ID 

C2FF2F 

4470 


JNZ 

CONI 1 

3020 

C9 

4475 


RET 



4480 

4485 

4490 


; FILLS THE PRINT LINE WITH SPACES (20H). 


3021 

0E48 

4495 

BLKLN: 

MVI 

C, 72 

3023 

214533 

4500 


LX I 

H,PLINE 

3026 

3E20 

4405 


MVI 

A, 20H 

3028 

77 

4510 

BLKL1: 

MOV 

M, A 

3029 

23 

4515 


INX 

H 

302A 

0D 

4520 


DCR 

C 

302B 

C22830 

4525 


JNZ 

BLKL1 

302E 

C9 

4530 


RET 



4535 

4540 

4545 

4550 

4555 


J THIS ROUTINE READS ONE 256 BYTE BLOCK 
,* OF DATA FROM THE DISK INTO THE AREA 
I CALLED 'DATA'. 


302F 

3E0 1 

4560 

RDBLK: 

MVI 

A, 1 

3031 

0601 

4565 


MVI 

B, 1 

3033 

219131 

4570 


LX I 

H,DRIVE 

3036 

4E 

4575 


MOV 

C, M 

3037 

1 19231 

4580 


LX I 

D,DATA 

30 3A 

2A0933 

4585 


LHLD 

DIR 

303D 

23 

4590 


INX 

H 

303E 

220933 

4595 


SHLD 

DIR 

3041 

2B 

4600 


DCX 

H 

3042 

CD2220 

4605 


CALL 

RDDSK 

3045 

D25630 

46 10 


JNC 

RDBL 1 

3048 

0E0E 

4615 


MVI 

C, 14 

304A 

213331 

4620 


LX I 

H,HDR10 

304D 

CD5E30 

4625 


CALL 

PRINT 

3050 

CD6830 

46 30 


CALL 

CRLF 

3053 

C32820 

4635 


JMP 

EXIT 

3056 

AF 

4640 

RDBL1: 

XRA 

A 

3057 

32A032 

4645 


STA 

BLKPT 

305A 

1 19231 

4650 


LX I 

D,DATA 

305D 

C9 

4655 


RET 




4660 

; 





4665 

J PRINT STRING AT ADDRESS 



4670 

,* NUMBER OF 

CHARACTERS IN 



4675 

; 



305E 

46 

4680 

PRINT: 

MOV 

B,M 

305F 

CD0D20 

4685 


CALL 

COUT 

3062 

23 

4690 


INX 

H 

3063 

0D 

4695 


DCR 

C 

3064 

C25E30 

4700 


JNZ 

PRINT 

3067 

C9 

4705 


RET 




4710 

; 





4715 

; INSERT CR 

AND LF 



4720 

; 



3068 

060D 

4725 

CRLF: 

MVI 

B, 0DH 

306A 

CD0D20 

4730 


CALL 

COUT 

306D 

060A 

4735 


MVI 

B, 0 AH 

306F 

CD0D20 

4740 


CALL 

COUT 

3072 

C9 

4745 


RET 




4750 

; 





4755 

; CHECK BLOCK ROUTINE 



4760 

; 



3073 

13 

4765 

NXTCR: 

INX 

D 

3074 

21A032 

4770 


LX I 

H,BLKPT 

3077 

34 

4775 


INR 

M 

3078 

CC2F30 

4760 


CZ 

RDBLK 

307B 

62 

4785 


MOV 

H, D 

307 C 

6B 

4790 


MOV 

L, E 

307 D 

3E0D 

4795 


MVI 

A, 0DH 

307 F 

BE 

4800 


CMP 

M 

3080 

C28630 

4805 


JNZ 

NXTC1 

3083 

32A132 

48 10 


STA 

LNTAB 

3086 

C9 

4815 

NXTC1: 

RET 




48 20 

t 





4825 

I HEADERS 



3087 

30A6 

30B7 

30C3 

30DC 

30EE 

3110 

3120 

312C 

3133 

3141 

3153 

3163 

3172 

317E 

3187 

3191 

3192 
3292 
329 3 

3294 

3295 

3296 

3297 

3298 
329A 
329C 
329E 
32A0 
32A1 
32A2 
32A3 
32A4 
32A5 
32A6 
32A8 
32AA 
3 2 AC 
32AE 
32B0 
32B2 
32B4 


48 30 

4E4F5254484835 
4E414D45204840 
4F4E2044524845 
4E4F20505248 50 
46494C452046 55 
5441424C454860 
4E414D45204865 
494E56414C4870 
4E4F20524F4875 
415247554D4880 
53594D424F4865 
535452494E4890 
41525241594895 
4C494E45204900 
4E554C4C204905 
4910 

49 15 
4920 
4925 
4930 
49 35 
4940 
4945 
4950 
4955 
4960 
4965 
4970 
4975 
4980 
4985 
4990 
4995 
5000 
5005 
5010 
5015 
5020 
5025 
5030 
5035 
5040 


DB 

DB 

DB 

DB 

DB 

DB 

DB 


HDR1: 

HDR2: 

HDR3 i 
HDR4: 
HDR5: 

HDR6: 

HDR7 i 
HDR8: 

HDR9: DB 

HDR10: DB 
HDR11: DB 
HDR12i DB 
H DR131 DB 
HDR14: DB 
H DR 15« DB 
PNAME: DS 
DRIVE: DS 
DATA: DS 

LINCT: DS 
CHRCT: DS 
TAB: DS 

CARRY: DS 
COUNT: DS 
MARK: 
LAST: 
PRSNT: DS 
NEXT: DS 

POINT: DS 
BLKPT: DS 
LNTAB: DS 
LOLINi DS 
HILIN: DS 
VALHI: DS 
VALLO: DS 
SYTOP: DS 
STTOP: DS 
ARTOP: DS 
NMTOP: DS 
AVAIL: DS 
TOP: DS 

HOLDT: DS 
NUMBR: DS 


DS 

DS 


NORTHSTAR BASIC PROGRAM SUPPORT' 
NAME OF PROGRAM: • 

ON DRIVE #: ' 

NO PROGRAM wrTH THAT NAME* 

FILE IS NOT TYPE 2' 

TABLE FULL - PARTIAL LIST SUPPLIED* 
NAME IS TOO LONG' 

INVALID UNIT' 

NO ROOM' 

ARGUMENT ERROR' 

SYMBOLIC VARIABLES' 

STRING VARIABLES' ' 

ARRAY VARIABLES'* 

LINE NUMBERS' 

NULL LIST' * 


Number 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 31 


156 





32B9 

00000000015045 

BASEl 

DB 

0/0 / 0/0/ 1/0/ 0/0 / 0/2 / 0/0/ 0/0/ 4/ 0/0/ 0/0 

32 CC 

08000000015050 


DB 

8/2 j 0< 0/ 1/6/ 0/ 0/ 0/ 3/ 2/ 0/ 0/ 0/ 6/ 4/ 0/ 0/ 1 

32Dr 

02080000025055 


DB 

2/ 8/ 0/ 0/ 2/ 5/ 6/ 0 / 0 / 5/ 1/2/0/ 1/0/2 / 4/ 0/2 

32F2 

00040800045060 


DB 

0/4/8/0/4/0/9/6/0/6/ 1/9/2/ 1/6/3/8 /4/3 

3305 

02070608 5065 


DB 

2/7/6/8 

3305 

5070 

DlRl 

D5 

8 

3311 

5075 

STACKi 

DS 

50 

3343 

5080 

ADDRi 

DS 

2 

3345 

5085 

PLINEl 

DS 

72 

3381) 

5090 

TABLES 

DS 

12288 

638(1 

5095 


END 

2A00H 


DH 2A00)33FF 

•> 

>DH 2A00-33FFF? 
>DH 2A00-33FF 


2 A£ 0 

21 

42 

33 

F9 

0E 

IF 

21 

87 

30 

CD 

5E 

30 

CD 

68 

30 

0E 

2 A10 
2A20 
2A30 

C2 

CA 

21 

1C 

6F 

A6 

2A 

2A 

30 

0E 

FE 

CD 

09 

5F 

5E 

21 

C2 

30 

87 

54 

0E 

31 

2A 

0A 

CD 

3E 

21 

10 

09 

87 

20 

B9 

31 

32 
CA 

36 

B2 

28 

20 

32 

2A 

23 

FE 

3A 

0D 

0D 

B2 

2A40 

32 

2B 

0C 

47 

CD 

0D 

20 

06 

20 

CD 

0D 

20 

06 

5F 

CD 

0D 

2A50 

20 

C3 

28 

2A 

77 

A7 

CD 

0D 

20 

23 

0D 

C2 

28 

2A 

CD 

68 

2A60 

30 

0E 

10 

21 

10 

31 

CD 

5E 

30 

CD 

68 

30 

C3 

0F 

2A 

0E 

2A70 

0C 

21 

B7 

30 

CD 

68 

30 

CD 

5E 

30 

21 

91 

31 

CD 

10 

20 

2 AS 0 

47 

CD 

0D 

20 

FE 

31 

CA 

A4 

2A 

FE 

32 

CA 

A4 

2A 

FE 

33 

2A9 0 

CA 

A4 

2A 

CD 

68 

30 

0E 

0C 

21 

20 

31 

CD 

5E 

30 

CD 

68 

2AA0 

30 

C3 

6F 

2A 

E6 

0F 

77 

CD 

10 

20 

47 

CD 

0D 

20 

FE 

0D 

2 AB2 

C2 

93 

2A 

06 

0A 

CD 

0D 

20 

3A 

9 1 

31 

21 

87 

31 

37 

3F 

2 AC0 

CD 

1C 

20 

D2 

DA 

2A 

0E 

19 

21 

C3 

30 

CD 

5E 

30 

CD 

68 

2 AD 2 

30 

C3 

0F 

2A 

06 

00 

0E 

04 

09 

3E 

02 

BE 

CA 

ED 

2A 

0E 

2 AEi3 

12 

21 

DC 

30 

CD 

5E 

30 

CD 

66 

30 

C3 

0F 

2A 

2B 

2B 

2B 

2AF0 

2B 

0E 

06 

1 1 

09 

33 

7E 

12 

23 

13 

0D 

C2 

F 6 

2A 

26 

00 

2B0.3 

2E 

00 

22 

43 

33 

06 

00 

0E 

04 

1 1 

8F 

33 

2A 

43 

33 

23 

2 B1 0 

3E 

0C 

BC 

CA 

23 

2B 

22 

43 

33 

62 

6B 

09 

EB 

73 

23 

72 

2 B2i3 

C3 

0C 

2B 

3E 

FF 

23 

77 

26 

BB 

2E 

BB 

22 

A6 

32 

22 

A8 

2B3I3 

32 

22 

AA 

32 

22 

AC 

32 

21 

8F 

33 

22 

AE 

32 

CD 

2F 

30 

2B4I3 

AF 

32 

97 

32 

3C 

EB 

BE 

CA 

BC 

2D 

EB 

CD 

73 

30 

1A 

32 

2350 

A2 

32 

CD 

73 

30 

1A 

32 

A3 

32 

AF 

32 

A 1 

32 

CD 

73 

30 

2B60 

62 

6B 

3E 

20 

BE 

CA 

B6 

2B 

3E 

8F 

BE 

C2 

73 

2B 

3E 

01 

2B70 

32 

97 

32 

3E 

22 

BE 

C2 

90 

2B 

3A 

97 

32 

FE 

02 

C2 

88 

2B80 

2B 

AF 

32 

97 

32 

C3 

B6 

2B 

3E 

02 

32 

97 

32 

C3 

B6 

2B 

2B90 

3A 

97 

32 

FE 

00 

C2 

B6 

2B 

3£ 

9A 

BE 

C2 

A4 

2B 

CD 

C8 

2 BA0 

2B 

C3 

B6 

2B 

3E 

40 

BE 

D2 

B6 

2B 

3E 

5A 

BE 

DA 

B6 

2B 

2BB0 

CD 

EA 

2B 

C3 

B9 

2B 

CD 

73 

30 

3E 

0D 

21 

A1 

32 

BE 

C2 

2 BC0 

60 

2B 

CD 

73 

30 

C3 

40 

2B 

CD 

73 

30 

1A 

32 

A5 

32 

CD 

2 BDO 

73 

30 

1A 

32 

A4 

32 

AF 

32 

A1 

32 

2A 

AC 

32 

22 

B0 

32 

2BE0 

CD 

7A 

2C 

2A 

B0 

32 

22 

AC 

32 

C9 

3E 

20 

32 

A5 

32 

32 

2BF0 

A4 

32 

1A 

32 

AA 

32 

CD 

73 

30 

3E 

0D 

21 

A 1 

32 

BE 

C2 

2 C0O 

08 

2C 

CD 

4A 

2C 

C3 

49 

2C 

62 

6B 

3E 

2F 

BE 

D2 

2C 

2 C 

2 CIO 

3E 

39 

BE 

DA 

2C 

2C 

1A 

32 

A5 

32 

CD 

73 

30 

3E 

0D 

21 

2C20 

A 1 

32 

BE 

C2 

2C 

2C 

CD 

4A 

2C 

C3 

49 

2C 

62 

6B 

3E 

24 

2 C30 

BE 

C2 

3A 

2C 

CD 

5A 

2C 

C3 

49 

2C 

3E 

E0 

BE 

C2 

46 

2C 

2 C40 

CD 

6A 

2C 

C3 

A9 

2 C 

CD 

4A 

2C 

C9 

2A 

A6 

32 

22 

B0 

32 

2C50 

CD 

7 A 

2C 

2A 

B0 

32 

22 

A6 

32 

C9 

2A 

A8 

32 

22 

B0 

32 

2 C6W 

CD 

7A 

2C 

2A 

B0 

32 

22 

A8 

32 

C9 

2A 

AA 

32 

22 

B0 

32 

2 C7tJ 

CD 

7A 

2C 

2A 

B0 

32 

22 

AA 

32 

C9 

22 

9C 

32 

EB 

22 

9E 

2C80 

32 

3E 

BB 

32 

98 

32 

32 

99 

32 

2A 

AE 

32 

22 

9A 

32 

2B 

2C9H 

3A 

AA 

32 

77 

2B 

3A 

A5 

32 

77 

23 

23 

3E 

BB 

77 

23 

77 

2 CA0 

23 

23 

23 

7E 

32 

AE 

32 

3E 

CC 

77 

23 

7E 

32 

AF 

32 

3E 

2 CB0 

CC 

77 

2A 

9C 

32 

3E 

BB 

BC 

C2 

C9 

2C 

BD 

C2 

C9 

2C 

2A 

2 CCO 

9A 

32 

22 

B0 

32 

CD 

75 

2D 

C9 

2B 

56 

3A 

A4 

32 

BA 

CA 

2CD0 

32 

2D 

D2 

FB 

2C 

2A 

9A 

32 

3A 

9C 

32 

77 

23 

3A 

9D 

32 

2 CEO 

77 

2A 

98 

32 

3E 

BB 

BC 

C2 

EE 

2C 

BD 

CA 

BF 

2C 

3A 

9A 

2 CFO 

32 

77 

23 

3A 

9B 

32 

77 

CD 

75 

2D 

C9 

3E 

BB 

2A 

9C 

32 

2 D0O 

BC 

C2 

18 

2D 

BD 

C2 

18 

2D 

2A 

98 

32 

3A 

9A 

32 

77 

23 

2 DIO 

3A 

9B 

32 

77 

CD 

75 

2D 

C9 

2A 

9C 

32 

22 

98 

32 

5E 

23 

2 D20 

56 

EB 

22 

9C 

32 

3E 

BB 

BC 

C2 

C9 

2C 

BD 

C2 

C9 

2C 

C3 

2 D30 

08 

2D 

2B 

56 

3A 

A5 

32 

BE 

CA 

41 

2D 

D2 

FB 

2C 

C3 

D5 

2 DAO 

2C 

2A 

AE 

32 

2B 

2B 

2B 

3A 

AF 

32 

77 

2B 

3A 

AE 

32 

77 

2 D50 

2B 

2B 

2B 

EB 

2A 

AE 

32 

2B 

2B 

2B 

2B 

22 

AE 

32 

EB 

3A 

2 D60 

AF 

32 

77 

2B 

3A 

AE 

32 

77 

22 

AE 

32 

2A 

9C 

32 

22 

9A 

2D70 

32 

CD 

75 

2D 

C9 

2A 

9A 

32 

23 

23 

23 

23 

3E 

CC 

BE 

C2 

2 D80 

B5 

2D 

23 

BE 

C2 

B4 

2D 

2B 

3A 

AE 

32 

77 

23 

3A 

AF 

32 

2 D9£ 

77 

2A 

AE 

32 

2B 

2B 

3A 

A2 

32 

7/ 

23 

3A 

A3 

32 

77 

23 

2 DAC 

7E 

32 

AE 

32 

3E 

CC 

77 

23 

7E 

32 

AF 

32 

3E 

CC 

77 

2A 

2 DB0 

9E 

32 

EB 

C9 

2B 

5E 

23 

56 

EB 

C3 

7C 

2D 

0E 

12 

21 

41 

2 DC2 

31 

CD 

68 

30 

CD 

5E 

30 

CD 

68 

30 

2A 

A6 

32 

22 

B0 

32 

2 DDE 

3E 

01 

32 

97 

32 

CD 

2F 

2E 

CD 

68 

30 

0E 

10 

21 

53 

31 

2 DEB 

CD 

5E 

30 

CD 

68 

30 

2A 

A8 

32 

22 

B0 

32 

3E 

02 

32 

97 

2 DFe 

32 

CD 

2F 

2E 

CD 

68 

30 

0E 

0F 

21 

63 

31 

CD 

5E 

30 

CD 

2 E00 

68 

30 

2A 

AA 

32 

22 

B0 

32 

3E 

03 

32 

97 

32 

CD 

2F 

2E 

2 E10 

CD 

68 

30 

0E 

0C 

21 

72 

31 

CD 

5E 

30 

CD 

68 

30 

2A 

AC 

2 E20 

32 

22 

B0 

32 

3E 

04 

32 

97 

32 

CD 

2F 

2E 

C3 

28 

20 

2A 

2E30 

B0 

32 

3E 

BB 

BC 

C2 

4B 

2E 

BD 

C2 

4B 

2E 

0E 

09 

21 

7E 

2EA0 

31 

CD 

68 

30 

CD 

5E 

30 

CD 

68 

30 

C9 

CD 

21 

30 

2A 

B0 

2E50 

32 

5E 

23 

56 

2B 

EB 

22 

9C 

32 

3A 

97 

32 

FE 

04 

C2 

8B 

2 E62 

2E 

IB 

1A 

32 

AA 

32 

IB 

1A 

32 

A5 

32 

CD 

84 

2F 

21 

45 

2E7e 

33 

EB 

21 

BA 

32 

0E 

05 

7E 

12 

23 

13 

0D 

C2 

77 

2E 

2A 

2E8E 

B0 

32 

EB 

IB 

IB 

CD 

DB 

2E 

C3 

Cl 

2E 

21 

45 

33 

IB 

1A 

2E9e 

77 

23 

IB 

1A 

FE 

20 

CA 

9B 

2E 

77 

23 

3 A 

97 

32 

FE 

02 

2 EA0 

C2 

AC 

2E 

3E 

24 

77 

CD 

DB 

2E 

C3 

Cl 

2E 

FE 

03 

C2 

BE 

2 EB0 

2E 

3E 

28 

77 

23 

3E 

29 

77 

CD 

DB 

2E 

C3 

Cl 

2E 

CD 

DB 

2EC0 

2E 

2A 

9C 

32 

3E 

BB 

BC 

C2 

CF 

2E 

BD 

C2 

CF 

2E 

C9 

CD 

2 EDO 

68 

30 

2A 

9C 

32 

22 

B0 

32 

C3 

4B 

2E 

13 

13 

13 

13 

13 




★ 


2. 

EE0 

13 

13 

13 

13 

13 

AF 

32 

94 

32 

3E 

08 

32 

92 

32 

3E 

0C 

2 : 

EF0 

32 

93 

32 

21 

51 

33 

22 

B2 

32 

IB 

1A 

32 

A4 

32 

IB 

1A 

2 

F00 

32 

A5 

32 

13 

13 

1A 

32 

98 

32 

13 

1A 

32 

99 

32 

CD 

84 

2 

F 1 0 

2F 

2A 

B2 

32 

EB 

21 

B4 

32 

0E 

05 

7E 

12 

23 

13 

0D 

C2 

2 

F20 

1A 

2F 

13 

13 

EB 

22 

B2 

32 

21 

93 

32 

3E 

07 

86 

32 

93 

2 : 

F 30 

32 

3A 

92 

32 

3D 

CA 

4E 

2F 

32 

92 

32 

2A 

98 

32 

EB 

3E 

2 

F40 

CC 

BA 

C2 

F9 

2E 

BB 

C2 

F9 

2E 

3E 

01 

32 

94 

32 

3A 

93 

2 

F50 

32 

4F 

21 

45 

33 

CD 

5E 

30 

CD 

68 

30 

3A 

94 

32 

FE 

01 

2 

F60 

C2 

6A 

2F 

2A 

9C 

32 

22 

B0 

32 

C9 

2A 

98 

32 

3E 

CC 

BC 

2 

F70 

C2 

7A 

2F 

BD 

C2 

7A 

2F 

C3 

63 

2F 

CD 

21 

30 

2A 

98 

32 

2 

F80 

EB 

C3 

E5 

2E 

0E 

05 

AF 

21 

B4 

32 

77 

23 

0D 

C2 

8A 

2F 

2 

F90 

AF 

32 

94 

32 

21 

08 

33 

EB 

3A 

A4 

32 

47 

0E 

08 

78 

E6 

2 

FA0 

80 

C2 

AC 

2F 

IB 

IB 

IB 

IB 

IB 

C3 

DD 

2F 

21 

B8 

32 

AF 

2 

FB0 

32 

95 

32 

3E 

05 

32 

96 

32 

1A 

86 

77 

3A 

95 

32 

86 

FE 

2 

FC0 

0A 

CA 

CC 

2F 

D2 

CC 

2F 

77 

AF 

C3 

D1 

2F 

D6 

0A 

77 

3E 

2 

FD0 

01 

32 

95 

32 

2B 

IB 

3A 

96 

32 

3D 

C2 

B5 

2F 

0D 

CA 

E7 

2 

FE0 

2F 

78 

07 

47 

C3 

9E 

2F 

3A 

94 

32 

FE 

01 

CA 

FA 

2 F 

3E 

2 

FF0 

0 1 

32 

94 

32 

3A 

A5 

32 

C3 

9B 

2F 

0E 

05 

21 

B4 

32 

7E 

3000 

C6 

30 

77 

3A 

94 

32 

FE 

01 

C2 

IB 

30 

3E 

30 

BE 

C2 

1 7 

3 

010 

30 

3E 

20 

77 

C3 

IB 

30 

AF 

32 

94 

32 

23 

0D 

C2 

FF 

2F 

3 

020 

C9 

0E 

48 

21 

45 

33 

3E 

20 

77 

23 

0D 

C2 

28 

30 

C9 

3 E 

3 

030 

01 

06 

0 1 

21 

9 1 

31 

4E 

1 1 

92 

31 

2A 

09 

33 

23 

22 

09 

3 

040 

33 

2B 

CD 

22 

20 

D2 

56 

30 

0E 

0E 

21 

33 

31 

CD 

5E 

30 

3 

050 

CD 

68 

30 

C3 

28 

20 

AF 

32 

A0 

32 

1 1 

92 

31 

C9 

46 

CD 

3 

060 

0D 

20 

23 

0D 

C2 

5E 

30 

C9 

06 

0D 

CD 

0D 

20 

06 

0A 

CD 

3 

070 

0D 

20 

C9 

13 

21 

A0 

32 

34 

CC 

2F 

30 

62 

6B 

3E 

0D 

BE 

3 

080 

C2 

86 

30 

32 

A 1 

32 

C9 

4E 

4F 

52 

54 

48 

53 

54 

41 

52 

3 

090 

20 

42 

41 

53 

49 

43 

20 

50 

52 

4F 

47 

52 

41 

4D 

20 

53 

3 

0A0 

55 

50 

50 

4F 

52 

54 

4E 

41 

4D 

45 

20 

4F 

46 

20 

50 

52 

3 

0B0 

4F 

47 

52 

41 

4D 

3A 

20 

4F 

4E 

20 

44 

52 

49 

56 

45 

20 

3 

0C0 

23 

3A 

20 

4E 

4F 

20 

50 

52 

4F 

47 

52 

41 

4D 

20 

57 

49 

3 

0L0 

54 

48 

20 

54 

48 

41 

54 

20 

4E 

4 1 

4D 

45 

46 

49 

4C 

45 

3 

0E0 

20 

49 

53 

20 

4E 

4F 

54 

20 

54 

59 

50 

45 

20 

32 

54 

41 

3 

0F0 

42 

4C 

45 

20 

46 

55 

4C 

4C 

20 

2D 

20 

50 

41 

52 

54 

49 

3 

100 

41 

4C 

20 

4C 

49 

53 

54 

20 

53 

55 

50 

50 

4C 

49 

45 

44 

3 

110 

4E 

4 1 

4D 

45 

20 

49 

53 

20 

54 

4F 

4F 

20 

4C 

4F 

4E 

47 

3 

120 

49 

4E 

56 

41 

4C 

49 

44 

20 

55 

4E 

49 

54 

4E 

4F 

20 

52 

3 

130 

4F 

4F 

4D 

41 

52 

47 

55 

4D 

45 

4E 

54 

20 

45 

52 

52 

4F 

3 

140 

52 

53 

59 

4D 

42 

4F 

4C 

49 

43 

20 

56 

41 

52 

49 

41 

42 

3 

150 

4C 

45 

53 

53 

54 

52 

49 

4E 

47 

20 

56 

41 

52 

49 

41 

42 

3 

160 

4C 

45 

53 

41 

52 

52 

41 

59 

20 

56 

41 

52 

49 

41 

42 

4C 

3 

170 

45 

53 

4C 

49 

4E 

45 

20 

4E 

55 

4D 

42 

45 

52 

53 

4E 

55 

3 

180 

4C 

4C 

20 

4C 

49 

53 

54 

54 

41 

42 

4C 

45 

2B 

32 

0D 

0A 

3 

190 

31 

37 

32 

30 

20 

53 

4C 

49 

4E 

4B 

3A 

20 

4C 

48 

4C 

44 

3 

1A0 

20 

20 

41 

44 

44 

52 

0D 

0A 

31 

37 

33 

30 

20 

20 

20 

20 

3 

1B0 

20 

20 

20 

20 

49 

4t 

58 

20 

20 

20 

48 

00 

0A 

31 

37 

33 

3 

1C0 

32 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

56 

49 

20 

20 

20 

41 

3 

1D0 

2C 

30 

43 

48 

0D 

0A 

31 

37 

33 

34 

20 

20 

20 

20 

20 

20 

3 

1E0 

20 

20 

43 

4D 

50 

20 

20 

20 

48 

0D 

0A 

31 

37 

33 

36 

20 

3 

1F0 

20 

20 

20 

20 

20 

20 

20 

4A 

5A 

20 

20 

20 

20 

53 

54 

4F 

3 

200 

50 

53 

0D 

0A 

31 

37 

33 

37 

20 

20 

20 

20 

20 

20 

20 

20 

3 

210 

53 

48 

4C 

44 

20 

20 

41 

44 

44 

52 

0D 

0A 

31 

37 

33 

38 

3 

220 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

4F 

56 

20 

20 

20 

46 

2C 

3 

230 

44 

0D 

0A 

31 

37 

34 

30 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

3 

240 

4F 

56 

20 

20 

20 

4C 

2C 

45 

0D 

0A 

31 

37 

35 

30 

20 

20 

3 

250 

20 

20 

20 

20 

20 

20 

44 

41 

44 

20 

20 

20 

42 

0D 

0A 

31 

3260 

37 

36 

30 

20 

20 

20 

20 

20 

20 

20 

20 

58 

43 

48 

47 

0D 

3 

27 0 

0A 

31 

37 

36 

32 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

4F 

56 

3 

280 

20 

20 

20 

4D 

2C 

45 

0D 

0A 

31 

37 

36 

34 

20 

20 

20 

20 

3 

290 

20 

20 

20 

20 

49 

4E 

58 

20 

20 

20 

48 

0D 

0A 

31 

37 

36 

3 

2A0 

36 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

4F 

56 

20 

20 

20 

4D 

3 

2B6 

2C 

44 

0D 

0A 

31 

37 

36 

38 

20 

00 

00 

00 

00 

01 

00 

00 

3 

2C0 

00 

00 

02 

00 

00 

00 

00 

04 

00 

00 

00 

00 

08 

00 

00 

00 

3 

2D0 

01 

06 

00 

00 

00 

03 

02 

00 

00 

00 

06 

04 

00 

00 

01 

02 

3 

2E0 

03 

00 

00 

02 

05 

06 

00 

00 

05 

01 

02 

00 

01 

00 

02 

04 

3 

2F0 

00 

02 

00 

04 

08 

00 

04 

00 

09 

06 

00 

08 

01 

09 

02 

01 

3 

300 

06 

03 

08 

04 

03 

02 

07 

06 

08 

4F 

56 

20 

20 

20 

4D 

2C 

3 

310 

41 

0D 

0 A 

31 

37 

39 

30 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

3 

320 

56 

49 

20 

20 

20 

48 

2C 

30 

42 

42 

48 

0D 

0A 

31 

38 

30 

3 

330 

30 

20 

20 

20 

20 

20 

20 

20 

20 

4D 

56 

49 

20 

20 

20 

4C 

3 

340 

2C 

30 

42 

42 

48 

0D 

0A 

31 

38 

31 

30 

20 

20 

20 

20 

20 

3 

350 

20 

20 

20 

53 

48 

4C 

44 

20 

20 

53 

59 

54 

4F 

50 

0D 

0A 

3 

360 

31 

38 

32 

30 

20 

20 

20 

20 

20 

20 

20 

20 

53 

48 

4 C 

44 

3 

37 0 

20 

20 

53 

54 

54 

4F 

50 

0D 

0A 

31 

38 

33 

30 

20 

20 

20 

3 

380 

20 

20 

20 

20 

20 

53 

48 

4C 

44 

20 

20 

41 

52 

54 

4F 

50 

3 

390 

0D 

0A 

31 

38 

34 

30 

20 

20 

20 

20 

20 

20 

20 

20 

53 

46 

3 

3A0 

4C 

44 

20 

20 

4E 

4D 

54 

4F 

50 

0D 

0A 

31 

38 

35 

30 

20 

3 

3B0 

20 

20 

20 

20 

20 

20 

20 

4C 

58 

49 

20 

20 

20 

48 

2C 

54 

3 

3C0 

41 

42 

4C 

45 

2B 

32 

0D 

0A 

31 

38 

36 

30 

20 

20 

20 

20 

3 

3D0 

20 

20 

20 

20 

53 

48 

4C 

44 

20 

20 

41 

56 

41 

49 

4C 

0D 

3 

3E0 

0A 

31 

39 

30 

30 

20 

20 

20 

20 

20 

20 

20 

20 

43 

41 

4C 

3 

3F0 

4C 

20 

20 

52 

44 

42 

4C 

4B 

0D 

0A 

31 

39 

31 

30 

20 

3B 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

157 



SYMBOLIC VARIABLES LI ME NUMBERS 

A 310 340 370 7ac or* 


A 310 

340 

370 

560 

705 




285 

80 


B 330 

340 

360 

560 

705 




290 

830 


C 350 

360 

370 

560 

705 




330 

340 


D 460 

48 0 

530 

532 

560 




350 

360 

370 

£ 480 

480 

480 

480 

480 

530 

534 

5 60 

410 

460 

550 

F 480 

480 

480 

532 

534 

560 



450 

440 


1 285 

286 

565 

580 

600 

630 



470 

445 


J 266 

286 

570 

580 

600 

620 



540 

530 

532 

P 470 

520 

590 

S90 

610 

610 

640 

650 

560 

538 


660 

680 







620 

580 

600 

T 400 

410 

690 

750 





680 

650 


X 286 

430 

440 

445 

480 

480 

705 

710 

690 

670 


STRING VARIABLES 

AS 50 

80 

820 

830 





750 

520 

640 

ARRAY VARIABLES 







580 

820 

740 


ZC) 305 

560 

560 

560 

560 

560 

560 

* 




560 


☆ 







Number 44 

158 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 



5ome Useful 
for a Z -80 


Subroutines 

Assembler 


BY JOHN W. CARTER 

Computer Systems Technology 
Memphis State University 
Memphis, TN 38152 

Language Overview 

Many new users of microcomputer systems purchase those 
systems with one predominant software objective: BASIC 
programming. Such a high-level language is certainly con¬ 
venient and relatively powerful. However, BASIC and other 
high-level languages have a distinct disadvantage in terms of 
execution time and memory usage. Two major types of high- 
level languages are now in common use: compilers and in¬ 
terpreters. 

Compilers are programs which convert an entire high-level 
source program into object (binary) code, and generate an 
object program which is later executed without aid of the 
compiler. In generating the object program, the compiler 
generates and calls object subroutines when processing is 
required. Repetition of these subroutines makes the object 
program inefficient in terms of execution time and memory 
usag;e. However, this trade-off can be more than offset by the 
convenience of the high-level language. 

Interpreters are programs which convert a high-level source 
pro-am into object code one line at a time. That is, each line 
or source code is compiled and executed individually, requir¬ 
ing recompilation for each execution. No object code is pre¬ 
served. Therefore, in order to execute such a source program, 
both the source program and the interpreter must reside in 
the memory space (usually RAM). This procedure is extremely 
slow and consumes large quantities of memory space. A good 
example of this is evident in the long looping operations of 
BASIC interpreters. For example, the execution time of a 
bubble sort of more than 1000 elements is formidable. You 
can expect to wait as long as an hour for such a sort to exe¬ 
cute — depending, of course, on the data structure. 


A solution to the memory and execution time inefficiency 
of compilers and interpreters can be realized in many applic¬ 
ations through the use of assembly language programming. 
Programs can be written in assembly language which would 
be inappropriate for use in a high-level language; the afore¬ 
mentioned sort, for example. Also, assembly language pro¬ 
gramming opens up a whole new world of data structures, 
program structures and hardware accessibility not previously 
available. Using the assembler, I/O ports, analog and digital 
converters, real-time-clocks and other useful hardware and 
software techniques are easily accessed. 

The assembler acts like a compiler, since it is one. The 
primary difference between this compiler and that which 
translates a high-level language, is that translation takes place 
at the machine level. Each source statement is translated to a 
single operation. No binary subroutines are generated (with 
the exception of macro assembly), giving the programmer 
total control over the program operation. The assembler re¬ 
sides in memory only during the compilation process. It 
generates a very efficient object code which can later be exe¬ 
cuted without the aid of the assembler. 

In order to help open up this area of programming to those 
interested individuals the following subroutines are offered. 

Subroutines 

When writing assembly language programs the first task 
involves communication between the program and the user. 
In order to do so, the peripheral keyboard and display need to 
be accessed, conversions between binary and ASCII must be 
performed, and some simple debugging tools would be useful. 
The following nine subroutines will help to fill such a need. 
They are a sample of a program library of over 60 subroutines 
written by this author for use in the assembly language pro¬ 
gramming course in Memphis State University’s Technology 
Division. Access to these subroutines can keep the beginning 
programmer from becoming bogged down in the process of 
program debugging. 


Page 34 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

159 






These program segments have been coded in Z-80 assembly 
language for use on the TRS-80 microcomputer. However, 
these can be easily translated for use on almost any mini or 
micro. 

The following is a summary of the subroutines given: 

Subroutine AINPUT. This subroutine will scan the key¬ 
board of the microcomputer for an ASCII character, and upon 
the execution of a wait loop, places that character in the 
accumulator and returns. The subroutine also echoes that 
character to the video display by calling subroutine APRINT 
prior to the return statement. This subroutine will require 
modification for use on any machine other than the TRS-80. 
In order to do so, design the subroutine structure such that it 
places the ASCII character in the accumulator prior to the 
return. 

Subroutine APRINT. This subroutine is the converse of 
AINPUT. It takes an ASCII character in the accumulator and 
prints it on the video display device. This subroutine will also 
require modification for use on any machine other than the 
TRS-80. 

Subroutine REGDMP. This subroutine provides a labeled 
hexadecimal dump of registers A, B, C, D, E, F, H, L, IX and 
IY. The technique used is by no means the most efficient in 
terms of memory usage, but it is very simple to implement 
and interpret. It can be placed within a program at any point 
(or points) and a dump of the registers will occur at that point 
in execution without affecting the contents of any of the 
registers. This subroutine is not personallized to the TRS-80. 

Subroutine OUT16H. This subroutine provides a hexa¬ 
decimal dump of the 16-bit contents of the HL register. Any 
register pair can be dumped by this subroutine. For example, 
the DE pair can be dumped by executing the following se¬ 
quence: 


PUSH 

HL 

; save data in HL from destruction 

PUSH 

PP 

; pp is the register pair 

POP 

HL 

; put that pair into the HL pair 

CALL 

OUT16H 

; dump it 

POP 

HL 

; restore old HL data 

Subroutine 

OUT08H. This subroutine provides a hexadec- 

imal dump of the contents of the C register. The contents of 
any register can be dumped by executing the following se- 

quence: 



PUSH 

BC 

; save data in C from destruction 

LD 

C,r 

;r is the register to be dumped 

CALL 

OUT08H 

; dump it 

POP 

BC 

; restore old C data 


Subroutine BINASC. This subroutine converts a four-bit 
binary value in the accumulator to its ASCII hexadecimal 
representation, and places that ASCII character back into 
the accumulator. It is used in all printing and register dumpmg 
routines. 

Subroutine IN08HX. This subroutine waits for and receives 
two ASCII characters from the keyboard (using AINPUT) and 
converts those two characters, assumed to be in hexadecimal 
representation, into the 8-bit binary equivalent. The binary 
value is placed in the accumulator prior to returning to the 
calling sequence. 


Subroutine ASCBIN. This subroutine is the converse of 
BINASC. The subroutine takes as ASCII character in the 
accumulator and, assuming that it is a hexadecimal value, 
converts it to the equivalent four-bit binary nybble. The 
resulting nybble is placed back into the accumulator prior 
to the return. 

Subroutine BMLT08. This subroutine was included to 
enable the beginning programmer the ability to multiply 8- 
bit numbers. This subroutine will multiply two 8-bit signed 2’s 
complement operands and produce a 16-bit signed 2’s comple¬ 
ment product, using Booth’s algorithm. In order to provide 
an efficient execution time, the registers were assigned as 
follows: The multiplicand and multiplier are placed in the C 
and D registers, respectively, prior to execution. After the 
subroutine is called, the most significant byte of the product 
is in the accumulator, the least significant byte is placed in 
the D register. The registers can be reassigned to provide more 
convenient use at the expense of execution time. 

Program BMLTST. This program was written to test each 
of the subroutines. The input routines are used to accept hex 
operands, the multiplication subroutine then generates the 
product which is consequently printed. The registers are 
dumped prior to and after the multiplication routine. An 
example of the printed output is as follows: 


FE+FE 

= 








: 

Fi B 

C 

D 

E 

F 

H 

L 

IX 

IV 

j 

2D 08 

FE 

FE 

00 

FF 

00 

11 

4015 

FFFF 

1 

Fi B 

C 

D 

E 

F 

H 

L 

IX 

IV 

S 

80 00 
0004 

FE 

04 

00 

FF 

00 

11 

4815 

FFFF 

j 

: 


44+44- 









S 

fi 

6 

C 

D 

E 

r- 

r 

ri 

L 

IX 

IV 


2D 

00 

44 

44 

00 

FF 

00 

84 

4815 

FFFF 


fi 

o 

1_‘ 

c 

D 

E 

F 

H 

L 

IX 

IV 


12 

80 

44 

10 

E8 

FF 

00 

84 

LO 

■H 

,r 1“ 

FFFF 

t 


I 1210 | 

•.i 

The aforementioned subroutine library is available from the 
author. For information concerning the remainder of the lib¬ 
rary, send a self-addressed, stamped envelope to the author 
at 4932 Shifri Avenue, Memphis TN 38117. The complete 
source list and cassette tape will be made available for a dup¬ 
lication and handling fee of $10. Indicate memory size in 
any requests (4K, 16K, 32K). 

Mr. Carter is an assistant professor of computer systems 
technology at Memphis State University and is actively in¬ 
volved with the development of micro and mini software, 
hardware systems and computer-aided instruction. Memphis 
State University offers a baccalaureate degree in Computer 
Systems Technology; a curriculum which emphasizes the 
hardware aspects of computer systems, as well as programming 
using compilers, interpreters and assemblers. 


Number 44 
160 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 35 








3 







0 

3 



CC' 

O 



1 

O 



U) 

X 



tt 




h- 

UJ 




I 



¥ 

1- 



1- 

u 




o 



_l 




_l 

in 


* 

£ 

t 


f 

O 

2 


* 


UJ 


4 

o 

y- 


4 

H 

z 


4 


o 


4 

in 

o 


* 



o 

4 


UJ 

UJ 

4 

UJ 

I 

H 



H 

O 

h- 



Ul 

Z 

H 


x 


b 


u 

Cl 

o 

ui 

X 

u 

u 

z 


<r 

U 


UJ 


3 

h- 

X 

UJ 

in 

D 

X 

z 


O . 

in 


in 

X CO 

z m 

J— 


UJ 

O cl 

b 

X 

> > 

►h ui 

p 

i- 

X X 

j— (_ 

u 


-1 _J 

— in 

Ui 

u 

u u 

z — 

3 

o 

in in 

« o 

in 



U UJ 


UJ 

CO 0 

UJ x 

* 

Cm 


0 

4 

O 

CL UJ 

O 

4 

u 

Ul CL 

X z 

4 

£ 

1- X 

UJ 

4 


CJ 

H 

4 

CL 

X X 

in 

4 


CL O 


i 

UJ 

X h- 

id 

4 

I 

X X 

UJ 

4 

I- 

O _l 

X 


GmSOSiOOSOOO 
CO N CO C6 ® H CsJ M TT 10 
WI0«DNNNNNN 
rHrHrHrHrHrHrHrHrHrH 
OOOQQQQQSO 






X 








z 








_J 








0 








X 

X 






in 


X 






X 







X 

UJ 


X 




in 

UJ 

h- 






X 

H- 

in 


X 




UJ 

O 



Cl 




y- 

X 

CD 






in 

X 

UJ 


> 





X 

X 


o 




cd 

X 



X 


X 


UJ 

CJ 

UJ 

4 

X 


0 

X 

ft 


X 

4 



K 

0 


»— 

o 

4 

o 


<J 

V— 

Ul 

z 

*- 

4 

1- 


X 

o 

> 


in 

4 




X 

X 

X 

UJ 

4 

w 



> 

in 

X 

X 

4 

*-> i/i 


1- 





* 

X 



y- 




4 

X X 


X 

0 




4 

Z K- 


K 

X 





m 


0 

H X 




X 

1- H- 


0 

0 CO 





0 0 



0 0 




5 

0 X 


X 

1- 




0 

X X 


K 

X 0 




UJ 

0 


■X 

y- 0 




X 

0 0 


0 

X 





in z 



0 




UJ 

m - 


H 





z 

'LL 

0 


K 





m x 

Z 

0 



X 


J- 

•— 0 

0 


0 

• UJ > 

FS 

> UJ 

_J 

X 3 

►1 

0 

1 

0 0 


*-• 0 

o 

H 

H 

r-t 

0 0 

UJ 



X 

0 



X 

l/l 



0 

X 0 



0 

D 



0 

O 1 



0 H 




in 

N 

X 


Z 

m uj x x -i 



X 

X 


0 — 

uj z in in -J 

X x 

►— 4 

m z 



X X 

z O 0 0 X 

o o 

UJ 4 

0 X 


X 

Z X 

- z Cl ll U 

X X 

X 4 

X y- 

X 

X 

CJ - X 

r- 



4 

X 

X 


1- 

0 



4 

0 X 

H 


0 

9 



4 

X X 

in 


o 

x z 



4 

1- 



X 

CO -* 



4 

X 

0 


0 

9 



4 

X X 

X 


0 

in x 



4 

h- o 

X 


0 

X 



' ' ' 

' ' 

' ' 

-■» 

•% ■*. 1 

G G G G G O 

0 0 

0 0 0 0 

0 0 0 0 

0 

0 0 0 

VO N CO OG H 

CM M 

rt to io r- 

0 <T, 0 -H 

CM 

n’t to 

N N N N CO CO 

X 0 

CO CO CO co 

co 0 cr. cr. 

cr. 

0 a. 0 

” H rt H H 

n 

H rH 

H H rl rl 

rH rH 

rH rH 

H 

H H rl 

Offi G 0 0 0 

0 0 

0 0 000000 

0 

0 0 0 


_J 

X 


0 

CJ 

0 

X 

X 



Q O O 

vo r>- oo 

CT, <T. O'. 


X 


0 z ~ 

X 


« CL 



0 X H 

0 


K 0 

z 


Z 0 



o X 

1C 

X 

X o 

X 

o 

H 0 

0 


— 0 

3 


X L/l 



1- H X 

X 

►H 

Z 0 X 

> 

CJ 

~ Z 0 

X 

0 

X X 0 

0 

<E 

X J X 


CL 

h* 

in 

H O 
X Z UJ 

C. w | V| CxL 

X <9Q£M , 

0 -J X O -.Cl -. _l 

0lCC0CT<roi 


CG X X X -J 

Ll in in in _j 

UJ DDDOICiQ 
0XXX_IO_I_I 


(XL 

QQQSQQGQ 
CT, 0 H CJ M t tO CO 
(TiGGOGGGG 
H OJ OJ CO CM CO CM C\J 
Q G G G G G G G 


to cn -h 

UJ (A UJ 

to Cl 0 0 H CT. 
u lL U U. u U 

rt to n x o 0 

UJ UJ Ul UJ UJ UJ 
UJ UJ UJ UJ UJ UJ 


HGG^GGC4GQi 7 iGG f GQin 

CM CM , T CM CM 'T CM CM CM CM T CM CM ”T 

UJ X 0 rH CM (A *t to c$ r- CO O'. CC CQ (J 0 

UIUIU.LlU.LlU.LlLlU.U-Ll UUUU 
UJUJUJUJUJUJUJUJUJUJUJUI UJ UJ UJ Ul 

'ttt'tt’ffr’r’t’t’t' *t *r t *t 


000©OO00©Cn0000<r. CT. 0 
CM OJ *r CM CM CM CM OJ ^ to CM CM CM *r to o 

UJ U 0 rH OJ tA rt tO '0 t- CO OV CC CG O 0 UJ 

UU G O G G G Q G G G G G G G G G 

LUUIUUUUUUUUUUUUUUU 

'T't't^t^t^trrrtrrrt’Tyr^T^r’t^trt 


rf H 
UJ OJ 
0 UJ 
o o 


rH rH 

u u 
* 


UJ 

rt 

UJ 

Ul 

H 

CM 

<T, 


rt 




0 



> 

> 



0 





















in 


in 









X 

X 











X 



X 

X 



X 





















X 


X 





o 




X 












z 



-1 

-J 

X 


X 





















X 


X 



X 





o 

1- 















X 

X 



O 

















> 



> 

H- 

X 

i— 



X 

> 

h- 



0 


CD 











H 


0 

0 

0 

X 


/A co 

















X 



X 

ICi 


ifi 

y- 

y- 

I 

X 

X 



1 

o 

X 











0 


X 



X 

X 

X > 

















0 



0 


X 


CJ 

o 


0 

0 



in 

y- 

X 







X 




P 


X 

0 

0 


A X 

X X 





0 












X 



X 

CD 

X 

a 

3 

Z' 

z 

X 

Zi 



X 









X 




X 


Q 



X 

x y~ 

0 1C 





0 












m 



in 

X 


X 

0 

0 


X 

CJ 



H 

X 






0 


X 




0 


X 

o 

X 

X 

X 

0 





1- 













Q 

0 


X 


X 

o 

o 



0 




X 

z 




X 

X 

X 

X H 




0 


> 

X 

X 

►“ 

J— X 

> 0 





0 












0 

z 

z 

0 


0 


X 

X 

1- 

0 

X 



X 

h 





X 

£ 

X 

X X 




0 


X 

0 

y- 

0 

0 X 

Z 0 




X 

z 









X 

X 



X 

X 


CD 


CD 

X 

X 

CJ 


a 



X 

O 





X 

3 

y- ll 

H- •-« 






1C 




— X 

1 




0 

0 

0 








X 

X 


z 

o 

CJ 

z 

z 

X 




Zi 





y- 

X 

X 




h- 

X 

u o 

O CD 




X 



> 

z 

0 

0 x 

> 0 




r- 


0 











o 



o 




X 

X 

0 S 

O 

X 




X 

X 




X 

> 

X X 

X X 




I 

> 

0 


o 

X 

X CJ 

X X 




o 

z 

y- 

CO 







0 

0 



0 

0 s 



ll 

1L 

o 

o 

O X 


X 



0 

X 

1— 





X 

X 0 

X X 




H 

X 

0 

0 


X 

X 

X H 




X 

o 

-i 

0 







X 

X 

4 

r- 

x 

X || 

y- 

X 


X 



X o 

1- 

X 



J 

X 

u 




CD 

1L 

X 

X 





X 

1 

0 

0 







> 

X 

z 

r- 














5 

»- 

O 

X 

X 

X = 


y- 

4 


£ 

CJ 

£ 




X 


X o 

X X 




h 


0 

1 

X 

X 

X -« 

Z 





X 

0 

0 







y- 

K 



y- 

K " 


3 

CJ 

3 

y- 

1- 



o 

4 


o 


X 




X 

X 

(J CD 

CJ X 




0 

1- 

X 

0 

X 


o 

0 0 




y- 



z 







0 

0 


H 

0 

0 M 

y- 




> 

■»- 

y- -i 

H 

z 

4 



X 

£ 

X 




X 


O 


4 

0 

X 

X 

K 

X 

h 

X 

X 0 

X 




D 

X 

0 

0 







0 

5 


Z 

Z' 

z> — 

z 

X 

0 

X 

X 

X 

z - 


X 

4 


o 

X 

X 

o 



X 

p 

y- 0 

O H 


4 

N 

y- 

0 


y- 

0 

o 

o X 

O X 




X 

0 

y- 








z 

z 

O 



z o 


z 

o 

z 



— CJ 



4 


y- 

y~ 

o 

y~ 



> 

X 

X 

X X 


4 

0 


s 

Z 





V- 

X 



r- 

y- 


o 







ii 

ii 

a 

X 

7 

ii in 

X 


X 

3 

X 

X 

X X 

X 

o 

4 





CJ 



X 

H 

X X 

CJ X 


§ 

rH 

o 


Cl 

z 

0 

z 

Z 0 

0 

X 




0 

y- 

1- 







X 

0 

X 

X 

<r 

O X 

X 

0 

X 

0 

z 

0 

X X 

X 

0 

4 


X 

o 

X 

X 



X 

X 

y- -« 

X X 


4 


y— 

1- 

X 

0 

X 

o 

o *- 

X X 




o 

X 

-> 























4 



X 

X 

> 








4 

X 



X 


X 



X X 





> 

X 

1- 






















4 



o 

H- 









4 

z 

0 

0 


X 


y- 

y— x 

y— y- 

0 



i- 



Z' 






















4 


X 

X 


y- 








* 

0 


1 

X 

X 

0 

X 

X -J 

CJ o 





t 


X 


y- 

z 

Z 




















z 


CD 

p 








4 

*■> 


0 

X 

►— 

0 

I- 

y- x 

X X 

H 



X 





z 




















y~ 



0 

Z 

X 








4 




1— 

CJ 

1 


Z 0 

X X 




z 

X 

0 




0 

0 


















Z' 


y- 



z 









in 

X 

z 

u 

X 

N 

X 

X > 

X X 

0 




y- 




X 

g 

g 


















X 


— 1 

X 

X 









1- 

oi 

X 

X 

X 

X 


0 

0 Z 

X X 

1 




_i 

■T 

X 


X 

a 

uj 


















z 


S 


o 









0 


CD 

y- 

X 

X 

X 

X 

X 

CJ CJ 

CO 



X 

0 

0 

X 


X 

X 

X 




















x 


h* 

X 








1- 


o 


X 

I 

0 

X 

X > 





X 









X 
















X 


X 

ui 

X 

X 





X 



0 


X 

X 

CJ 

CJ 


X 

X X 

M X 

0 



y- 

f- 

0 

0 






5 


















3 

z 


y— 





z' 





X 

0 



X 

X 

X X 

— X 

y- 



u 

0 

X 

X 






0 

X 



H 

x 


y- 

X 

CO 

X 



I 

1- 


X 


X 



■ o 






1- 


X 



CD 



z 

X 

X z 

(J X 



0 

X 








X 

to 

I 


I 

z 

i 

I 

z 

z 

0 

z 



VO X 


H 

z 



y- 

> 

X X 





X 

z 




0 

X 



5 



0 

y- 



X 

0 

y- 

y— 





cr. 

rf 

5 


'X 


0 

0 


0 

y- 




*H 0 


X 



X 

x 

X 

Z X 





X 






X 

CJ 

CJ 

0 

X 

X 0 

X 0 

X 


0 

X 

o 

_i 

0 





X 


8 

X 

CM 

X 

8 

X M 

X 

a 

0 

3 

X 


H 0 

X 

X 

H 



o 

0 

O X 




X 

X 

X 


X 


I 


l/l 

0 


X 

X 

3 

X 



X 

x 







X 

X 

z 



X 

z 


X 

X 


X 



Zi 

X 

1- 

D 


I 

X 

X 

*- I 



X > CG 


X > 

X 

X 


1- 

0 

X 

X 

X 

I 

x r- 

1- 1- 

:> 


y~ 

0 

X 

z 

z 





■Lf 

in 


0 

X 

X 


CJ X 

X 

X 

X 

X 

I 

J 

O X 

X 

X 

o 


1- 


X 

y- o 

0 


0 - 

CM 

X N 

X *-• 

0 

X 








X 

X 

z 







X 





















X 



X 



X 







p 


X 

X 

1- 

1- 

r- 

y- 

1- X 

x y- 

O 







Ui 





















0 


X 

X 

0 

z 

a 







X 


o 

J— 


z 

z 

z 

z :> 

> b 

o 







D 

:< 

co 

i 


















D 


0 

p 



D 

1- 






X 



0 

X 




- z 

z X 



lL 






i 

0 

0 


















X 



X 

o 

X 


z 







X 

X 

o 

z 

X 

X 

X 

X o 

0 Z 

Cl 


X 





in co 

i— 

rH 



0 



0 

0 


0 

0 

0 

0 



0 

0 




X 

h~ 

X 

X 

X 


X X 

X 


_J 


4 

X 

0 

0 


X 

X 

X 

X CJ 

o -« 



Cl 





x 0 

0 

y- 

o 


0 



0 

0 


0 

0 

0 

0 



0 

0 


4 


a 

X 

0 

0 

X 

X 

X X 

X 


_l X 

X 

4 

r~ 

0 



V 



V V 


X 




0 



z z 

z 

b 

X 

0 

X 

0 

0 

X 

X 

0 0 

£ 

£ 

£ 

£ 

0 

0 

X 0 

X 

X 

4 


o 




z 

X 

Zi Z) X 

X X 

X 0 

3 

4 

X 

X 










X 

X 

X 

0 

0 



0 

0 

o 

0 

CJ 

0 

0 

CJ 

CJ 

0 0 

CJ 

CJ 

CJ 

CJ 

0 

0 

CJ 0 

CJ 

•“> 

4 


X 

0 

> 

X X 


X 

X X CJ 

o *-> 

CJ X 

X 

4 

X 

X 










X 





y- 





















4 


X 

X 


X 

y- 







4 

o 


0 

1- 

y- 

X 

X 

X CJ 

Z X 



I- 





D 





















4 


3 

£ 

0 

K 

b 







4 


X 

0 


z 

z 

0 

CO 0 

— I 



0 





0 





















4 


X 

Q 

CO 

X 

o 


K 

X 




4 



1- 

X 


X 

H 

0 X 

0 0 








X 





i- 
















4 



X 

1 


X 



z 




4 

3 

X 

X 

z 

X 

0 

1- 

►- Z 

0 O 



0 





X 





X 
















4 


X 

> 

X 

CD 

X 


X 





4 


X 

z 


X 

X 

3 

1) — 

0 Z 



X 





3 





X 
















4 


X 

X 

X 

X 

5 


z 

X 




4 


*- 

0 

X 

X 

X 

O 

O 0 

X •- 



X 





in 





y- 
















4 


y- 

LL 

►— 

X 

X 



X 




■» 



' ■> 

•' 


■' 

'*'■ 

•v 






•' 

■* 



a 




in 


















r. 

*'• 



* 


X 

-1 




0 0 0 

0 0 0 0 

0 

o 

0 

0 

0 0 

0 0 

0 0 0 

0 

0 

0 

0 0 0 

0 

0 

0 0 

0 

0 

0 

0 

0 

0 

0 0 

0 

0 

0 

o 

0 

0 

0 0 

0 

0 0 0 0 

0 

0 

0 0 0 0 

0 

0 0 0 0 0 

0 0 

0 0 

0 

0 rl CM 

<'\ *r to lo 

r- 


0 

0 

H CM 

m -r 

to 

■O N 

0 

cr, 

0 

H CM rn 


n 

0 N 

co 

8 

8 

rH 

(M 

M 

t to 

^0 

N 

co 

Cr. 

z 

rH 

CM M 

rt 

IT. LO N 

00 

K 

8 

h cm rn -«• 

n 

VG N <X> X 0 

H CM 

n 

8 

0 0 0 

0 0 0 0 

0 

0 

0 

rH 

rH H 

H rH 

H 

rH 

rH 

H 

H 

■‘M 

CM CM CM 

CM 

•-.j 

CM CM 

'-•j 

CM 

n 

I'l 

m 

cn 

m rn 

m 

M 

M 

(A 

rt 

T 

rf rf 

rt 

rf 

rt 

♦ rt 

to 

to to to to 

to 

in to in to 

lo 

V0 X 

LO LO 

X 

H 

H rH 

H rH 

H rH 

*H 

rH 

rH 

rH 

H H 

rH 

rH 

rH 

rH 

H 

rH 

H 

H 

rH 

H 

rH 

rH 

rH rH 

rH 

rH 

H 

rH 

rH 

H 

rH rH 

rH 

H 

rH 

rH 

rH 

rH 

rH rH 

rH 

rH 

rH rH 

rH 

rH 

rH 

H 

rH rH rH 

rH 

rH rH 

H rH 

rH 

rH rH 

rH rH 

rH 

0 0 0 

0 0 0 0 

0 

0 

0 

© 

0 0 

0 0 

0 0 

0 

0 

0 

0 

0 0 0 

0 

0 

0 0 

O 

0 

0 

0 

0 

0 

O 0 

0 

0 

0 

0 

0 

0 

0 0 

0 

0 

0 0 0 0 

0 

0 0 0 0 

0 

0 0 0 0 0 

0 0 

0 0 

0 



to 

X 



X 

X 


X 

X 

X 

X 



X 

X 

X 

0 


X 



rt 

rf 



t 

rt 


rt 

rf 

rf 

rf 



rt 

rf 

■<r 

8 


rt 



0 

X 


X 

rt 

X 

Cl 


X 

rH 

X 



CM 0 

rt 

cr. 

to 0 

CC 

rf H 



0 

X 


CM 

X 

X 

(A 

X 

0 

X 

0 



cr, © 

X 

cr 

X M 

X 

X X 



H 

X 

N 

X 

0 

0 

X X 

0 


0 

0 

N 

•r 

0 X 

0 

tA 

in 0 0 

N CO 

0 0 

rH 


(A 

o 

in 

(A 

CJ 

CJ 

rf (A 

CJ 

CJ 

CJ 

CJ 

co 

co 

O (A 

CJ 

CJ 

0X0 

0 CM 

O X 

0 

X 

9t 

CJ 

X 

0 

CM 

in 

0 cr, 

0 

X 

rH 

rf 

N 

co 

cr, cj 

X 

rl 

t to N 

•X 0 

0 0 

CM 

X 

X 

£ 

£ 

B 

X 

X 

0 0 

X 

0 

CJ 

CJ 

U 

CJ 

CJ CJ 

CJ 

0 

0 0 0 

0 0 

0 X 

X 

X 

X 

X 

X 

X 

X 

X 

X X 

X 

X 

X 

X 

X 

X 

X X 

X 

X 

XXX 

X X 

X X 

X 

rf 

rf 


rf 

rf 

rf 

rf 

rt rt 

rf 

rf 

rt 


-t 


rf rt 

rt 

rt 

'T ^ rf 

rf rt 

t ^ 

rt 


Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

161 






X 


> > 

a: <r 

x _i 

Cl CL 

X X 

Xx-*X>- 
CL Hi CiUl Ci 

UJ h— H 

H 10 Z 1.0 Z 

1-0 —. O -H o 

►-< a a 

cd x h x h 

UJ X — x — 

CL 

IHJh 

x z z 
:> ►— 

•r UJ CL UJ CL 

X CD CL CD Cl 


-« Cl 

) -1 1.0 

I ^ CJ *-• 

i CO UJ 1.0 Ci 

«r j <r 

: E CD z 

CCi o o 
X > H 

• JZ H 

- Cli h- 

CD CO CL 

• > Z UJ h 

: z > z 


O LL > X 

ID OO 
•-> CJ H 

u. 

. X H 
H X X 
L O 'I UJ 
u Z u. > 
uj uj z 

IU. Ct o 



X 

X z 




X X 

X CJ 

X 

X > CL 

H 



X 

X X z 

H X 

CD 

H X Zi 

z 



CO 

H ►- 

Z > 

H 

X O 

o X 



X 

z o 

O 

H 

XXX 

H 



H 

X O X 

H 

_• 

IL CO 

X X 



z 

X Cl 

CL Z 

O 

X ►“< X 

X £> 



o 

X H X 

X X 


HDD 

H 




h •— :< 

H Z 

X 


. X H 

X 

X 

X 

X 

o >-• 

z 

J u E 

cn x 

CO 

X 

z 

X > X 

X X 


X Z CL 

Z CL X 

Q 

X 


X X 

Z X X 

H 

►h cr o 

O X 1 

X HX 

H 

H 

— X Ci 

O X H 


3 X 

-1 X >-0 

o .. D . 

z o 

z 

3 Cl Z 

•-•XX 

9 

CL 

HuH u 

X u o o 

o x 

o 

X H 

HUD 

U- 

X •-< X 

►-« X 



CL 

X 



x z z 
CC U I M o 
UJ H 


H O CD. C. 

►H UJ 

Z CO 

•“« _i u 

lL CO 

UJ 10 (T 

Cl UJ z 

z — 
cl x u - co 

UJ H 


cc dh 

z o -< 

CL O 

CD CD CO 


Ol- OH 

C 0 Z I X Z 

■r — x cr « 

Z CL © Z CL 

-• Cl . *-« Cl 

X <T <E O X X 


X X CT X X X XX 
Ci O O O O X X u J J H 
DZCLCLCLitl'IDZIClUJ 
XXXXXXOOXXOOX 


I J N M 

x . - 

oz a:i 


QOOOOSQQQOISQQQ OO SO SJO 

h cj ro *r to cd r-- x co <s h cm ro ^ to cd n co co q 

n n r- t- r- r-- n r - k co co co x co co co co co co co 

CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CJ CM CM CM CM 

ooooooooooooooo o o o o o 


X 

X 


X 


X 


z 

X 


z 

O X 


z 


X 


X 




X o 

X 

X X 


4 

X H 

£ 

X z 

D Q H 

4 

O Z 


z o 

X X Cl Cl X 

4 

X - 

X 

<E ~ Z 

O *-> <L <L CL 


X 

X 



4 

Z x 




4 

X X 

X 


U (L 

4 

X 



X Z 

4 

X X 

CD 

XI 

<X -■ 

4 

X > 

X 

3 

Z X 

4 

H Z 

X 

X 

-- X 

. 

■. . •. 

•. .. 

.. .. . 

. X X 


m (T| cr, o O O o O O O O O O H H H H ri H H H H H M C\l C\l CM (\l CM CM M M (M ('W ‘1 f'l 

co co ro ro co co co co ro co co co co co co co ro co co co 

OOwOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOSOOOOO 


CM CO t N CO CO U 
CO CO CO O', O', co cr. 
u U. X U. Ll x x 
*t *f *t f «t of 


XX LL UJ 

^ *f *T f V 

CD *f *f Ll *f •f 

Ll CD UJ X CD UJ 

XHXXXXOiE,Xr-JC,iXCO 
MIOOOOOOhluUU 

DHOHCMM tMOQOM 

cocoxxxxxxxxxxx 

IlLlLlLlLlU-LlLlLlU-LlLlU. 


'I CD N O 
Q CD O CO 
UJ X CD VD CO 
X X O U O 

T ID (Ti CD D 
X X X X X 
LlU-U-U-U. 
*T *T rt rf 


Z U) Z CL 

J LO O UJ 

- UJ Ci h- 

l IL K X 

- Ci Z H h 

iDDOo 

IOZuj 
: O CL . 

5 H X 

XhOlL 

- uj z cr : 

" z uj jl 

„ E O H 

- O UJ 'I UJ l 

: H CL CD o ( 

« O ( 

C O UJ o o . 

- a 5 o a c 


UJ H UJ H UJ H UJ 
1 CJ lf> O X O X O 

I I M I M CC H I 

> X CD X CD X CD X 

IKlHhUJhlOhUJKlOHllJhlOt 
J — : *-« CL *-• = mCL-<: >-• lL •-» = ► 

iHHhL)KH|-DI-HhUJ|-Ht 

z-z z ~ z z ~ z z-; 

•HUMj-HUHhHUHhHU* 
J LL i/i CL UJ CL I/i CL U CL 10 CL UJ CL 1 /t c 
JXXXCDXXXCDXXXCDXXC 


■ CL O h 10 h CL O l 

« h h : h Hi 

X > 

- >-< > H •-> H ►-< > I 

: .z z-z c, 

' H 'I -i U >-i H 'I i 

: UJ UJ CL 10 DC UJ UJ i 

. CD CL Cl CT Cl CD CL i 


X H I H 

CO X Z CO X z 

© O *-• IS O M 

IHCMiLJHCMCL 
i X X O , Zi .CL . D .CL 

iXXCDOOIIOOH 


XHIHXHXH IHXH 

COXZ CO X Z COXZ COXZ CO X z CO X z 

GO >Xi •—« o o *•* Q S H O O >-• o IS •-< (Ti o 

XHCMCL-JHCMCLi^HCMCLUJHCMCL XHCMCL-IH^MCL 

_J;J -.Cl Zi .Cl .D .Cl . D .ClCJU _I J U. u .. Z» .Cl - D .0. 

IIOO'IIuOIIOOIIOOITCD'IIIICDoOIIuOII 


CL H CM CL 
Cl X -I O CL > -I 

x — x o x <r -• x 


-j ,. , , XX_J_J_J_JX—J_J_J_J_J—J_J_J XXX_J_J_J_JI_J_JI _J—I 

^ =J ^ uj D- X i/i |/i _J J _J J 0 . 10 _J _J _J _) _l _J _J J Cl Cl Q. i/i 10 10 _j _j _j _J Co X _J j 10 X J _l X X X H 
‘-I^Z^POjJDIDIuCCDlODuXDIDXDIuIDIDXDXuuODDjiXDIuIDirDOIDiIjOIDIOD"" 
JLiHC»^Xu.u.XJOJ(jJCjJOXXJOJOJOJOJCjJCjJOJOXXXXXX_jCj_jOJCJJCJXXCJJOXX(JJOX.- 


'•D X Z 

H fl H 

H O X 

Zi . X CJ X _l 

O <L X CD X X 


10 X J -JUIX-J —ILLLLLLr— 
DuIDXDO ID X u D O U 
ClClO JuClCL O-JOX.-XX 


UJ XUJXUJ XUJXUJXUJXUJ XUJXXXUJ XUJ 

If ’t rf rj- f f ^f •t’f’f’t Tj- >T ’T rr ’T ’f'f 

7 ; :-0 u ? T 1 -i o *t iZ. X> f iD O f uSt u O t DO t iZ S' *T LD CM O f b'J CM Ci ’f 

, . I" , A A t , 'Ti CM Ud CA CM UJ CO CM UJ CO CM UJ CO CM UJ CO CM UJ CO CM X CO CM X X CO CM X X CO £i X 

^^ l PS^ UJ H ,Hli,)t - l ^ LlJ ‘-'^^XDXDXOCCiDXDHHHb:'L‘jli'JijDXuuuXDDHDXuiDHiDLlJuH'HHC0| 

NOCMOCMOXXOfOMCJfCjfOUXXfOfOO’fOfOOtOfOOfOMUOlLXXU.OfCJi'OtjfCJfOtjDXCjfOCJlLXUMOOlLUlCj 

O D O ^ CM f ID ^D T- CO J, (j X H CM ID N (E lCi Cj D O CM li'MD CO CCi X II Cd f N CO O D O H CM M f liD ID N CL u U. O CO Ii'j CO T Cli X O M j,-j CD CTi CO X X O H 

H H CM CM CM CM CM CM CM CM CM CM CM fO fO i'O fO fO fO fO i'O tt t t f 'M' t L"j I'J 10 M 10 10 CD CD <D CD CD CD CD Cjj cjJ ijj CD f- N N T- t- f- f- CO CO CO CO CO CO CO CO CO CO 

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X X X X X X X 


Number 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 37 



o 

in © 
LU © 
© Z © 
Ui — D 
> H © 
O D © 
O H 
© © 

O lCi c. 

D Z 
© © © . 
_l i 

© o a : 

Z CO UJ - 
© I Ci - 
XNZI 
© X © . 

© H 
Z CO X I 
© I © i 
© 

in © © I 

lli : 

Cl i 

© ui i 

© >- ^ : 
Z — Q 1 
Hina 
h Z ll 
D UJ 
Oh> 

axu: 

LU UJ 'I 


0.0 
O Z - 
O H 

. — a: 

X h E 
UJ CE © 
I JO 
D © 

. a. z 

_i *—< *—< 

© z 

Z © © 
- Z O 

o © 


CE . 

. Ci in 

) UJ 

> z 

■ © 

) O H 

. z d 
■ UJ o 

> s © 

> LU 

i © in 


© © 
<r uj 

ui H 
CD Ui 
— CE 
_J O 


00 

m 


© Z CL © © Z 

Z CxL H 

H 

© — Z Z © 

© 3 © 

© 

© _j — — 



o Z CJ z 

ID H X © 


— © . © o 

O © — 


a x © d o 

© I 


z © H z 

Cl CM © 


— © u u it 

moMZ 

O 

HZ — Z © • 

D X © © 

z 

© — H © X O 

© U Z 

© 


o ce : 
in ui ui < 
— co co . 
id-. 


■ in . 


i > o 

i Ui UJ 
II>H 

I z z — 
: - a: Ui 

illl E Z 


© © G © 

r - co <x. q 
O O O H 
T ”*• ’t’t 
© © © © 


© © © © 
H CM M ’t 


’t "T ’t 
© © © © 


©©©©©©©©© 
ii r- co a! o h cm rn in 

H H H H H CM CM CM CM © 

©©©©©©©©©Ui 

Ui 

© 


C\l U CTi t © N ill t U O UJ f>- CM rl U. ’TUJJl 
JIlLlLUJUIljiXiiLCTiHUJCC^UJ© uj © ce 
©©©©©©©©©©©©©©©©© © © © 


HHHH£DZ©CJXCi©©HlCO© l-X 
CSDJJJO — Z © CO CD H Z D © Z Z X H 
(TiSEEEEIOCDh CE © UJ ITi — © H H Ci — © Ui 
©GCOlQCOlO©(JiXiZH©CD©ZH -J CD Ui©CE 

©oicoc.©©©© — d © © © — j euj © z h 
’ to©©©-J-J©_iL0o_i©_i©ocn© ce — in 



(J JO 

m ce 

© z o 

— H 
u O 
Z UJ o 
h ui I 
CE O 
H X UJ 
UJ UJ 
O I Ui 
UJ 

O H 

h c. © 

ui CE 

in a: 

- o > 

CO Ui 
UJ > <E 
Z UJ z 

- iZ — 
H CL 
D © 

O CO H 
ui I — 

© in © 

- Ui • 


in y 


© 


l/i © o 

Hlh 
I H 

y— z 

z © 

© O I 
Oiil- 
ll. 

© H 

in in ui 

O Ui © 
© © > 
©HZ 
D O O 
Cl © O 
© 

© I Cl 

I I z 
h o © 


CE 

in © 

Z CE 
O I 
— O Cl 


© © © 

Cl © o 

z © 

© CE — CE 

© H 


© 


© 


X — 
© © © © 

© I © o 

H y- Cl 

o o © 

*i y- - © 

© © o © 

© «r — © © 

© x — © o 

y- o o © 

© © o © 

— — ac 

CD — Z O 

© O H — H 

© © © 

© © © H 

© :> o © 

>hz©- 

© © O _J I 

woo©© 


_J X I 
cu © © i 
CL X © ' 


x y- z i 

© © I 
Z © © I 
> o I 
HZ©' 
© O © I 
OuEi 


D - 
© CL 
Zul 


© © 
z o 
• © 


CO©©CJCJCJCJCJ©©o 


I —J —J -J -J 

© _J _i © © © © _i _i 
DCEIOJJ_JJCCCE© 
©OuJWWWWOOO 


© 

h 

CJ . 

CE © 
© © 
CE © 
I © 

o > 

z 


> © S 
© = © 
© _ = 
— — I 
CD CJ © 

© z = 

O © — 1 © 
y- -> = 


© H © 

© z o © 
> cj z :> 
z © z 
O I © o 

O CJ — CJ 


© CJ iZ 
© D © 

c. o 

©03 

© 

© © o 

Cl © 
- H _J 
> — © 


© 


© 


o © © 
y- © © 

CL © 

55 fe 

HZ 
© H © 

o — z 

0 CQO 
_l I — 
© CO © 

z 

© Cl D 


© 

© 


D 

O 


D 

Cj 

H 

© 


Q 

© 


Ci © 

o 

CJ H 

© 


O 

© 


o o 

© 

D — 

o 


© 


H 

© 

© 

C CQ 



© 

Cl 


© © 


O 

Cj 



© 

© 

H 

z 

© © 

_l 


© 


© 

© > 

o 

© _l 

o 


O 

Cl 

© z 

o © 

© 





© 

zo 


© 

© H 

Cl 

Cl 

© © 

H 

o c 

© © 


O © © 

z 

Q 

D H 

© 


H Z 

Ci 

© © 

© 

© 

© > 

g 

■» H 

> 

z 

© — H 



© 

z 

H O 

© o 

© 

tr -j 

H 

Z 


© 

I Z 

H 

u 

> © o 


© 

© © 

o 

ID 

© 

rr 

. CO — H 

© 

I 

I Z 

z 

— © 

Z Q 



© 

© Cl 



H 

I 

z 

© z z 

o 

© 



© 

H 

CD 

© H © © 

© 

© X 

© 


Z 

O 


O Z CJ © > 

© 

H © 

© 

© 

© 

5 

© H 

D - - © 


© I 

H 

CJ 


© 

CJ 

© O © © © 

© 

© 

■ CJ 

© 

© 


O D 

H CJ © © © 


> © 

© © 

© 

z 

© 

I C. 

© > — — o 


D r- 
© O © _J 

o Z D 
© z 
© © © 

© H > H 

_l > © © «. U_ 

o © © o © z 


© © 

© _J H 
© II 
© iz © 
© © 
©a: © 
© z — 


© 
CM © 

II o 

© H 


© © © © CJ © 
©H>©Q— © — 
X©LDOZX©I 


© 

o© 

i H © 


© © Cl © 

> © Ct O D O 

GO © © CD © o 




©CD©© M HNCMINI UJ 


© CJ CD 
. . I I 
© © © CJ © 


© © O © Z H C CL 

O Cl Cl Cl J Z © © © iU © © ©H ©i2iC© D© 
X J J J©tu1u J1© ©Ci ©_J©H © H 


0000000000000000000000 
in *t ui cl r- co a-i o h cm rn *r ui © r- co er. o h cm m tt 

M fO M M M M M t t t t t t t t t t yi yi UI LI LI 

m © © m m m n m rn rn © © rn © © © © © © © © © 

oooooooooooooooooooooo 



© © © © 

*r *t’t 

HHrlHtN 
Cl O CM CM CM CM d Cl 
L1CiC.U-lOHiluCOC.C 1H Her. 
OOO’fOCJOOOOOOO 

© © CM UI © GO © (J © H ^ ©ID 
OQCQOCJOOOUuUU CD 
©©©©©©©©©©© ©© 


O © O N 

© o © o 

© © © *-D © 

d © © Cl o 

r- © CL © G 

uuuu© 
© © © © © 
T ’«■ 


00 ©HOCM CU©©CJ LI CM 

O OOOO O CM H © © © 

©ID©©NID©CO©GQCOlUCOO©CQHCOHCD 
©OIONH©©CM©NCMOOHONCOH©H 

HCM' 4 -U 1 UJrv<nCQ 0 © 0 <‘M 'J-'ZiCOCr, ©coc.© 
©©©©©©©©©©©©©©©©©©©© 
©©©©©©©©©©©© ©©©©©©©© 
't rf rf -t rt rf rf Tf rf rf rf rf rf ’fr ’fr TT r|- 


Page 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

163 







A Fast Fourier Transform 
for the 8080 



BY ROBERT D. FUSFELD 

16767 Marquez Terrace 
Pacific Palisades, Cal. 90272 

The Fast Fourier Transform (FFT) is a rapid method for 
digital computer calculation of Discrete Fourier Transforms 
(DFT). To begin with, the frequency spectrum of a continuous 
random wave will be a continuous curve with real and 
imaginary components. The imaginary components arise from 
analysis of a real signal because of the mathematical necessity 
of adjusting the phase relationship of the various frequency 
components of the spectrum to give a true representation of 
the original signal. However, when doing a digital calculation, 
the signal to be analysed must be sampled at discrete intervals. 
When this is done, a modification of the calculation process 
known as a DFT becomes necessary. In 1964 Cooley and 
Tukey (Ref. 1) developed the FFT which greatly reduces the 
calculation time while giving the same numerical results as the 
DFT. These results are an interval sampled approximation of 
the continuous frequency spectrum. A good review of the 
mathematical reasoning behind the FFT calculation is given 
by Brigham (Ref. 2). Douglass (Ref. 5) also gives some useful 
comments for users of the FFT. 

The importance of Fourier Transforms is that spectral 
analysis is an extremely valuable tool in many types of 
engineering and scientific investigations. Applications occur in 
electrical engineering, vibration analysis, meteorology, speech 
recording and synthesis, music, etc. Naturally, due to the 
widespread use, many computer programs to perform the FFT 
calculation are readily available, particularly in high level 
languages such as ALGOL and FORTRAN (Ref. 2). When it 


comes to the microcomputer, BASIC programs are available 
such as the one by Stanley and Peterson (Ref. 3). However, 
in the interest of economy of memory and of computation 
time, implementation of the FFT in machine language is 
highly desireable. This was done for the 6800 CPU by Lord 
(Ref. 4). The program listed here is a similar one for the 8080 
CPU. 

This program is a direct implementation in 8080 machine 
language of Brigham’s flow chart for the FFT calculation 
(Ref. 2, page 161). The calculation is performed on 256 
points of input data and gives the power spectrum at 128 dis¬ 
crete points. The input data, calculations, and results are all 
done in single byte, two’s complement format. This 
immediately limits the precision to approximately slide rule 
accuracy with two place decimal numbers. The indexing of 
data addresses is simplified for the 256 points by using Lord’s 
suggestion of starting all data tables and the sine table on a 
page boundary. Further simplifications are made by writing 
the sine table as the sine times 128. The “MULT” routine 
then does a signed multiply and divide by 128. A “scale test” 
and “scale” procedure is done before each pass thru the data, 
during the calculation of each new data point and after cal¬ 
culation of power values. The number of times the real and 
imaginary data tables have been scaled by dividing by two is 
given in address 2277 H . However, the power values may have 
been scaled even further to prevent overflow. The power 
values at each discrete point are simply the sum of the squares 
of the real and imaginary data at that point. 

To use this FFT program the user must input his 256 points 
of real data into addresses 2400 H to 24FF H and fill the 
imaginary data table 2500 H to 25FF H with zeros. I use a Cro- 
memco D+7AI/0 board to convert an analog signal into the 


Number 44 

164 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 39 



correct digital two’s complement format. The next user’s 
step is to “CALL FFT”. The calculation takes about twenty 
seconds and is concluded with a “RET” command. The power 
spectrum will be located in addresses 2600 H to 267F H . The 
real and imaginary frequency spectrum values will be located 
in 2400 h to 247 F h and 2500 h to 257 Fjj respectively. The 
original input data in 2400 H to 24FF^ has been replaced by 
the real part of the answer. The answers have been unscram¬ 
bled as required in the FFT algorithm at the end of the cal¬ 
culation. The user can display the power spectrum on an 
oscilloscope, print out the data, or use it in any way necessary 
for his study. 

V/hat do the points on the power spectrum signify? The 
first point is the relative power at zero frequency. This is the 
mean offset of the original data from zero. If the total of 256 
data points indicate a time span of T seconds, then the interval 
between power spectrum points is 1/T Hertz. For example, if 
the original data was recorded at 10,000 Hertz then the 256 
point sample would span .0255 seconds. The interval between 
points would then be 1/.0255 = 39.21 Hertz and the last point 
would be the power at 4979 Hertz. As is well known, the 
sampling rate should be at least twice the frequency of the 
highest frequency component in the signal. 

The FFT program listed here has been assembled at 2000 H . 
The first 8K bytes of memory have been left for other uses. 
The program itself occupies IK bytes and uses the next three 
pages starting at 2400 H (768 bytes) for the data and power 
tables. If the FFT program were to be reassembled at a dif¬ 
ferent address, the first seven lines of the source listing would 
need to be changed. Some precautions will have to be taken. 
The real and imaginary data tables must start on consecutive 

O', 


page boundaries, i.e., 2400 H and 2500 H . Also, “FIN” must 
equate to one higher than the high byte of “IMAG”, i.e., 26 H . 
Finally, the location of Til must be at K+9. The program and 
sine table could be in ROM but K and the next 13 bytes must 
be in RAM as well as the data and power tables. 

For users who might want to compare this program with 
Brigham’s flow chart (Ref. 2), abbreviations used in the 
listing generally are those used in his book. However, because 
many commonly used printers (including mine) do not have 
lower case characters, there have been a few changes. K is used 
in place of k, REAL, REAL 1, IMAG, or IMAG 1 is used in 
place of Xj(k), and REAL 2 or IMAG 2 is used in place of 
x^k+N/2 1 ). 

References 

1. Cooley, J.W. and Tukey J.W.: An Algorithm for the Machine 
Calculation of Complex Fourier Series. Mathematics of Compu¬ 
tation 19:297-301, 1965. Reprinted in: Rabiner and Roder, Eds.: 
Digital Signal Processing. IEEE Press, New York, 1972. 

2. Brigham, E.O.: The Fast Fourier Transform. Prentice-Hall, New 
Jersey, 1974. 

3. Stanley, W.D. and Peterson, S.J.: Fast Fourier Transforms on Your 
Home Computer. Byte, Vol. 3, P.14-25, December 1978. 

4. Lord, R.H.: Fast Fourier for the 6800. Byte Vol. 4, P.108-119, 
February 1979. 

5. Douglass, K.H.: Fast Fourier Transforms on Your Home Computer. 
Letter to the editor. Byte, Vol.4, P.225, May 1979. 





uj 

cu Cu 

§K £ 

'X ^ 1 15 K* 'X Cu 
I- I U, X k X 
• I Cj X Lu Uj »- 
X X Cu kf X 
K- Ul Uj 4 CT 
I Q pc ^ Cj Cu <X k 
; • *g Lu Uj -- P^ X 
i I 4 2 r cci k X X Lu 
t- x 2: -4 

; CQ X X 3: Ct kl X X 
CO I— * J X I— X 

: Lu ^ Lu f— co 

i X Uj 1- .I CD 

ir k 2:, 2: 2: cu 

• x *—i f— co sc.' 
i h ►- c- Uj Uj k G 2: 
1 X CO Cu '-5 *-< Cu *- 


3: ~j -a 

+ ct >- 

oj Lu <x 

2. cu o 

Uj 

Cj L- h— Cj X ~J 

J— CC ^ L- U» l-~ X 

\ 'I *— Uj 

^ 2 Uj »— Cj Cu Cu 

X O Cg X Uj 
*—i _J Cj *■—i K~ > U k 

X 'X ^ Cj Uj X Cj Uj 

Cu Cj CO Cu 1 J CO (X 1 J 


•o L— X 1— Oj 
CO '—■ ■***"< 2 

x cu +■ 
Cj Lu Cu 2 
2; Cu cj cu 

►—, K- Cj _J Cj ►— 

c u.i u x u ijj 


'J <x, 

' 2 j I— '—i 1 —r ( 


X Cj Uj <i •: 
Cu Cu ' 4 Cj t 


r. 

4 

12 C 2 2: 

-. *—i '.j -. -. -. 

X c U. fr, X J; a: 2 ^j . 


x x: 

Uj X l -« O.j V 

' jj cuxs:^<: uo co <i s: 

+ -. - -. +• -. + - -.-+. 

; 2 a: -4 -a 2 Cj 2 a; -4 = 3 : 2 


X- Cj 2> Cu a> >; 2> *-i r-j ^ cu l —< X Cu Cu Cj 'i ; 

CQCxC|Xca.x :-c 2 Uj 2 x 2 2 x >: < 

*u2-c,CU-c_ l ~i.c_ f 4 j —I CU—| c, H ►'i'X (/; u • 


2: i co as Oj 

^ r»j i—• 2 : og h- + roi»-' + 4 4 a 

•X, in 3: CO 'X 2j -~J Oj 'Jj "Ct 2j _»2 -X ^ j j; X 2 Cj 2 Sj 3: »-i '2/ ’-i -j 

+ 4- Cj 4 2 4 4 - 4 Xj -. 4- 2j -. -. -. -. Cj >— Cj f— 

•X 2 2 2 ~4 -ct 2 2; 2 2 3: x x 2 2; a: £: 2: 2 2 a: 2: 2: a: 2: 2 X ^ co x X <x 


• X' : I X' x ►— X- 
iQKOQ j-C Cj 
; 2 : x 2 *4 —i 2 j 


x x -4 x Cu : i x *—• 
2: co cj Cj h co 4 x 


4 *^v «4 

hXX'X4-XXhXXX4 k 'C(XX4^iXiXhX , ^Xh X> 

x c c c x c o c c c -x x Q c Cj ;-i x x >c c x c x x X g g 

4 X X '-O fj CO 4 4 X X 4 Cj 4 X X 4 Cj 4 X X 4 X 4 X Cj j Cj j U 


Sj£g 

Og Og 

eg 

fg j* 

Og Og 

rg 

eg £j 

Oj Cg 

JN?-' 

cg eg 

Og Og fVj 

Og Oj Og 

Og Og Og Og In 

Og Og Og Og Og 


Og pg og 
og Og Og 

Cvj 

eg 

»-« *»» 
Og Og 

Vo k. r-> 

Og Cj r. 

R 

■•Jj X 

x 

R 

IP S 
f- ® 

ys 

r- m 

cr, to x x 
fv r-u t x 



X X 
r-v f'j r-. 

R 

R 

X X X X 


■’—t »—i *-* »—t »—* »—« »-« »—i »—• »—• »—« • ■*—« 

Og Og Og Og Og Og Og Og Og Og Og 0.J Cvg Og Og Og Oj Og O.J 


-J -4 
XX 
Uj Uj 

Cu Cu Og 


U_i Uj ‘ 
K- h- Cu Cu- 
X:2 : l Uj i 

Cl O Uj X Uj ( 
Cu X 1 J CO ' J 3 


Cu X Co 'X Cj Cj 


-4 -4 

as 

CO Cu CU CQ Cj x p 3 • 
2: -. -. -. -. -. co 
xxi3:cj-4Ujxcucxi: 


^ 2 : XT X 3 X Uj f O Ci X 

CO -. Co -- CO - JU 4 «Xi Cu -■ 

Q_ Cj 3; C. X cu Cj X Cl Cj X Cj U-r Q X CO 2 X 


-J Cu 
X K. IT; 
Cj N + 
CQ 2: Qj JU 


U: co cu Cj Cj x c;. x 


X 'X. X- Oj 
cci X Ci Cu X Ci co 


X UJ Uj X 

Uj -4 X -4 Uj 

Cu X X X X) X XXL- cu 

® Cj Cj Cj -. Cj 
X X •■* to X CO X X X CO X 


( X X 

Ct; Cl 4 4 ^ X 2> CO X X X X Cu CU 2- 
XXXXCjCjCjXCj'jjCjL-XXCj 

h^)44uu2 | L-j2CL f .0 k iHu 


X -C ^j XX 

Sr 3: Sr & 2> X X Jr*. X X X X X N -4 X X x X Oj '--j ^ Cj X 2- X' X X X N X X X ^ ^ 2> ►-» ^ X X ^ r-g ix 

8?CiSpf-ggQ&.t a ocj5?og^KiuQg335Cjog<iogo2gc,ouj :: <gci.(i.CLJ:5Cja.2Lux 

-4 X -4 -c. X r -0 } -4 C_i ) <—JXXCi j Cj CO X -4 jXXXXXXXXXCi jXXXX-4XCj jCj j *~-1 X Cj j X -4 


K? IS f'- !» 3, X Og Oj Jo 'Jj o- pj X, X Og Oj rj. to 'jj r~ CO X, X- - Og r-j T to X r - OjX,X — Og h-, ^ u- 'gj r _ Oj Q-, X —. Og T'- rj> to '-jj r-_ cox,®^ Og ro TJ- u j '■£> rv- 

S J }Q }£ £ }Q ^ is £ iS £ & ■£ o o 'o x x x x x r^- r-. r, r-« x co co o_- o: Oj co co co co 00 x, x, x, x x, x x, x x-, x xixx-xxxixxxx^^^ — -.^-.^-. 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 


iXXXXXXXXXX’ 


■3 eg ® 

pg 

X X pg 

Og X 

eg eg eg 

og 

Og og Og 

Oj Oj 

<x m a ’ 

X' 

x x jn 

X X 

in rv. -s a-. 

K. 

X x Fw 

r-« X 



X 


X X 

X 

TT 


Oj 


oj OJ 

oj 

Oj 

X 

X 

X 

X -*4 X ^ 

'•£■ — 

X 

X 


X 

*4 Cj X X 

Oj X 

X 


Co O-, Uj lo <2 K -i Csj -I- 'SJ- Lu IT' <1 IS. ^ Og Oj T’j -I U_i -a: L-- <c r--_ Lu 10 og x Og q\ <X ro U m * in 'C- 1C. U. 00 Lu f - «^| m <Si 0& —. —1 cr, —. Uj Lu Og Uj « r-j w Uj T-g 'j, ’-i 

'O in r2 Lu >2 r ~ Lu ^ Og ~ Lu - r-> tu - r- o Lu X ^ r- X - X Cj Cj ro <j fo O Cj O - CO $ r-.. ^ rj. fs. *4 o K x (J O Og K Lu k U. Lu Og fS k Cj .4 Og 

Qi <1 Qj Cj G Uj L is *-i Oj h 4 In '-n r--_ CO a-. <T Cj Xi O.i l r, C/j O-. <r on < j U O.i ir. Ln rr- (\r. In it-. ^ r.. rv. *+. 1 r.r. rr. f -. r~. 1 ___r.. r. rr. r % 1 .. <*■. rv. ^ 


Number 44 

166 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 41 



2 -J L 

t; i 1 r 

O Lu 

t: |3 © © j. 

3 -i © : 

.1 Q ^ O C 

c: •i 

' § -J >> 2 
j H <t QQ H ( 

Uj I* 
© © o i- 
■ QC - J N t 

: os 3 © 2. < 
. Co to 'J Q- £ 


; **>« i— Lu i— 

i— i 

: + © '-r © } 

■i Lu GQ lu ^ 

©©3 3 : 

- 05»— •=. o >- 

y co 3- no cl c 

*'■ 

J^isp < 

: Lu 1 j © i- 

j fv ^ L> L L ■■ 

o ^ 

- __i © © © © I - 

J <1 III Zj O LU o l 

2 O L? © © 'J © '. 


' 4 lu 
lu |u © 
-J © 

no ■>* u'i 

£g‘© 

©I Uj UD 

© © c. 2 

©3^ 

O -K 

©* h— 1—~ -J 
p-C O ST 
© 2 ©. 

*“ Ll. ^ C? 
O •—* © Ll 
i— Cl 

i- a: 

© <X © CJ 

2;Uj-jc< 

© P- 5 . I 

© lu (J Ll' 

Cl cl to to 


Lu 

rjL © 

ck'Jt ft 

lu CD ' J 

r j ^ 
2 © 
lu© 

© ~J Q 
Cl © 

cq Ci lu 

L L Oj 
2 JL 

Q © © © 

L 1 J C H 
3: 0 2 

I CO 

'■k (±. 

3p^>© 

35 to. $ 

i — i 

CO Ll Lu P 
© © CO o 


I— CQ © © 

© 3 cd © 

Lu Ci 3: Lu O 3 

3 'JK © 3 lU Cl 

3* Cl © !••- © © 3 !— *— 

a. u t cd £fc £ u -j j~ ar o 

3 ce i— 't £ £ 

pppt^Jttp K® 

I— Cl © * J ' i Lj 1 —3 © 

L L Cj L 
© ©.L»3 4:»-^l--il- *— 

zk? ;x u_ ^ z: u. _ 

H L ^ I— © *-i I—*—< © *—1 © 

C'lOluui^Oluiu 

Cl cd Cl L? Cj cd © © ',? to Cl 


s ;■! £ 'I 3C -J pjQ- ■3 £ 3 £ ^ CO ® £} Cu O £ £ £ £ in 

£ £ £ W £ CCi -J U CQ £ Cj £ CQ Lj £ 00 £ -J Cj U Cu £ £ -I Cci £ Cl! £ ~l Cu £ Cu Cj Cj £ £ Cu Cj £ CQ -j £ £ £ -J £ £: CO Cu —I 


UCLlCCitulijlu 


—I 2 2 >C >•; >C yr 

© 2 © ^ © 3 2 © 3 2 3 © -^ 3 © © © © N 2 2 S- !© 3 Cl N 3 © © 3 © 3 N cl © 3 Cl 2 3 Cl 3 cl 2 £u 3 cl rsi Cl cl Pg 3 2 © © © 

^SJ='3 ? jCi!32C|!33S^:3£;L- : p222:^:->C 5= ;2LjS:CL32$2Cj32232$2X'3 3 , 3 33C;3!333 3 22 2 3 :< 3 3 3 3 3 3 

h c. Q Ij Q - 1 u ^ U u Cj u r -D Ci u CD Cl h n h i u c ^ < r o j *u ^ j 3 j 2 3 Cl 3 OUu^S^CtuQuCiCuCj O 


't io ’■£> r ~ oo cr, © r? cy ro 3 10 ;d |v 05 or, © *-. cvj r*> in ;d r ~ 00 3 © cy ro ^ jn 'o r-~ co 3, © >*- o v - ro ^ m- to k cd a . © cy ro 't in to 
? ? ? ? ? ^ ^ ^ ifi 10 in m in in in in 'd m> to u *d'd'd'd'd *o fv r . r . ru r-_ r ■« rv r'« k r-- cd co co © «Xi 00 co cd co a-, cr , 3 , 3 , 3 . 3 , 3 


O.J cu Oj C'.J Cy Cy Cy Cy Cy Cy Cy O.j Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy C-.j Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy 
©©©©©©©©©©©©©©©©©©©©©©©©©•S^©<S ©•©©©©©©©© 


Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy Cy 
© © © © © © © iS. © © © © © © © 


r . cc 3. © -- og po ^ in 

3 . 3 . 3 © © © © © © 

cy Cy o.j 0 - ro ro m r-> pd 
©©©©•©©• © © © 


© 


-r-, 


■•—i 

© 

r-, 

© © 

Cy Cy 

cy 

cy 

og 

Cy 

Cy 

cy 

Cy Cy Cy 

Pw © © 

© 

© 

Cj © 

© 

© 

© 

© © © 

a-, © © 

Lj 

cc 

© © 

Q 

© 

© 

Q © © 


i Cl in 3 Ll CJ 3 K 3 CJ Cy © © Cy >~t CJ Cj O Cy ^ lu © '•£» Lu Cy Lu © Cy Tv 3 © Cj K © P-. Oj © ~ ’ 

j © © © '•£• © © to *—i r _ © © r-. 3 - © oj © © © Cy r-o Oui -y- 3 © K Oj © 3 © © © 3 3 © © C*.j ’ 

j y- r-, © a , 3 © © © © © © ^ cy m ^ 10 to i - 3 © © ©• —1 cy m to rs ~ 3 © © © —• cy pd © 00 1 
: 3 3 3 3 3 3 3 3 3 3 © © © © CQ CQ CCi CO © © © © © © © © © © © © Cj © Ci © Ci © © £ 

] Cy Cy cy cy Cy cy Cy cy cy Cy Cy cy 0.j Cy Ou! o.j 0.j Oj 0.4 O.j 0.J o.j O.j Cy 0.4 O.J Cy o.j Og Cy Oj Cy Cy Cy O.j 0.j Cy r 


; y- r-, 3 a-, 3 © © © © 
: 3 3 3 3 3 3 3 3 3 


. k © © © r-, 1 
: © cy K 3; © r 

, © Og I'D ^ l 

j © © © © © l 

j Cy Cy O.j Og Og t 


. 3 r> © © © 
• © Cy >-1 -^-i 


3 © © ^10 to r '-~ © 

©©©©©©©©© 


Og Og Og Og Og Og Og Og Og 


©© 

© 3 

£? 8* £ 

£ 

Uj I UJ>-lD>-£ 
ce Cu- Oe ce ® oq o 

£ I— 

I- —£~,Ujl-- 
Q Ul r -j I— Q K. 

Z ^u-u-u-5k-2 


© © *■*« LD © © 

.3 3 5,5. 

© © Lu — 2 © 2 © 

Cl 3 Qc p— •—: 3 •—< 3 

© 2 2 
OCtS^GCi'^3^^ 
© © *— 1 1— I— © © 

^ -2 

l«» Li; I—. |«. ©. Lu l~“ 

£ £.£££, 

© ©■ __J © © © K- Cj h- 

O © 3 © O © 3 ^ 3; 

© © O to © © © © to © 


cy © 

Cy Cy 3 Cy 

© © 

© © © © 3 © —J 

33© 32 3 

c_ © , 4U © *- © ~J 

^ © © ©_© © 3 

© Cy 2 © 

— 2 © 3 © © © © © 

K- © I— +k2;kk 

I 2 CO Og •—i 

2 © © © © © 
£•0 0. ■£.£&;££ 

~j -c_ 1 — © © © © © 

C © © C © © 3- ©© G 


iL ©» 

©Cl 2. 


3 © 2 © l 

© © 4- © I 

> © <Vi V 
- © 2 ©'. 
© © © 2 c 

- —| © © -U © c 

j 3 © © 3 © »■ 

3 © CO © © © C 


© © 2 © 

' © © 1 J © -jL 

1 © © i © 3 

© 2 , LL © 
. © © © © 
j © © © © © 

) CO © • J to • J 


© Oj 

-u © + 

o£ £££ £ 

© © © -. -k 

© >c —I CD 2 3 3 3 


-j 

© © © 3 

4- © —1.4- Lu 

3 -u © © 3 iL © 3 

2 -U 3 © CO ©O^ 2-u© : 


3 3 

; 2 © 2 © 2 2 © 


-. 4- -. -. -. - 4- -. © 

;'jguu2©2© 3 © © © 3 © © © -j © 2 to 


2 - : I 
© © 

Cl © 2 3 © © 

...... Qj . 

CO 2 3 co 3 © © 3 © 1 


© . © © © © © © © © © *^ L-^ © © 3 © 2 © © © © : I Q © 3 3 ©© © 2 © © © © © 2 3 © © - : X © © © © 3 © © © lu © © © © 2 © © 2 © 

©ry© ; g>c©©£!2©2©©$':I>:©X!©©©©22©©©©22©©©©©©©©©22S©©I©©!©©©©©3©:<X©3©©2©©C 
© * ^ ©532©2H2O^Ouuu2u32 k iSu32uljH32u3 22C3QuO k i2u2232u322Lj©uu2(j2 f /ih50)Q 


CD to Sc © © 

r* Jr* ?“ t © 3 © Cy PD T ln 'O P- CO cr, -s. —. Og Oj 10 K Oj O, © Cy PD T In tc P- Oj 3, •£• — Og fD T In '■£• K Oj Q\ © —. Og PD y in to K Oj CT Q> — Og PD- 

CO © 3 00 Oj Oj © Oj © O, 3, 3, 3 3, 3, 3, 3, 3, 3, O.j Cy Cy Cy Cy Cy Cy Cy Cy Cy M © PD Pd Pd Pd © Pd Pd h T* ’T’t 

2 2 2' 2 ^ 2 2 ^ ^ ^ ^ ^ ^ *- © Cy Cy Cy Og Og Cy Og Cy Cy Og Cy Cy Cy Og Cy Og Cy Cy Cy Cy Cy Cy O.j Cy Cy Cy Cy Cy Cy Og Cy Cy Cy Cy Cy Cy Og Cy Cy Cy Cy Cy Cy Cy 

© © © © © © © p: •© 3- ©©©©©©©© © ©•©©©©©©© © © © © © © © •© © © •©■© •©•©■© •©'©«©©©'© *2 ■© © © © © ©©©©©©•©© © 



2 

—• © Cy Og 3 

cy 

0g Og 

Cy Cy Cy Og Cy 

3 © 

© oo 

3 © •’*• O j © © 

p- in 

PD P- 

P-. -y* lj P- P- © 


T'S US 5 DC lu ^ CO CD © Og Oj Og Lu © © © 

P- in pd P- p- o p - P- ©1 p-. p _ p-, <1 © © t, 

lu 3 CJ ro lu Ll lu © P-. O © © Cy Cj 3 —• © 3 '£» P- O ^ 3 'U IV 3 © © 'U © 3 In © O m* 3 © O © 3 © © *-* © 3 Vj © Cj 0* : © © © Cy Lj 3 Cy Cj 

© Lj Cy Lj cy © Co p. *-* r _ Dg K © Lj Lj ^ Cy 1 Xj -~I Oj P~ —• Cy •—. Oj T*-. —« Cy . r D-- Oj T Tn Oj 'Jj r -~ Og Og PD ^ PD '■£> P- Oj ^ f’j Oj '£• P-. Lj Lj ©• Og K. Lj O- ©• © Pv ©• © 

Og r>. © CQ Lu © .© Cy PD ^ m P- 3 © © ID tO P- © 3 : 3 © © © © © © ^ Og Pd ’l* P- © 3, 3 © Lj © © © © © T In '•£■ P- CQ Lj Q S ~ ^ © Qj L C lu L ^ 

^ 'i* rr 'r ^ ^ m in m in m in in in m- © © to © © © © © © © © © p« p- p. Pw p. p- Pw k p« k p. p. p» p- © © © © © © © © co co 3,3,3,3.3 3 3,3, 3 *, cr-, 3 

Oj |>.J Oj O.j oj O.j Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj oj Oj Oj Oj Oj Oj Oj Oj oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj 


Page 42 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

167 




C •£> «S 3 0 

to -. 

Ci3:cciCciCi.<a:-a:s:Uj 


’■? cr cil 

<X o cl <X 5: Uj 


/i ll Ui 3 : lj_ co 

; <X _j -CC ■' 

to i~ o u Uj cu 

ce a ck <t i— 

• -j Lu a: yj _j j u 

• u. fc , 3llj. CO •— 

: g U. CD — 

i—rj'-.gi-a; iQ 
. =J O , I g U t- 'J Uj 

. _ Cl Lu Ll I— 

1 l —l Cj Cl , l— I— CTi I— ^ 

; Cj Uj Uj 3D Lu Ui Lu Lu >—< 


ujCQCiS:^;co<t'S<i 


'j 3 3 

lj q ft: N i cl q. u h h h cr^/j 5 cl <i ce s> <x <x 

j Ci Cjj^; Cl a. Ce u -j <: l> a. S: : Ij ^ O h <: a. <x 


Cl •q: cl cl Cj o o Ci ct: N qcl^^ s> • i cl *— 

Cl <l ^ H o H Cj Cl ' Cl Cl Cj Ct < a: <: Ct: o H Ct: 


r-. cc- ■J- c ^ cm r-s ^ (o 'o r-~ od a. «s ^ cm r*- ; t it, >. c rv os <r, Gi •— 

tv-. T’*, r*", t*- rt» rt- rt- r*. r+. rt* Tt- rt- Ir. Ir. Ir-, li-, Ir. Ir. Ir, Ir. Ii—. Ir. • r. Ir. 


: *x. ro o o 

) co % <x o u. 

j L- »-i 'Ti 'J'i 

!i CO CO < X O Ll 

j Cl US Ll '-£• JvO 
j CO CO cr-, o Ll 

. c- m Co ro ro 

j co co cr. o u_ 

j G. £ co g g 
•, co <~Jj cr, o Ll 

j —. ro cr, uj p 
• co co cr-, co Lu 

■> —. r-o r ~ eg <x 

-, oo or* cr- : co Lu 

i cm cm Lo co r-- 
-, co 'X cr-, co Uj 

. r-o r- j '.jj r-o 
•, co co cr, co Lu 

ro — c .j ro g 
-, co co o -, Qj Lu 

j TJ- G ' 2 j — Cl 
-, CO Co 0 -, CO Cj 

i lP '5 U, Lu -2 
-, CO Co Cl j -cc Cj 

. us G Cj o r-- 
-, 'X CO CO -CC Cj 

« K CD '-j -cc 'I* 
: cc- co Oj <i ci 

j os *5) -c; r-~ 

: co co <35 -c Q 

j cr- ; Ci *3j <n u. 

; Cr. CO 00 X CJ 
j Cl C< *2 - C 'Si 

j cm cm o.j o.j o.j 


cm a-, in cm co a- ; -- '■£• m in cr- : K cvj ougu.^ k o.j cj Ll cj ?■■. fv cm a-, in cm i. >~i co -o cj co Ll cj >t. 

q © *— cj Lu Uj O cj *- cm S; cj Ll k -ju.^ cm r-o t u. i u - cm r-o cm qqs-iU cm cj r -- Uj r-. cj cm rn cj 

Lu — cm ro 'c rv os a-, <s Q s- cm ro in 'c t, <i qq cj cj Uj u. cm r-o ft- jn \c- -X cc • j Ll 'S- — cm ^ in us [- *x- 

cm fo r-o c-j ro r-o ^ ro h h ’i- t ^ ^ t- ’t ’r t- t- 't’ t in in uo in in in m m in in '■& •& ’ o ’ u ' o ' o 'o 

cm cm cm cm cm Cm cm cm cm cm cm cm cm cm cm cm cm cm cm cm cm cm c-j cm Cm cm Cm cm c*j cm cm Cm Cm c*.j Cm o.j Cm cm cm cm o.j 

CM cm cm og cm cm cm cm o.j o.j cm oj oj o.j o^ cm o.j cm oj cm oj o.j cm o^i cm cm oj o.j oj o.j Cm cm cm oil cm cm cm o.j cm cm cm 


Q 

Uj Uj>- 


O Cj 

cl s: -i a -. Jo a. s; 

co co Oj .. 

i<cco— j^iClClS:o:<s 


_ Lu Uj 2: 

^ c> 

Sj o 

CJ K- h- 

CJ <x 

cr CO IJ Cl 


2 i- Cl 
rj co 
C3 Uj Ll 

Oj K 


CO 

Uj Ll Ll Uj 


Cj 3: 

"1 Cj 'Si 0.1 

Uj '■& <x cc CD CD Cj 

CO CO Cj 

j —j Cl Cl co 3c 'I os c U cd I q l 


3: 3: 

h ^ s: 3 w & r j q s ^ g Q; ^ t ck (si cl g Oj cc cl 3> cs cj 
2:Uj->co3:^3:3:3Sc^:cj3 ,: sCiS:3:2:3;3j3j^CL<:3:css-'>'3>‘Q:-j 
uc-jsc'i j'—• * j-j<2‘ : ict:S: k ~-i'~i'n'~'jCLCL-Q;'~jLj*-iciS:-js:CjCL 




'& ® o.j ro in •c co o- : cs cm ro in '•£• k os t, «s> oj ro in '-o 

•Si Gi *Si Cj >-i *-* »-i > ~i »-• »-t Cm Cm Oj oj o.j Cm o.j o.j o.j o.j ro ro ro ro ro ro ro 

ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro ro M ro r^! r^. ro ro ro ro 

CS Cs 'S; CS CS Cj C; Cs CS Cl CS Cj CJ C; C; S; *S; C- CD CS Cj CJ CS 'S CD CD Cj CS Gs CS C- 



US 

O.J 

eg »-i '-jj 

Oj 

Oj 

IT-. 

cm 

cm 

cm 

CM Cvj Oj 

CM O.j 

cm 

'Si 

ti- 

■>-. 

Ci 

C Uj C 

C Lu 

- 9 - 

•S S 'X 

Ll 

■s 

•s 

•S : Lu S' 

Lu 

O.J 

•S''S c. 


cm a, —i Uj k <c cj o cm ro Lu rv Ll r-, cj cj Cm ro in in r-- cm Ll cj Ll ' j ^ 'c u- r . 

cj cj cm r ~ -a: Ll cm cm cj o cm r-. -g: r-, cm cm cj cj • j lu -c Ll cm ro o* cd cm >— o.j <s- 

cr. tjQ®*i cm in '-js r-. -cr cj cs — cm ro m ' js 0 s . cj cs Uj Ll r M ro ^ in r-_ <s ls cs 
Ll U. L. Q O '2 G S S '3j S ’'i ^ ^ ^ ^ ^ ^ ^ ^ ^ >i C'.j Oj Cu O.j Oj O.j Oj O.j 

—, y* +-t CM 0.J CM Cm cm Cm 0 .J CM Cm Cm Oj Cm cm Cm CM cm Cm Oj CM cm Oj Og Cm Oj Oj Oj Oj Oj 

Oj Oj Oj Cm Oj Cm Oj Oj Oj Cm Cm Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj Oj 


Number 44 

168 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 43 



access addend 


algebra analog 

application ai 


level procedural language such as Pascal 
or C. On the other hand, some algorithms 
are particularly efficient and interesting 
simply because they match the machine 
structure well. Occasionally we’ll just 
mention a trick, a data structure, a gim¬ 
mick which seems to be particularly 
useful. 

Merge Sort 

The Merge Sort sorts a list of keys in- 
place in time n*log(n). It is very simple 
to state: 

Recursively divide the list to be sorted in 
half until sorted lists are obtained (that 
is, lists of length one); then successively 
merge each pair of lists until the entire 
list is sorted. 


A MONTHLY ALGORITHM 
COLUMN 

BY DENNIS ALLISON 

With this issue of Dr. Dobb’s Journal 
we begin a new series concentrating on 
the building-blocks of systems rather 
than the systems themselves. One of the 
failings of most of us is the inability or 
disinclination to take and use the work of 
others. Everyone writes his own sort 
program, his own integration program, 
and so on ad infinitum. Often it would 
be better and faster to take an existing 
program and reuse it. Of course that is 
not always possible, but often one can 
take the algorithm and adapt it easily. 

The intent is for this to be a reader 
participation column. We will publish 
submitted algorithms accompanied by 
adequate, if terse, documentation and 
(if possible) some measure of their 
effectiveness. We certainly need a test 
program drive and the results of a few 
test runs. Some analysis is important. 
One needs to know, for example, if a 
sort program runs in time n*log(n) where 
the log is base 2 or in time n'J - . 

From time to time we will publish 
reference lists of published algorithms. 
For that reason, if you find a published 
algorithm to be of use, please send it 
to Algorithms, Dr. Dobb’s Journal, 
PO Box E, Menlo Park, CA 94025 so it 
can be added to the file. Be sure to 
include a complete reference; a few 
comments would also be welcome. 

Lastly, if you can improve on an 
algorithm published here, or if you find 
a bug, we will publish corrections and 
improvements. There’s a lot to be learned 
about prog^imming from a study of how 
algorithms are constructed. 

Algorithms may be programmed in 
any convenient language, including 
assembler, but are preferred in a high 


RECURSIVE FORM 


int at 11], 1 inkC11]; 

sort (i,j) int i,j; -C int k, ii, jj; 

if<i==j) { linkCi] = 0; return(i);} 
k = i + ( < j-i )»1); 
ii = sort(i,k); jj = sorttk+1,j); 
return(nerge(ii,jj)); 

> 


tierge<i,j) int i,j; { int k; 

if (i==0) return (j); 
if (j==0) return (i); 
if(aCil>aCj]) { k = i; 

else { k = j; 
linktk] = nerge(i,j); 
return(k); 


linkti];} 
linktj];> 


NON-RECURSIVE FORM 

Merge(i,j) int i,j; < int k,n; 

k = 0; 

whilet <i! =0) SS < j!=0)) { 

if(ati]<aCj]) { « » i; i * j; j 
n = linkCiD; 
linkCi] = k; 
k = i; i = «; 

> 

if <i==0) -C m = i; i = j; j = m; > 

n = i; 

while! k != 0) { 

j = linktk]; 
linktk] = «; 

« = k; 

= j; 

> 

return(n); 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Ortnodontia, Box E. Menlo Park, CA 94025 


Number 44 

169 




The sort is obviously n*log(n) since there 
can be at most log(n) partitioning opera¬ 
tions and any merge operation can be, at 
most, n operations long. 

The program given here uses an array 
of keys and an associated array of links. 
The index value zero is distinguished as a 
list terminator. The programming lan¬ 
guage is C. The routine sort returns the 
index of the first element of the sorted 
list, call it j. The a[j] is the first sorted 
element and link [j ] is the index of the 
next element, and so forth. Sort takes as 
arguments the first and last indexes to be 
sorted. If this is a single element (the 
indexes are equal) it simply initializes the 
link field and returns as a list of length 
one is, by definition, sorted. If there is 
more than one element, sort partitions 


the list in two and calls itself to sort the 
two partitioned lists and then merges 
them returning the head of the merged 
lists. 

The merge routine merges the two 
sorted lists whose heads are given as argu¬ 
ments and returns the head of the new 
list. The data are not actually moved, 
only the link fields are modified. Again 
a recursive formulation is used. Only the 
top elements of the two lists need be 
considered. If either of the lists is empty 
then the other list is the result. If not, 
then one finds the index of the largest, 
removes it from the sublist, and merges 
the remaining values. 

As written, this program is somewhat 
inefficient since it uses a local variable to 
save the index for the merge, and it will 


recur as many times as the lists are long. 

The performance can be improved by 
using an iterative rather than a recursive 
formulation of the merge. The procedure 
is similar to the recursive one. The heads 
of the two lists are examined and the 
largest removed and placed on a list using 
its link field to thread the list and the 
procedure repeated until one of the lists 
is empty. At that point the entirety of the 
other list becomes the tail of the merged 
list. Items from the reversed list are added 
to the tail until the reversed list is empty. 
At that point the merge is complete. 
While this takes more code, it operates 
in place with a minimum number of 
procedure calls. 



Number 44 

170 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 45 



ADVERGATE. . . 



Dear Suzanne; 

If you are unable to produce Dr. Dodd’s [szc] without the 
advertisements, you very much should resign. In the great 
muddled world of the small computer, the unbiased product 
which Dr. Dodd’s [szc] Journal was prior to your editorship 
is greatly needed. Another advertiser base journal is sorely 
unneeded. 

An example in point is your advertisement for Lifeboat 
Associates. This organization represents the greatest obstacle 
to small computer software development. Almost all worth¬ 
while CP-M products are now sold through Lifeboat. Because 
of their non-support of the small dealers, these products are 
not available in the computer stores. Without the support 
of the computer store, most of these products are worthless. 

I am strictly a user of these products and am not in any 
way a dealer. I have found a great many problems in the CP-M 
packages which I do use and have spent hundreds of hours 
tiying to work these problems out without any local support 
whatsoever. Dr. Dodd’s [szc] Journal has been a great help 
in circumventing this system. Now with full page ads from 
Lifeboat Associates, you can count on the fact that you 
will now produce the glowing reports of these products which 
are worthless. 

Sincerely, Medical Central Service 

Robert C. Luckey, M.D. 471 Williams, Suite 4 

Richland, Washington 99352 

A symptom of our times, a parable of today: guilty until 
proven innocent, suspect without cause, wrong even if you’re 
right. Although I’m not quite sure what Dr. Luckey is accusing 
us of, it seems to be vaguely a general suspicion that, because 
we now have advertising in DDJ, we are guilty... of some¬ 
thing, I don’t know what. 

I should know, since everything that goes into this maga¬ 
zine filters through me: there has never been a case of altering 
anything in the magazine to please an advertiser. To be honest, 
our advertisers report unusually excellent response from 
advertisements in DDJ, and since we limit the amount of 
advertising in our pages, we don't really have to bow down to 
advertisers. We haven’t done it yet, and I hope we never do. 
I do have a certain way of looking at the world, and it does 
not include “selling out” or going out of my way to accom¬ 
modate myself to another’s point of view if it does not fit 
in with what I believe. It’s called “ethical. ’’Not too obsolete 
a word, I hope. 

I think this is really an unfair letter: it is all generalizations 
and vague assumptions. Any decent graduate school in journal¬ 
ism would give an automatic “F” to Dr. Luckey for all accusa¬ 
tions/no hard data. Dr. Luckey thinks another ‘‘advertiser 


base journal is sorely unneeded. ” Well, that may or may not 
be true, but frankly, just between us wage-earners, I ap¬ 
preciate getting my very small paycheck twice a month. - SR 

TABLE DRIVEN ASSEMBLER IN DDJ # 42 

Dear Dr. Dobb’s : 

Due to a phone call from a reader, I have become aware 
of an oversight concerning the assembler. As I have been de¬ 
veloping a number of large programs in ML-80, I long ago 
modified the compiler to substantially enlarge its internal 
tables and fix a few bugs. As a result, the assembler can’t 
be compiled by ML-80 as currently distributed by the CPM 
User’s Group ( I have sent them the mods, but during their 
year-long reorganization confusion it may be a while yet) 
due to its size. The disk I am making available does contain 
ML-80 with all my patches and will compile it. If I had the 
source of ML-80 and I had access to a PL/M compiler, I would 
have made changes that way, but I have neither. One side 
effect of the changes is that the modified L82 will not run in 
a 16K system. (It runs fine in 32K, with one small change it 
would run in 24K, but compile smaller programs.) 

Sincerely, 1522 Brockton Ave., Apt. 5 

Darrel J. Van Buer Los Angeles, CA 90025 

NORTH STAR PATCHES 

Dear Dr. Dobb’s, 

Here are some software patches for the North Star Horizon 
which might prove of value to readers who use this system. 

Two minor but irritating problems with North Star soft¬ 
ware are the use of the underline character 5FH for backspace 
and the symbol for line cancel. These are useful functions 
but why use printing characters? They also implement the rub- 
out or delete character 7FH as a backspace. If you use their 
personalization routine to change the DELECHO from 5FH to 
08H, then you enable the backspace key giving you no less 
than three different backspace commands. Also, you will 
note that the backspace 08H will not function in DOS. 

Therefore: For Release 4 Software Only 

In DOS: 263C holds the backspace character; change 5FH to 08H 

2637 holds the line cancel character (40H); change to 
your choice. I use 7FH (rubout). 

In BASIC: 48A2 holds the backspace; change 5FH to 08H 

48BB holds the line cancel character; change as in DOS. 


Facie 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

171 






497B holds the character echo for line cancel; it con¬ 
tains 4 OH you do not need to change it unless you 
want to. 

48A6-48AA implements a backspace on rubout; if you 
use the rubout for line cancel as I did, you will need 
to replace these bytes with 00H. 

In MONITOR: This Applies to M6700 

6740 holds the backspace character, change to 08H 
673B holds the line cancel character, change as in DOS. 
686 A holds the character (3FH) printed after a line 
cancel; this is the same character printed after an 
invalid command. It is probably best to leave it alone. 

This should make it possible to have a consistent set of 
function keys and to regain two ‘lost’ printing characters. 

Sincerely, 502 W. Kenicott 

Richard M. Johnson Carbondale IL 62901 


LONG AGO AND FAR AWAY 

Dear Suzanne: 

One of your readers pointed out a mistake in my article, 
“A Floating Point Subroutine Package for the 1802” in DDJ 
#37. The subroutine call addresses for floating point subtrac¬ 
tion (AC-OP -> AC) should be 02E9. It was printed as 029E. 

Yours truly, 918 Ray Avenue 

Paul Wasserman Union, NJ 07083 


INCREASING Z-80 POWER 

Dear Suzanne, 

This is something that your readers might be interested 
in which I stumbled across doing software work for a little 
firm here in Sacramento. I have since found that it is not at 
all well known. My favorite micro chip is the Z-80 (In fact, I 
think the 8080 is completely obsolete and has been since the 
first Z-80 was fabricated. So why the insistence on “8080 
compatible software”? Never mind...). The basic statement 
of what I discovered is that the Z-80 is far more than Zilog has 
seen fit to tell us. The official tally of Z-80 instructions is 694, 
according to my Z-80 tech manual. My discovery was that 
about 410 instructions can be added to that total, genuine 
useful instructions that any Z-80 will execute. Most involve 
the twin index registers, and consist of things such as “Load 
upper half of IX from any 8 -bit register” or “Load lower half 
of IY immediate”. In other words, the index registers can be 
used to a much greater level of efficiency than before. The 
other members of the new set are things such as “Shift left 
and set least signficant bit”. 

The key to the new instructions came when I finally saw 
something that a lot of people have probably seen: The object 
code for indexed instructions can be formed by taking the 
object code for an operation involving HL and tacking a 0FDH 
or ODDH on at the front end (not quite, there is a problem 
with the displacement byte, but to a first approximation this is 
correct). What occurred to me was to try tacking those bytes 
onto an instruction involving just H. So I did, and it worked! 

Some notation for the following examples: HX is the high 
byte of the IX register, LX the low byte, and similarly for the 
IY register. 


Desired 

Object 

Standard 

instruction 

code 

Assembler 

LD HX, A 

DD 67 

DEFB ODDH 
LD H,A 

OR LY 

FD B5 

DEFB 0FDH 
OR L 

ADD A,HY 

FD 84 

DEFB 0FDH 
ADD A,H 


You see the pattern. There are some limitations; it is not 
possible, for instance, to LD HX,LY. On the other hand, 
LD HX,LX is possible. The rule is that only one index register 
at a time may be referenced. 

The other type of additonal instructions I’ve found do not 
involve the index registers. On page 50 of the Z-80 Technical 
Manual, in the Op-Code column, the object codes for the 
various rotate and shift instructions are defined in terms of 
prototypical configurations, with the various codes being 
differentiated by a 3 bit field. This means that there are 8 
possible operation types. NOTE THAT ONLY SEVEN ARE 
LISTED IN THE MANUAL! The missing one is pattern 6. 
When it is generated, the results show a “Shift left and set 
least significant bit”; i.e., the operand is shifted left and the 
low bit is set rather than reset. The high bit of the operand 
is shifted into the carry, and sign and parity are affected in 
the expected manner. This one is moderately useful, also. 

Any good macro assembler can generate these extra codes, 
and in fact, the Microsoft MACRO-80 package allows a single 
macro to generate all the extra index register instructions. 
I am sure that other packages will also. Again. ANY Z-80 will 
execute them. I am on the track of a few more. Once I get 
them all, I am going to write an assembler that accepts these 
extended codes. The only question now remaining is: why 
didn’t Zilog tell us? 

I hope the above sets someone onto a better way to accom¬ 
plish a project. 

Sincerely, 8725 La Riviera Dr., #68 

Daniel R. Lunsford Sacramento, CA 95826 


A SLIGHT CORRECTION 

To the Editor: 

I would like to correct a slight inaccuracy in the article 
“CP/M and CDOS Program Compatibility”, by Jim Warner, in 
the January, 1980, issue. 

The article states “The address of the jump vector table 
depends on the amount of memory allocated to CP/M and 
unfortunately D.R. has not specified how transient programs 
should locate it.” Actually, the D.R. CP/M System Alteration 
Guide, Rev. Jan., 1978, pages 17 and 21, specifies that 
location 0,1,2 must contain 

JMP WBOOT 

where WBOOT is the address of the second entry in the jump 
vector table. Contents of location 0, 1,2 are to be set in the 
BIOS. See sample CBIOS, System Alteration Guide, page C-5. 

Code to load a pointer to the jump vector table origin into 
HL, usable in any transient program, is as follows: 

LHLD 1 


Number 44 

172 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Page 47 



DCX H 
DCX H 
DCX H 

The article was otherwise quite informative, as was the 
issue as a whole. 

Yours sincerely, 

Dr. Stefan M. Silverston 


SAVING 8080 REGISTERS IN 47 BYTES 

Dear S. R., 

In the last issue of Doctor Dobb’s the problem was pre¬ 
sented of saving all the 8080 registers in 58 bytes or less. This 
was assuming that the stack pointer may be pointing to ROM 
at the time the routine was entered. The first time the solution 
was attempted the code took only 42 bytes. Either I do not 
understand completely the question or someone’s coding is 
not very tight. (PSW, BC, DE, HL, & the SP saved with all 
renters restored at the exit) 

Yours truly, 2305 W. Winona 

L. Barker Chicago, Ill. 60625 


pointer might not be valid. (If the stack pointer is pointing at 
ROM, at memory-mapped I/O devices, or an non-existent 
memory, then PUSH PSW followed later by POP PSW will not 
restore the original condition codes or register A). 

Also in DDJ #41: Jon Bokelman gives a clever, but overly- 
complicated solution to the problem. (I will take his word for 
it that his solution correctly deduces the settings of the N and 
H flags). 

In my solution to the problem, one of two DAD SP instruc¬ 
tions is executed, depending on the setting of the carry flag. 
If the carry is reset when the routine is entered, then the jump 
in the third instruction is not taken, and the following DAD 
instruction leaves the carry reset. If the carry is set when the 
routine is entered, the jump in the third instruction is taken 
to SAVE1, and the carry is set by the STC instruction that 
follows the DAD. In either case, when the label SAVE2 is 
reached, the carry flag is the same as it was when the routine 
was entered. (All other flags are also the same, since DAD 
affects only the carry flag). At the end of the routine, all 
registers have been saved and only HL and the stack pointer 
contain values that are different from their entry values. The 
original contents of these registers can be easily restored if 
desired. (Where was the original statement of the problem 
and what was its motivation?) 

Sincerely, 5472 Playa Del Rey 

Jim Howell San Jose, CA 95123 


As pec Dr. Dobb's »4w page 9b. 

Save all bube registers (Nuit buob not Zbv) 
Assuming stack may be pointing to kOM at entry 




; 5 flags 

bit numbers 





7 6 

5 4 u 

2 1 



; Flags 

S Z 

6 AC u 

P 1 

0000 

222D00 

START: 

SHLD 

ADDK+b ; 

save hL 

00k) i 

EB 


XCHG 



0004 

2221*00 


SHLD 

ADDR+4 ; 

save DE 

0607 

210006 


LXI 

H , 0 


0 0 0 A 

54 


MOV 

D,H 


0603 

5D 


MOV 

E, L 


00 0C 

D21100 


JNC 

SKIP 


000 F 

1E01 


MV i 

E, 1 


0011 

39 

SKIP: 

DAD 

SP ; 

HL=SP 

601 ,2 

222B00 


SHLD 

ADDR+b 

save pointer 

0015 

312900 


LXI 

SP,ADDR+4 

0018 

F5 


PUSH 

PSW 


00 r> 

El 


POP 

H i 

PSW in HL 

001A 

19 


DAD 

D 

witn carry t 

00 IB 

C5 


PUSH 

b ; 

save BC 

061C 

E5 


PUSH 

h ; 

save PSW 

00 Id 

FI 


POP 

PSW ; 

restore 

001B 

Cl 


Pup 

B 


00 IP 

Dl 


PUP 

D 


0620 

El 


POP 

H 

oiq stack po 

00 2 j. 

Fy 


SPHL 


00 2 2 

2A2D00 


LHLD 

ADDK+o ; 

restore HL 



.**•«** 



00 2 b 


ADDR : 

DS 

10 


00 2 F 


END 






P0'J~ 

INE TO SAVE T HE STATUS OF THE 8080 



NO ASSUMPTIONS ARE MADE 

ABOUT THE INITIAL CONTENTS 



OF 

ANY OF THE REGISTERS 


SAVE: 

SHLD 

HLSAVE 

; SAVE H AND L 



I.XT 

H, 0 

; PREPARE TO GET S~ACK 

POINTER 


JC 

SAVE 1 

; JUMP IF CARRY IS SET 



DAD 

SP 

; GET STACK PTR, LEAVE 

CARRY RESET 


JMP 

SAVE? 



SAVE 1 : 

DAD 

SP 

; GE~ STACK PTR 



STC 


; AND RESTORE CARRY TO 

•SET' 


HL NOW CONTAINS INITIAL 

STACK POINTER 



THE 

CARRY FLAG (AND ALL 

OTHFR REGISTERS) ARE THE SAME 

j 

AS 

THEY WE B E ON EK“°Y 



SAVE?: 

LXI 

SP, LCLSTK 

; LOCAL STACK 



PUSH 

H 

: SAVE INITIAL STACK POINTER 


PUSH 

D 

; AND 0~HE B REGISTERS 



PUSH 

B 




PUSH 

PSW 




... all registers are now saved ... 

ORC RAM ; SOMEWHERE IN "AM 

DS 20 ; LOCAL STACK (WI"H SOME EXTRA SPACE 

LCLSTK FO'J * 

HLSAVE DS 2 


Program =37 bytes 
Storage = 10 bytes 
Total = 47 bytes 


VARIATION ON SAVING 8080 STATUS 

Dear Dr. Dobb’s, 

One of the more popular topics in DDJ recently has been 
how to save the status of an 8080 if no assumptions can be 
made about what is in any of the registers. The major problem 
is to get the stack pointer contents without altering the carry 
flag. A couple of writers in DDJ #41 used the current stack to 
save one or more registers, but this is not allowed by the 
conditions of the problem, since the contents of the stack 



Page 48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 44 

173 









Dr. DoBB'S JoURNALof 

COMPUTER 

(Calisthenics Cf Orthodontia 

Running Light Without Over byte 

Number 45 May 1980 Volume 5, Issue 5 

A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 

Special Issue! 

The C R'ogramming Language 


A Small C Compiler for the 8080’s 5 

Ron Cain 

The C Programming Language 20 

D.M. Ritchie, S.C. Johnson, M.E. Lesk, B.W. Kernighan 

Structured Programming, C and tiny c 30 

Tom Gibson and Scott Guthery 

Help with OSI’s CP/M 36 

Lee Barker 

MITS DOS — Disk to Disk Copy Routine 40 

Andrew Bender 

An 8080 to Z80 Translator System 47 

Robert W. Dea 






fi smFiii a anainiEN 

EEfl THE SESE's 


BY RON CAIN 

811 Eleventh Ave. 

Redwood City, CA 94063 

I had to have a compiler for my home computer. 

There was no doubt about it: after programming 
nearly every day in BLISS and then reading about C, PASCAL, 
LISP, and all the other various languages becoming available, it 
made no sense at all to continue programming in assembly 
language. 

However, the question arose: Which language? 

Surprisingly, the decision was not difficult. Since I do most¬ 
ly system type programming (editors, music-board drivers, 
modem talkers, faster versions of LIFE, etc.) rather than 
application programming (accounting programs, solar eclipse 
predictors, etc.), the choice boiled down to two: C or BLISS. 
Besides having the most esoteric names of the group, both 
possess the strengths of system programming languages. Which 
is to say they both have a slightly better notion of computer 
architectures than strictly application oriented languages in 
terms of accessing bytes and words, and neither wastes time 
doing “garbage collection” or keeping track of legal array 
subscripting. Both are intended to produce fairly fast (usually 
inline) code to get the job done with the least amount of 
overhead. 

After looking around the marketplace, I decided C was the 
appropriate choice if I expected to produce code usable by 
others. However, another thing also became obvious: the C 
compilers available either cost a lot of money, ran only on 
CP/M, or both. Having neither a lot of money nor CP/M 
(the second by choice), I had to think of an alternate 
approach. 

The first step came by way of the Tiny-C Interpreter 
offered by Tiny-C Associates. For a mere $40, I was able 
to buy the source code of a working C interpreter. I intended 
to use it to run the C programs I would write until something 
bigger and better came along. I sent off the money, got the 
huge white notebook in the mail, and after a couple weeks of 
typing, had it up and running. Let me be another of many 
praising the product. The documentation, clarity of print, 
and ease of implementation of the thing were all exceedingly 
good. 

It gave me a few weeks to evaluate the C language as well as 
the interpreter. It became obvious after very little time that 
the language was very easy to use and to follow. It also became 
obvious that the interpreter, though an excellent 
implementation, was too slow for my needs. Modem 
to disk programs like to think in terms of microseconds, 
not milliseconds, and the former was not to be had with 
an interpreter. Clearly, a third approach was needed. 


The solution was obvious. I had to write the compiler 
myself. I said obvious, not easy. 

So, after gathering together a thick stack of paper and 
getting ready to produce the (hopefully) last vast 8080 
programming effort, I wrote a few lines, and, ... recon¬ 
sidered. 

Hmmm. What better use of a systems programming 
language could there be than to write a compiler? And wliat 
better language could be used than the one the compiler 
would ultimately support? Ideas began to gel, and pieces 
began to fit together. I already had the interpreter. Even 
though it was slow, it might be just the ticket to bootstrap 
my way onto the machine. And so it began. 

Considering the fact I had never even seen a compiler 
before and had not done any lengthy programs in C, the 
thing went together in a remarkably short period of time. 
Chalk that up to the ease of use of the language. The ability 
to have variables local to individual routines made the 
recursive-descent expression parser fit together literally in 
hours. A few weeks of a couple hours a night saw the compiler 
begin to take shape. A few obstacles appeared along the way; 
probably the worst being the point where I discovered I didn’t 
have enough memory for the entire compiler to reside in 
memory along with the interpreter. One demonic session with 
the editor deleting all comments (gulp), and shortening all 
names, brought it to size and solved that problem. The com¬ 
piler’s still recovering from that early trauma. Eventually, 
there came an evening when all such little problems were 
solved, and the compiler, running under the interpreter, 
accepted a small C program and produced an 8080 program. 

At that point, I refined the compiler, removed subtle errors, 
and discovered I still didn’t have enough memory for the com¬ 
piler, the interpreter, and the symbol table a program as large 
as the compiler itself required. So I asked around, eventually 
got access to a UNIX system, and spent a couple more weeks 
refining the compiler without regard to memory or inter¬ 
preters. This exercise helped remove some of the less obvious 
syntax errors not caught by the interpreter and necessitated 
modifying the compiler to accept the true C syntax rather 
than the slightly-modified syntax used by the interpreter. 
After this upgrade, the compiler was beginning to took like a 
true C compiler, and there came a time it ran under UNIX and 
accepted as input itself. 

So, finally, I was able to take the equivalent 8080 code for 
the compiler back to my machine at home to complete it. The 
generated code was assembled, run, and once again the com- 


Number 45 

176 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 


piler was submitted to itself. The results of this inbreeding 
highlighted errors in the generated 8080 code which had thus 
far been hidden. I set those aright, compiled the compiler 
once again, then used the ouput to compile the compiler 
again, and then one more time (sound like an infinite loop?) 
compiled the compiler. When the code generated by this 
great-grandson was byte-for-byte identical to the code 
generated by UNIX way back when, and all subsequent 
offspring produced such twins, I decided the thing could 
be considered working. 

Once it was working, I decided it would save people in a 
similar situation a lot of parallel effort if I made the thing 
available. And if I sold it, I would probably get caught up in 
supporting it on a number of machines, which was not my 
intention behind writing it. Giving it away for free seemed like 
an excellent way to make C available to hobbyists who might 
otherwise not have been able to get it. What better way to add 
users to the C community? So here it is. 

For those of you who are interested in getting a compiler 
for a structured language on your home machines, I’d feel 
flattered if you’d consider the one published here. And if you 
are the sort who is looking for a systems programming 
language, you are undoubedly the sort who would modify the 
thing to fit your own needs. Therefore, a few vital statistics are 
in order. 

In a nutshell, the compiler: 

1. Is written in C. 

2. Accepts as input a text file written in C. 

3. Produces as output a text file of 8080 mnemonics. 

The syntax it accepts is a subset of the standard C language. 
Within this subset, it does not depart from the standard 
syntax, which means the listing shown here will compile and 
run under UNIX. Although the subset is limited to make the 
compiler simpler and will therefore not accept just any pre¬ 
existing C program, the programs you can write with it are 
authentic and will be compatible with more complete 
compilers. 

Right out front, so that UNIX freaks can groan and keep 
their hopes from getting too high, let me tell you the features 
of standard C this compiler does NOT support: 

1. Floating-point data types. 

2. Structures (or unions). 

3. Multiple dimension arrays. 

The aim was not to support the full C language, but rather 
to support enough of a subset to be able to create C programs 
which would be compatible with standard C. Then, as the 
compiler expanded, more and more features could be added to 
bring it closer to the real thing. 

Currently, the allowable data types are: 

1. char—8 bit data element. 

2. int —16 bit data element. 

Obviously, this means the compiler is an integer-only 
subset of the language. Which means it will not handle 
floating-point numbers. Actually, all internal arithmetic 
operations assume 16-bit integers, meaning 8-bit character 
elements are sign-extended prior to use. 


Allowable modifiers of the two basic types are: 

1. type *name — declares name to be a pointer to an element 
of the specified type. 

2. type name [ ] —syntactically identical to the above pointer 
declaration. 

3. type name [constant] —declares an array of “constant” size 
where each array element is of the specified type. 

If you’ve worked with C before, you know just about 
everything is done with pointers. It lets you exploit the archi¬ 
tecture of the cpu by giving access to all addressable memory. 
Unlike standard C, you can’t use more than one modifier per 
declaration, meaning it will not accept something like “int 
(*name) [ ] ”. This does not present a terrible restriction, 
but it must be mentioned. Since no runtime checking is made 
on the legality of pointer usage, it is a trivial matter to access 
any byte in memory, and a not-at-all-trivial problem finding 
which routine is clobbering some random location. You can 
see why pointers have been lumped with “goto’s” as the bane 
of the code maintainers and modifiers. 

Allowable primary expressions are: 

1. A local or global variable name. Any name which has been 
declared previously may be used as an expression. The 
name can be any length, but only the first 8 characters are 
used by the compiler. Presently, variable names are not 
folded to upper-case prior to being used in the output file. 
Therefore, the variable “x” would expand in the expression 
“x = 0” to: 

LXI H,0 
SHLD x 

If the assembler you intend to use cannot handle lower¬ 
case names, do not use lower-case names in your C 
programs. 

2. Constants. These can be either: 

a. A decimal number. 

b. A single or pair of ASCII characters enclosed in single 
quotes, such as ‘a’ or ‘TX’. 

c. A string enclosed in double quotes, such as “this is 
a string”. The value such a constant yields is a pointer 
to the first character of the string which the compiler 
stores in memory. 

3. Function calls. These are defined as any expression 
followed by an open paren. Thus, a function can be to a 
named routine, such as “print()”, or to the results of 
some expression, such as “ 1000()” (which calls location 
1000 decimal), or “array [i]()” which calls the location 
whose value is found in array [i]. Functions always return 
a value in HL, though it does not have to be used. Argu¬ 
ments to functions appear between the parentheses and are 
pushed onto the stack in the order they appear. Hence, 
“print(x,y,z);” would effectively do: 

PUSH x 
PUSHy 
PUSH z 
CALL print 

Any number of arguments may be passed. 

4. Subscripted elements. Either an array name or a pointer 
may be subscripted to refer to the appropriate element. 
Subscripts are assumed to start from zero. Therefore, legal 


Page 6 


Or. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

177 



expressions are: 

array [0] - the first element in array, 
array [x + 31] — the element at the address given by 
adding x to 31 and then to array, 
pointer [i] — the element at the address given by 
adding i to the contents of pointer. 
Only single dimensions are allowed. Subscripting either an 
integer array or a pointer to an integer will cause the sub¬ 
script expression to be doubled. Therefore, if you declare 
“int *ptr”, the expression “ptr[3]” refers to the element 
at ptr+6. 

Allowable unary expression operators are: 

1. — forms the two’s complement of the expression 

(minus). 

2. — refers to the element pointed to by the expression 

(providing the expression is a pointer). 

3. “&” — evaluates the address of the given expression, 

providing it has one. Hence, &count yields the 
address of the element “count”. &1000 is an 
error. 

4. increments the expression by one. If this appears 
before the expression, it increments before using 
it. If it appears after it, it will increment it after. 
Only lvalues (expressions which can appear on the 
left-hand side of an equal sign) are allowed. 
Hence, assuming “count” contains a 5, ++count 
would evaluate to a 6, and “count” would contain 
a 6. Count++ would evaluate to a 5, and count 
would contain a 6. 1000++ is illegal. If this 
operator is applied to an integer pointer, it will 
increment by 2. 

5. — decrements the expression by one. This works just 

like ++ but subtracts one rather than adding. 

Allowable binary operators are: 


44 99 

M# »* 

44 l 99 
“%” 

6. “I” 

7 

8. 

9 «=” 


1 . 

2 . 

3. 

4. 

5. 


adds the two expressions (i.e. count + total) 
subtracts the two expressions, 
multiplies the two expressions, 
divides the first expression by the second, 
yields the remainder after dividing the first expres¬ 
sion by the second (modulo), 
yields the logical inclusive “or” of the two expres¬ 
sions. 

yields the logical exclusive “or”, 
yields the logical “and”. 

assigns the value of the expression on the right to 
the one on the left. Since evaluation is done right 
to left in this case, syntaxes like: 

x = y = z = 0; 
are legal. 


Comparison operators compare two expressions and yield 
either a zero or a one depending whether the result of the 
compare is false or true, respectively. These include: 


1. tests for equality. 

2. tests for inequality. 

3. “<” — tests for less than. 

4. “>” — tests for greater than. 

5. “<=” — tests for less than or equal to. 


Comparisons involving a pointer (which is an address) are 

done as unsigned compares. All other compares are signed. 
Program control is accomplished by the following allowable 

statements: 

1. expression; An expression, no matter how complex, is con¬ 
sidered a simple statement. 

2. if (expression) statement; If the expression is nonzero, the 
statement is executed, otherwise it isn’t. 

3. if (expression) statement; else statement; This form of the 
“if” statement allows the “else” clause. As is the case with 
most “dangling else” ambiguities, all “else’s” pair with the 
nearest unmatched “if’. 

4. while (expression) statement; The statement is performed 
until the expression becomes zero. Since the test is made 
before the statement is executed the first time, it need not 
be executed at all. 

5. break; This statement will cause control to be transferred 
out of the inner-most “while” loop. 

6. continue; This statement, used within a “while” loop, 
will transfer control back to the top of the loop. 

7. return; This statement does an immediate return from the 
current function. If a function does not end with this 
statement, one is performed regardless. 

8. return expression; This statement allows a function to 
return a value explicitly. 

9. ; A semicolon by itself is considered a null statement which 
does nothing but take the place of a statement. You see this 
in forms such as: “while ( *iptr++ = *jptr++) ;” where the 
test itself contains all the necessary parts of the statement. 

10. {statement; statement;...; statement;} The use of curly 
brackets (“ { } ”) around any group of simple statements 
is considered a compound statement. A compound state¬ 
ment can be used anywhere a simple statement can. For 
example: 

while (1) (x = 3; y = 10; funct(33);} 
or 

if (x < y) 

{ print(x); 
total (x); 


else 

{ type (“all done”); 
x = y; 

} 

The compiler also accepts some pseudo-op type statements. 
These are: 

1. #include filename Anywhere this statement appears in the 
program, the indicated filename will be opened and 
inserted. The “included” file may not contain an “#include” 
statement. 

2. #define name string This statement will cause the given 
name to be replaced by the string throughout the entire 
program. Normally, it is used to define constants, such as: 

#define tablesize 1000 
#define maxlength 8 

But it can also be used for any sort of text: 

# define jprint 3crs print (12); print(12); print(12); 


Number 45 

178 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



The replacement is purely on a text level, and error 
checking will be performed only after the replacement. 

3. #asm ... #endasm This structure is not supported by 
standard C, but it was a feature I felt I needed. It may 
appear anywhere a statement would, but it passes every¬ 
thing between the word “#asm” and the word “#endasm” 
right through the parser without intervention. It is intended 
to be used to pass assembly language code through the 
parsing mechanism. Since it counts as a single statement, 
allowable (and expected) forms are: 
if (x < y) 

#asm 

LHLD TOTAL 
CALL ADD 
CNCERROR 
#endasm 
else return; 

This pseudo-op conceivably allows an entire assembly 
language program to be passed through the compiler. Its 
intent is to allow machine dependent features (like the 
8080’s “IN” and “OUT” instructions to be used without 
writing separate programs). 

In parsing the input, the compiler never tries to be overly 
clever, which simplifies the compiler quite a bit and makes 
the generated code quite predictable, if somewhat redundant. 

The input file is scanned character-by-character left to 
right. Only a single 80 character line at a time is buffered. This 
reduces the amount of memory used by the compiler and 
makes any kind of look-ahead improbable. The expression 
parser (namely the routines heir 1 () through heir 11 () and 
primary()) uses the method of recursive-descent to evaluate 
an expression, which means the routines call themselves when 
necessary (such as encountering an open paren). All expres¬ 
sions result in a value in the HL register pair. Character values 
are sign-extended through the H register. This means the 
line of code: 

x : = 5; 

generates the code: 

LX I H, 5 
SHLDx 

Notice, HL still contains the 5. The compiler relies upon this 
convention in the forms: 

x : = y = z = 0; 
which generates the code: 

LX I H,0 
SHLDx 
SHLDy 
SHLDz 

In fact, using an expression as a statement is a good way to 
load the HL pair using the compiler. The expression: 

100 ; 

puts 100 into the HL pair. Of more use might be the expres¬ 
sion: 

& local; 

which would load the address of the variable “local” into HL. 

Whenever a binary operator is seen, and a second value is 
needed, the HL pair is pushed onto the stack, and the second 
operand is loaded into HL. Therefore, the expression: 
x = x + 5; 

would generate the code: 


LHLD x 
PUSH H 
LXI H,5 
POP D 
DADD 
SHLDx 

Obviously, this shows the excessive caution used by the 
compiler. It need not actually have pushed the HL pair, but 
could merely have put it into DE with an “XCHG” instruc¬ 
tion. Except for the one fact the compiler had no idea how 
involved the second expression would be. Consider: 

x = x + (5 * x) / funct(x * 3); 

Obviously, in such a case, pushing H would be wise. The 
compiler makes no distinctions, but generates bullet-proof, 
rather than optimal, code. 

Global variables (those declared outside of a function) are 
assigned storage and can be referenced by name. This means 
assembly language code can refer to the global variables using 
the same name as the C program. Local variables, however, 
like function arguments, occupy a spot on the stack, and are 
referenced by some offset from the current stack pointer. 
The simple routine: 

main(arg) 
char arg; 

{int localword; 
localword = arg; 

would generate the code: 
main: 

PUSH B 
LXI H,0 
DAD SP 
PUSH H 
LXI H,4 
DAD SP 
CALL ccgchar 
POP D 
CALL ccpint 
POP B 
RET 

Notice a few important items. First, the address of 
“localword” is evaluated as it is encountered. Then it is 
pushed, since HL must be used for something else. The address 
of “arg” is evaluated, and an outside routine “ccgchar” is 
called to read one byte from the specified address and to sign- 
extend it. Then the address of “localword” is popped, and 
another routine “ccpint” is called to store a 16-bit value in 
HL at the address in DE. This means there is a runtime library 
needed for the C programs produced by this compiler. It is 
not listed here, since it is as long as the compiler itself (it is 
in 8080 code) and all the routines seemed fairly obvious, 
since they are all invoked by the code generating routines at 
the end of the compiler. If there is enough response, perhaps 
Dr. Dobbs can print that too one day. 

I guess the biggest question remaining is “How can I get it 
on my system?” 

Good question, and I’m afraid you know the answer better 
than I do. 

Obviously, the C listing printed here is not directly usable 
on your home system. If you had access to a UNIX system, 


Page 8 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

179 



you could simply type it in as shown, compile it with UNIX’s 
C compiler, and have a running version. At that point, you 
could run the compiler under UNIX, submit it to itself for 
compilation, and the output would be a copy of the compiler 
in 8080 mnemonics. That output is directly usable on any 
8080 machine with some mass-storage and an assembler. 
This is just what I did in bootstrapping the compiler, so 
naturally I have all the intermediate files on floppy disk. 

However, I am not a distributor. I can’t handle, nor do I 
want to handle, requests to put the files onto some other 
media. I originally released the first version of the compiler 
some months ago and have not been able to deal with even the 
moderate number of requests. 

It is my hope some of you will either go to the effort 
yourselves or get some distributor to go to the trouble of 
getting the files onto the necessary floppies or cassettes. Such 
group efforts I will assist where possible. 

Already, a couple of distributors or private parties have the 
thing working on other machines or are planning it. 

Walt Bilofsky, Software Consultant, 14478 Glorietta Drive, 
Sherman Oaks, Ca. 91423, has been in on this thing from early 
on, and has an extremely improved version running on his 
Heath-kit. His compiler supports much more of the standard 
C language, and his runtime library sports the ability to do 
I/O redirection like the UNIX shell. I am told he is considering 
a CP/M version, and will eventually support others. What is 
published here is free, if difficult to transport directly to your 
system. But for a small fee, I’m sure he’ll be able to supply 
you with a working compiler. 

Also, The Code Works has obtained a version and was 
considering making it work on other machines. Their address is 
Box 550, Goleta, CA 93017. 

Which brings up interesting points. If you haven’t already 
made the intuitive leap about the power behind writing the 
compiler in the same language it supports, it lies in the ability 
to compile itself. This means a user with extra memory can 
add additional features to the basic compiler, compile it with 
the old compiler, and voila! A new and more powerful version 
will exist. 

If you have a working compiler on one cpu and want to 
bootstrap your way to another kind of processor, you need 
only change the code generating portions of the compiler 
(all grouped into the final section of the listing) to make code 
for the new machine, compile that compiler, and once again, 
you have a new beasty. Sort of like cloning. 

Personally, I’ve developed the thing about as far as I need 
to begin using it for the things I originally intended. After all, 
I did write it for a reason. However, I am still interested in 
hearing what modifications are found useful, what machines 
it eventually wanders onto, and any other interesting paths 
this thing takes. 

If you get this thing running on your home system, make 
mods to it, make it run on another cpu, or are in a position to 
make copies of your work for others with similar cpu’s, I 
would appreciate hearing about it in Dr. Dobb’s. 

I thing it’s an excellent opportunity to leam how a com¬ 
piler works and at the same time establish the necessary 
groundwork for a C community. It’s already here, with the 
Tiny-C interpreter and the other C compilers now available. 
I hope to see alot more C programs in the future. 


PNESNFlfll 


. ... . 

/• V 

/* small-c compiler */ 

/* rev. 1.1 */ 

/* by Ron Cain */ 

/* */ 

/**....... 

/* Define system dependent parameters */ 

/* Stand-alone definitions */ 

/• {Jdefine NULL 0 */ 

/* #define eol 13 */ 

/* UNIX definitions (if not stand-alone) */ 

{{include <stdio.h> 

{(define eol 10 

/* Define the symbol table parameters */ 


{{define symsiz 14 

{{define symtbsz 5040 

{{define numglbs 300 

{{define startglb symtab 

{{define endglb startglb+numglbs*symsiz 

{{define startloc endglb^synsiz 

{{define endloc symtab+symtbsz-symslz 

/* Define symbol table entry format */ 

{{define name 0 
{{define ident 9 
{{define type 10 
{{define storage 11 
{{define offset 12 

/* System wide name size (for symbols) */ 

{{define namesize 9 
{{define namemax 8 

/* Define possible entries for "ident" */ 

{{define variable 1 
{{define array 2 
{{define pointer 3 
{{define function 4 

/* Define possible entries for "tvoe" */ 

{{define cchar 1 
{{define cint 2 

/* Define possible entries for "storage" */ 

{{define statik 1 
{{define stkloc 2 

/* Define the "while" statement gueue */ 

{{define wqtabsz 100 
{{define wqslz 4 

{{define wqaax wq»wqtabsz-wqsiz 

/• Define entry offsets in uhile queue */ 

{{define wqsym 0 
({define wqsp 1 
{{define uqloop 2 
{{define uqlab 3 

/* Define the literal pool */ 

tfdefine litabsz 2000 
{{define litmax litabsz-1 

/* Define the input line */ 

{{define llnesize 80 
{{define linemax linesize-l 
{{define rapmax linemax 

/* Define the macro (define) pool */ 

{{define nacqsize 1000 
{{define raacmax macqsize-1 

/* Define statement types (tokens) */ 

{{define stif 1 
{{define stwhlle 2 
{{define streturn 3 
{{define stbreak 4 
{{define stcont 5 
{{define stasis 6 
{{define stexp 7 

/* Now reserve some storage words */ 


Number 45 

180 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 





cheir symtabtsynitbs23; 

char *glbptr,*locptr; 

ini: uqCuqtabszl; 

int *uqptr; 

char litqClitabszJ; 

int litptr; 

char macqLmacqsizel; 

int macptr; 

char linetlinesizel; 

char mllneClinesizeD; 

ini: lptr/inptr; 

/* Misc storage * 

int nxtlab, / 

litlab, / 

sp, / 

argstk, / 

neap, y 

errcnt, y 

eof, y 

inputs y 

output/ y 

input2/ y 

glbflag/ y 

ctext/ y 

cmode, y 


/* symbol tatle */ 

/* ptrs to next entries */ 

/* uhile queue */ 

/* ptr to next entry */ 

/* literal pool */ 

/* ptr to next entry */ 

/* macro string buffer */ 

/* and its index */ 

/* parsing buffer */ 

/* temp macro buffer */ 

/* ptrs into each */ 


Hhile(J—) 

(outdec((litqCk*+DU27)); 
if ((J==0) I (k>=litptr)) 


Cnl(); 

break; 

} 

outbyte(', '); 

) 


Dump all static variables 


need <cr> */ 


separate bytes */ 


dumpglbsf) 
C 


next avail label ft 
label ft assigned t 
compiler relative 
function arg sp •/ 
ft open compound st 
ft errors in compil 
set non-zero on fi 
iob ft for input fi 
iob ft for output f 
iob ft for "include 
non-zero if Intern 
non-zero to interm 
non-zero uhile par 
zero uhen passing 
last executed stat 


o literal pool */ 
stk ptr */ 

atements */ 
atlon */ 

nal input eof */ 
le */ 

ile (if any) •/ 

" tile */ 
al globals */ 
lx c-source •/ 
sing c-code */ 
assembly code */ 
ement type */ 


int ); 

ifCglbflag==0)return; /* don't if user said no */ 

cptr=startglb; 

uhile(cptr<glbptr) 

Clf(cptrCidentll=function) 

/* do if anything but function */ 
(outstr(cptr);col(); 

/* output name as label... */ 
defstorageC); /* define storage */ 

j=((cptrtoifset]&255)« 

((cptrCoffsetM3fc255)<<8)); 

/* calc ft bytes */ 
if((cptrCtypel==clnt)| 

(cptrCidentl==pointer)) 


quotet 2 3; /* literal stri 

*cptr; /* uork ptr to 

*iptr; /* uork ptr to 

>>»> start ccl ««<< 

Compiler begins execution here 


literal string for */ 
uork ptr to any char buffer */ 
uork ptr to any int buffer */ 


outdec(j); 

nl(); 

) 

cptr=cptr*symsiz; 

> 


Report errors for user 


need that many */ 


errorsummary() 
( 


glbptr=startglb; 
locptr=startloc; 
uqptr=uq; 
macptr = 
litptr= 

sp = 

errcnt= 

eof = 

input= 

input2= 

outputs 

ncmp= 


/* clear global symbols */ 
/* clear local symbols */ 
/* clear uhile queue */ 

/* clear the macro pool */ 

/• clear literal pool */ 

/• stack ptr (relative) */ 

/* no errors */ 

/* not eof yet */ 

/* no input file */ 

/* or include file */ 

/* no open units */ 

/* no open compound states */ 


/* see if anything left hanging.•• */ 
if (ncmp) error("missing closing bracket"); 
/* open compound statement ... •/ 

nl(); 
comment( ); 

outdec(errcnt); /* total ft errors */ 
outstr(" errors in compilation."); 
nl(); 


Get options from user 


lastst= /* no last statement yet 
quoteC13= 


o; /* . 

quoteC03='"'; 
cmode=l; /• en 

/* 

/* compiler body 

/* 

ask(); 
openout(); 
openin( ); 
header(); 
parsed; 
dumplits( ) ; 
dumpglos(); 
errorsummary (); 
trailer(); 
closeout(); 
return; 

) 


...all set to zero.... */ 

/* fake a quote literal */ 
enable preprocessing */ 

*/ 

dy */ 

*/ 

/* get user options */ 

/* get an output tile */ 

/* and initial input tile */ 
/* intro code */ 

/* process ALL input */ 

/* then dump literal pool */ 
/• and all static memory */ 
/* summarize errors •/ 

/* follou-up code */ 

/* close the output (if any) 
/* then exit to system */ 


int k,nuaCll; 
killO; 
outbyt e(12); 
nl();nl();nl(); 


/* clear input line */ 
/* clear the screen •/ 
/* print banner */ 


/* Process ail input text */ 

/* */ 
/* At this level/ only static declarations/ 


/* 

/* 

parse() 


defines/ includes, and function */ 
definitions are legal.•• */ 


uhile (eot==0) 

< 


/* do until no more input 


if(amatch("char",4))(declglb(cchar);ns();> 

else if(anatch("int",3))(declglb(cint);ns();> 

else if(matchC’ftasm"))doasm(); 

else if(match("ftinclude"))doinclude(); 

else if(match!"ftdefine"))addmac(); 

else neufuncO; 

blanks!); /* force eof if pending */ 

i 


/* Dump the literal pocl */ 

/* 

dump 1 i ts( ) 

(Int 

It (Utptt==0) return; /* It nothing there, exit...*/ 
printlabel(litlab);col(); /* print literal label */ 
k= 0 ; /* init an index... •/ 

uhile (k<lltptr) /* to loop with •/ 

IdefbyteO; /* pseudo-op to define byte / 

j=10; /* max bytes per line */ 


pl(" * * * small-c compiler * * *"); 
nl(); 

pl(" by Ron Cain"); 

nl( );nl(); 

/* see if user uants to interleave the c-text */ 

/* in form of comments (for clarity) */ 

pl("Do you uish the c-text to appear? "); 
gets(line); /* get ansuer */ 

ctext=0; /* assume no */ 

if((ch()=='¥')I(ch()=='y')) 

ctext=l; /* user said yes */ 

/* see if user uants us to allocate static */ 

/* variables by name in this module */ 

/* (pseudo external capability) */ 

pl("Do you uish the globals to be defined? "); 
gets(line); 
glbflag=0; 

if ((ch() = ='Y')|(ch()=='y')) 

glbflag=l; /* user said yes */ 

/* get first allouable number for compiler-generated */ 
/* labels (in case user uill append modules) */ 

uhile!1) 

Cp1("Starting number for labels? "); 
gets(line); 

if(ch()==0)CnumC03=0;break;) 
if(k=number(num))break; 

) 

nxtlab=numC0l; 

litlab=getlabel(); /* first label=literal pool */ 

kill!); /* erase line */ 

> 

/* */ 

/* Get output filename */ 

/* */ 

openoutO 
( 

kill!); /* erase line */ 

output=0; /* start uith none */ 

p1("Output filename? "); /* ask...*/ 
gets(line); /* get -n filename */ 

if(ch()==0)return; /* none given.•• */ 

if((output=fopen(line/"u"))==NULL) /* if given, open */ 
(output=0; /* can't open */ 

error("0pen failure"); 


/* erase line */ 

/* start uith none */ 


Page 10 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

181 


/* erase line */ 


Get (next) input tile 


openin() 
C 


input=0; /* none to start with */ 

while (input==0) /* any above 1 allowed */ 

(kill!); /* clear line */ 

if(eof )break; /* if user said none */ 
plC'Input filenaae? "); 
gets(line); /• get a name */ 

if(ch()==0) 

(eof=l;break;3 /* none given*.• */ 
if (( input = fopen( line,"r"))==NULL) 

(input=0; /* can't open it */ 

pl("Open failure"); 

} 

> 

kilK); /* erase line */ 

) 

*/ 

Open an include file */ 

V 


do include() 
( 


blanks!); /* skip over to nane */ 

i f (( input2=f open( 1 ine«-lptr,"r") ) = = NULL) 

(lnput2=0; 

errorC'Open failure on include file"); 

) 

klllO; /* clear rest of line */ 

/* so next read will cone fron */ 
/* new file (if open */ 


/• Close the output file */ 

/* */ 
closeout!) 

( if(output)fclose(output); /* if open, close it */ 

output=0; /* mark as closed */ 

) 

/* */ 

/* Declare a static variable */ 

/* (i.e. define for use) */ 

/* */ 

/* makes an entry In the symbol table so subsequent */ 

/* references can call synbol by name */ 

declglb(typ) /* typ is cchar or cint */ 

int typ; 

{ int k,j;char snameCnamesizel; 

while!1) 

(whiled) 

(if(endstO)return; /* do line */ 

k=l; /* assume 1 element */ 

if(match!"*")) /* pointer ? */ 

j=pointer; /* yes */ 

else J=variable; /* no */ 

If (syraname(sname)==0) /* name ok? */ 
illname!); /* no... */ 
if(findglb(sname)) /* already there? */ 
■ultidef(sname); 

if (matchC'C")) /* array? */ 

(k=needsub(); /* get size */ 

if(k)J=array; /* I0=array */ 

else J=pointer; /* 0=ptr */ 

) 

addglb(sname,J,typ,k); /* add symbol */ 
break; 

> 

if (match(",")==0) return; /* more? */ 

) 

> 

/* V 

/* Declare local variables */ 

/* (i.e. define for use) */ 

/* V 

/* works Just like "declglb" but modifies machine stack */ 

/* and adds symbol table entry with appropriate */ 

/* stack offset to find it again */ 

declloc(typ) /* typ is cchar or cint */ 

int typ; 

( 

int k,j;char snaoeCnaaeslze); 
uhlle(l) 

(whiled) 

(if(endst())return; 
if(match("*")) 

j=pointer; 
else J=variable; 
if (symname(snaree)==0) 
lllnameO; 
if(findloc(sname)) 

aultidef(sname); 
if (matchC'C")) 

(k=needsub( ); 
if (k) 

(J=array; 

if(typ==cint)k=k*k; 

) 

else 

(J=pointer; 


else 

it((typ==cchar) 

&(jl=pointer)) 
k=l;else k=2; 

/* change machine stack */ 
sp=modstk(sp-k); 
addloc(sname,J,typ,sp); 
break; 

) 

if (uatch(",")==0) return; 

> 

) 

/* >>»» start of cc2 <«<«« */ 

/• •/ 

/* Get required array size */ 

/• */ 

/• Invoked when declared variable is followed by "C" */ 
/* this routine makes subscript the absolute */ 

/• size of the array* */ 

needsub() 

( 

int nunCli; 

if(iratch("D"))return 0; /* null size •/ 
if (number (nuni) = = 0) /* go after a number */ 

(errorC'must be constant"); /* it i 


nucC0]=l; /* so to 

) 

if (numC03<0) 

(errorC'negative size illegal"); 
nunC 0] = (-numC03); 

> 

needbrack("3"); /* force single 


"); /* it isn't */ 

/* so force one */ 


/* force single dimension 
return numC03; /* and return size */ 

) 

/* */ 

/* Begin a function */ 

/* */ 

/* Called from "parse" this routine tries to irake a function */ 
/* out of what follows* */ 

newfuncd 
( 

char ntnamesize3,*ptr; 
if (symname(n)==0) 

(error("illegal function or declaration"); 

ki11(); /* invalidate line */ 

return; 

) 

if(ptr=findglb(n)) /* already In symbol table ? */ 

Cif(ptrCident3!=function)multidef(n); 

/* already variable by that name •/ 
else if(ptrCoffset3==function)multidef(n); 

/* already function by that name */ 
else ptrCoffset3=function; 

/* otherwise we have what was earlier*/ 
/* assumed to be a function */ 

) 

/* if not in table, define as a function now */ 
else addglb(n,functionsint,function); 

/* we had better see open paren for args... */ 
if (match("(")==0)error("n.issing open paren"); 
outstr(n);co1();nl(); /* print function name */ 

argstk=0; /* init arg count */ 

while(match(")")==0) /* then count args */ 

/* any legal name bumps arg count */ 

(if(symname(n))argstk=argstk*2; 
else(error("illegal argument name");Junk();) 
blanks!); 

/* if not closing paren, should be comma */ 
if(streq(llnedptr,")")==0) 

(if(match(",")==0) 

error ("expected comma"); j O'*-* 

3 

if(endst())break; 

) 

1ocptr-start loc; /* "clear" local symbol table*/ 

sp=0; /* preset stack ptr */ 

while!argstk) 

/* now let user declare what types of things */ 
/* those arguments were */ 

(if(araatch("char",4))(getarg(cchar);ns();) 
else if(aroatch("int",3))(getarg(cint);ns();> 
e1se(error("wrong number args");breakj) 

> 

if(statenent()!=streturn) /* do a statement, but It */ 

/* it's a return, skip */ 

/* cleaning up the stack */ 

(modstk(0); 
ret( ); 

) 

sp=0; /* reset stack ptr again */ 

locptr=startloc; /* deallocate all locals */ 

3 

/* */ 

/* Declare argument types */ 

/* V 

/* called from "newfunc" this routine adds an entry in the */ 

/* local symbol table for each named argument "/ 

getarg(t) /* t = cchar or cint */ 

int t; 

( 

char nCnamesize3/c;int J; 


reset stack ptr again */ 
deallocate all locals */ 


Number 45 

182 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 


C1 f ( argstk==0)return; /* no more args */ 
if(match("* M ))J=pointer; 

else J=variable; 
if (symname(n)==0) illnameO; 
if(findloc(n))multidef(n); 
if(natch("t")) /* pointer ? */ 

/* it is a pointer, so skip all */ 

/* stuff between "C3" */ 

Cwhile(inbyte()!=*3*) 

if(endst() )break; 
J=pointer; 

/* add entry as pointer */ 
i 

addloc(n,J,t,argstk); 
argstk=argstk-2; /* cnt down */ 

if(endst())return; 

if(aatch(",")==0)error("expected comma"); 

) 


/* (for "break" statement) */ 
printlabe I (wqCwqloopl);col ();nl(); /* loop label */ 
test(wqCwalabD); /* see if true */ 

statement); /* If so, do a statement */ 

jump(wqCwqloop)); /* loop to label */ 

printlabel(wqCwqlab));col();nl(); /* exit label */ 


locptr=wqCwqsym3; 
sp=icodstk(wqCwqspD); 
delwhilef); 

) 


/* deallocate locals */ 
/* clean up stk ptr */ 

/* delete queue entry */ 


"return" statement 


doreturnf) 
( 


/* if not end of statement, get an expression */ 
if(endst()==0)expression(); 
modstk(O); /* clean up stk */ 

ret(); /* and exit function */ 


/* Statement parser */ 

/* */ 

/* called whenever syntax requires */ 

/* a statement- */ 

/* this routine performs that statement */ 

/* and returns a number telling which one */ 
statement() 

t if ((ch()==0) & (eof)) return; 

else it(amatch("char",4)) 

(declloc(cchar);ns();) 
else if(amatch("int",3)) 

(declloc(cint);ns();> 
else l£(match("("))corapound(); 
else if(amatch("if",2)) 

(doif();lastst=stif;> 
else if(amatch("while",5)) 

(dowhile();lastst=stwhile;) 
else i f (aroatchC'return", 6) ) 

(dor eturn();ns();lastst=streturn;) 
else if(araatch("break",5)) 

(dobreak();ns();lastst=stbreak;} 
else it(amatch("continue",8)) 

(docont();ns();lastst=stcont;> 
else if(match(";")); 
else if (aatch("£asm") ) 

(doasm();lastst=stasra;) 

/* if nothing else, assume it's an expression */ 
else(expresslon( );ns();lastst=r.texp;) 
return lastst; 

) 

/* */ 

/• Semicolon enforcer */ 

/* •/ 

/* called whenever syntax requires a semicolon •/ 
ns() (if(Batch(";")==0)error("missing semicolon");) 

/• */ 

/* Compound statement */ 

/• •/ 

/* allow any number of statements to fall between "()" */ 
compound( ) 

( 

♦♦neap; /* new level open */ 

while(aatch(")")==0) 

if(eof) return; 
else stateaentO; 

—neap; /* close current level */ 


—neap; 
) 


"it" statement 


int flev,fsp,flabl,flab2; 

flev=locptr; /* record current local level */ 

fsp=sp; /* record current stk ptr */ 

flabl=getlabel(); /* get label for false branch */ 
test(flabl); /* get expression, and branch false */ 

statementO; /* if true, do a statement */ 

sp=modstk(fsp); /* then clean up the stack */ 

locptr=flev; /* and deallocate any locals */ 
if (amatch("else",4)==0) /• if...else ? */ 

/• simple "if"...print false label */ 
(printlabel(flabl);col();nl(); 
return; /* and exit */ 

) 

/* an "if...else" statement. */ 

juap(flab2=getlabel()); /* Jump around lalse code */ 
printlabel(Llabl);col();nl(); /* print false label */ 

stateaent(); /* and do "else" clause */ 

sp=modstk(fsp); /* then clean up stk ptr */ 

locptr=flev; J* and deallocate locals */ 

printlabel(flab2);col();nl(); /* print true label */ 

> 

•/ 

"while" statement */ 

*/ 


dowhileO 

( 

int wqC4J; 
wqCwqsya)=loeptr; 
wqtwqsp]=sp; 
wqCwqloop)=getlabei(); 
wqCwqlab)=getlabel(); 
addwhile(wq); 


allocate local queue */ 
record local level */ 
and stk ptr */ 
and looping label */ 
and exit label */ 
add entry to queue */ 


"break" statement 


int *ptr; 

J* see If any "whiles" are open */ 
if ((ptr = readwhile( ))= = 0) return; 
modstk((ptrCwqspl)); /* else cl 

jump(ptrtwqlabJ); /* Jump to 

) 


) return; /* no */ 

/* else clean up stk ptr */ 
/* Jump to exit label */ 


/* 

/* 

/* 

/* ente 
/• 

doasm( ) 


int *ptr; 

/* see if any "whiles" are open */ 
if ((ptr = readwhile( )) ==0) return; 
modstk((ptrCwqspD) ); /* else cl 

jump(ptrCwqloop3); /* Jump to 

) 

*/ 

"asm" pseudo-statenent */ 


) return; /* no */ 

/* else clean up stk ptr */ 
/* Jump to loop label */ 


enters mooe where assembly language statement are */ 
passed intact through parser */ 


cmode=0; /* mark mode as "asm" */ 

while (1) 

(inlineO; /* get and print lines */ 

if (match("Sendasm")) break; /* until... */ 
if(eof)break; 
outstr(line); 
nl (); 

) 

ki Il(); /• invalidate line */ 

cmode=l; /* then back to parse level */ 

> 

>»>> start of cc3 «<«<«< */ 


/* Perform a function call */ 

/• */ 

/* called from heirll, this routine will either call */ 

/* the named function, or if the supplied ptr is */ 

/* zero, will call the contents of HL •/ 

califunction(ptr) 

char *ptr; /* symbol table entry (or 0) */ 

( int nargs; 

nargs=0; 

blanksO; /* already saw open paren */ 

if(rtr==0)push(); /* calling HL */ 

while(streq(]ine^lptr,")")==0) 

( if(endst())break; 

expressionO; /* get an argument */ 
if(ptr==0)swapstk(); /* don't push addr */ 
push(); /* push argument */ 
nargs=narqs^2; /* count args*2 */ 
if (ffatch(",")==0) break; 

) 


needbracxC")"); 
if(ptr)call(ptr); 
else callstkO; 
sp=modstk(sp♦nargs); 


/* clean up arguments 


if (an(inbyte())) 

while(an(ch()))gch(); 
else whlle(an(ch())==0) 

(if(ch()==0)break; 
gch(); 

> 

blanks(); 


endst() 
( 


blanksO; 

return ((streq(1ine+lptr,";")|(ch()==0))); 


illnaae() 

( error("illegal symbol name");Junk();) 

multidef(snarae) 

char *snarae; 

( error("aiready defined"); 


Page 12 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

183 


comirent( ); 
outstr(snaoe);nl( ); 

> 

needbrack(str) 

char *str; 

C if (match(str)==0) 

(error("®issing bracket**); 
coamenU ) ;outstr (str ) ;n 1 ( ); 

> 

> 

needlvalC) 

( error("nust be lvalue"); 

) 

flndglb(snane) 

char ‘sname; 

C char *ptr; 

ptr=startglb; 
uhile(ptr!=glbptr) 

(if(astreq(sname,ptr,nameroax))return ptr; 
ptr=ptr4symsiz; 

> 

return 0; 

) 

findloc(sname) 

char *snane; 

C char ‘ptr; 

ptrestartloc; 
while(ptrl=locptr) 

(if(astreq(sname,ptr,namerBax))return ptr; 
ptr=ptr+syaisiz; 


addglb(snaroe,id,typ,value) 
char *sname,id,typ; 
int value; 
l char *ptr; 

if(cptr=flndglb(sname))return cptr; 

If(glbptr>=endglb) 

(error( "g lobal symbol table overflow*')) 
return 0; 

> 

cptr=ptr=glbptr; 

uhile( an(*ptr44- = *snaae + *)); /* copy naie */ 

cptrCident3=id; 

cptr(type3=typ; 

cptr(storage3=statik; 

cptrCoffset)=value; 

cptrCotfset*13=value>>8; 

glbptr-glbptr+symsiz; 

return cptr; 

) 

addloc(sname,id,typ, value) 
char ‘snarne,id,typ; 
int value; 

C char *ptr; 

if(cptr=findloc(sname))return cptr; 
if(locptr>=endloc) 

(error("local synbol table overflow"); 
return 0; 

) 

cptr=ptr=locptr; 

while(an(*ptr*4 = ‘snarne-**))) /* copy nane */ 

cptrtident 3=id; 

cptrCtype3=typ; 

cptrCstorage J=stkloc; 

cptrCoffsetDevalue; 

cptrCoffset*13=value>>8; 

locp tr = locptr+synslz; 

return cptr; 

) 

/* Test if next input string is legal synbol nave */ 
syanarae(snane) 

char ‘snarne; 

( int k;char c; 

blanksO; 

it(alpha(ch())==0)return 0; 
k = 0; 

whi le(an(ch()))sna«eCk**3 = gch(); 

snareCk3=0; 

return 1; 

3 

/* Return next avail internal label number */ 
getlabel() 

( returnd+nxtlab); 

) 

/* Print specified number as label •/ 
printlabe1(label) 
int label; 

( outstr("cc"); 

outdec(label); 

) 

/• Test if given character is alpha */ 
alpha(c) 

char c; 

( c=c&127; 

return(((c>='a•H(c<='z'))| 

((c> = 'A')Mc<='Z'))| 

(c=='_')); 

) 

/* Test if given character is numeric */ 
numeric(c) 

char c; 

f c=c4127; 


return((c>='0'H(c<='9') ); 

) 

/* Test if given character is alphanumeric */ 
an (c) 

char c; 

( return((alpha(c))I(numeric(c))); 

) 

/* Print a carriage return and a string only to console */ 
pl(str) 

char *str; 

( int k; 

k=0; 

putchar(eol); 

while(strCkl)putchar(strCk**D); 

) 

addwhile(ptr) 

int ptrCD; 

( 

int k; 

if (wqptr==wqmax) 

(error("too many active whiles");return;) 

k = 0; 

while (k<wqsiz) 

(‘wqptr** = ptrtk**);) 

> 

delwhile( ) 

(if(readwhile()) wqptr=wqptr-uqsiz; 

> 

readwhi le() 

( 

if (wqptr==wq)(error("no active whiles" );return 0;) 
else return (wqptr-wqsiz); 

) 

ch() 

( return(lineClptr3&127); 

> 

nch() 

( if(ch()==0)return 0; 

else return(llneClptr*13&127); 

1 

gch() 

( if(ch()==0)return 0; 

else return(lineClptr443&127); 

) 

killC) 

C lptr=0; 

linetlptr1=0; 

) 

inbyte() 

( 

while(ch()==0) 

(if (eof) return 0; 

inllne(); 

preprocessO; 

} 

return gch(); 

) 

inchar() 

( 

if(ch()==0)inline(); 
it(eof)return 0; 
return(gchC))J 

1 

lnlineO 

( 

int k/unit; 
whiled) 

(if (input==0)openin(); 
if(eof)return; 

if((unit=input2)==0)unit=input; 
killO; 

while((k=getc(unit))>0) 

(if((k==eol)|(lptr>=linesax))break; 
linetlptr4*D=k; 

) 

linetlptr3=0; /• append null •/ 

if(k<=0) 

(fclose(unit); 
if(input2)input2=0; 

else input=0; 

» 

if(lptr) 

(if ((ctextH(cmode)) 

(coiaent(); 
outstr(1ine); 
nl(); 

> 

lptr=0; 

return; 

) 

) 


3 


/* >»>» start of cc4 <<<<<<< */ 


keepch(c) 

char c; 

( mlineCmptr3=c; 

if(aptr<mpmax)mptr44; 

return c; 

) 

preprocess( ) 

( int k; 

char c,snameLnanesize3; 
if(cffode==0)return; 


Number 45 

184 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 


( 


raptr=lptr=0/ 

uhile(chO) 

tit((ch()==' ')|(ch()==9)) 
lkeepch(* '); 
while((ch()==* ')| 

(ch( )~9)) 

gch(); 

) 

else if(ch()=='"') 

(keepch(ch()); 
gcho; 

while(ch()!=*"*) 

(If(ch()==0) 

(error("raissing quote"); 
break; 

) 

keepch(gch()); 

3 

gch(); 

keepch(•"*); 

> 

else 1f(ch()==39) 

(keepch(39); 

gch(); 

whlle(ch()l=39) 

(If(ch()==0) 

(error("missing apostrophe"); 
break; 

> 

keepch(gchO); 

> 

gch(); 

keepch(39); 

> 

else If((ch()=='/')i(nch()=='•')) 

(lnchar();inchar(); 
while(((ch()== # *'H 

(nch()==*/*))==0) 

(if(ch()==0)inline(); 

else lncharC); 
if(eof)break; 

} 

inchar();inchar(); 

) 

else lf(an(ch())) 

(k = 0; 

uhile(an(ch())) 

(if (k<nasiemax) snameCk^+3=ch( ); 
gch(); 

} 

snametk)=0; 

if(k=findmac(snane) ) 

while (c=macqCk-* + l) 
keepch(c); 

else 

Ck=o; 

while(c=snameCk+*3) 

keepch(c); 

1 

> 

else keepch(gch()); 

) 

keepch(O); 

if(cptr>=Bpmax)error("line too long"); 
lp tr=raptr = 0; 

while(lineClptr + 0=rollneCniptr«^3); 
lptr=0; 

) 


( char snaneCnaoesizei; 

int k; 

if(symnaBe(snanie)==0) 

(111name( ); 

kiliO; 

return; 

> 

k = 0; 

while(putmac(snaneCk++3)); 
while(ch()== * * | ch()== 9) gch(); 
while(putnac(gch() ) ); 

if(oacptr>=raacraax)error("raacro table full"); 
3 

putaac(c) 

char c; 

( macqtroacptr3=c; 

if(nacptr<niacinax)*acptr + + ; 
return c; 

) 

flndmac(snane) 

char *sna^e; 

( int k; 

k=0; 

while(k<nacptr) 

(if(astreq(sname/macq^k/nameinax)) 
(while(macq(k++3); 
return k; 

> 

uhile(aacqCk++]); 

while(macqCk*+3); 

) 

return 0; 

> 

outbyte(c) 

char c; 


if(c==0)return 0; 
if(output) 

(if((putc(c/output))<=0) 

(c loseou t(); 

error("Output file error"); 

3 

) 

else putchar(c); 
return c; 

) 

outstr(ptr) 

char ptrtD; 

< 

int k; 
k=0; 

while(outbyte(ptrCk+♦))); 

3 

nl() 

(outbyte(eol);3 

tab() 

(outbyte(9);> 

col() 

(outbyte(58);> 
er ror(ptr) 

char ptrC3; 

C 

int k; 

conurent();outstr(line);nl();cottKent(); 
k = 0; 

while(k<lp tr ) 

(if(lineCkJ==9) tab(); 

else outbyte(* *); 

♦ ♦k; 

) 

outbyte(*“'); 

nl();coiraent();outstr (»•****•* "); 

outstr(ptr); 
outstr (" ******>•); 

nl(); 

♦♦errent; 

) 

ol(ptr) 

char ptrC3; 

( 

ot(ptr); 
nl(); 

> 

ot(ptr) 

char ptrtl; 

( 

tab(); 

outstr(ptr); 

} 

streq(strl,str2) 

char strlC3,str2C3; 

( 

int k; 
k=0; 

while (str2Ck3) 

(if ((strlCkl)!=(str2Ck3)) return 0; 
k ++; 

) 

return k; 

) 

astreq(strl / str2 y len) 

^ char strlC3/Str2C3;int len; 

int k; 
k=0; 

while (k<len) 

(if ((strlCk3)l=(str2Ck3))break; 
if(strlCk3==0)break; 
if(str2Ck3==0)break; 
k+^; 

> 

if (an(strlCk3))return 0; 
if (an(str2Ck3))return 0; 
return k; 

> 

oatch(lit) 

char *lit; 

( 

int k; 
blanks(); 

if (k=streq(line+lptr,lit)) 

(lptr=lptr+k; 
return 1; 

3 

return 0; 

> 

amatch(lit/len) 

char *lit;int len; 

( 

int k; 
blanks(); 

if (k=astreq(line+lptr/lit/len)) 

(lptr=lptr^k; 

whil e(an(ch()) ) inbyteO; 

return 1; 

3 

return 0; 

3 

blanks() 


Page 14 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

185 



CuhileCl) 

(while(ch()==0) 

(inline!); 
preprocess(); 
if(eof)break; 

1 

if(ch()== * ')gch(); 
else if(ch()==9)gch(); 
else return; 

> 

> 

outdec(number) 

lnt number; 

( 

int k,zs; 
char c; 
zs = 0; 
k=10000; 

If (number<0) 

Cn urn be r = (-number); 
outbyte( 

) 

while (k>=l) 

C 

c=nunber/k ♦ '0*; 
if ((c!='0 # )|(k==l)|(zs)) 

Czs=l;outbyte(c);> 
nuober-nunber%k; 
k=k/10; 

) 

) 

/* >»>»> start of cc5 «<«« */ 

expressionO 

( 

int lvalC2i; 

if(heirl(lva1))rvalue(lval); 

) 

heirl( lval) 

int lvalCD; 

C 

int k/lval2C2D; 
k=heir2(lval); 
if (natch("=")) 

Cif(k==0)(needlval();return 0;> 
if (lvalC13)push(); 
if(heirl(lval2))rvalue(lval2); 
store(lval); 
return 0; 

> 

else return k; 

) 

heir2( lval) 

int lvalCD; 

( int k,ival2C23; 

k=heir 3(lval); 
blanks(); 

if(ch()l='|*)return k; 
if (k)rvalue(lval); 
whiled) 

(if (natch!"I")) 

(push(); 

if(heir3(lval2)) rvalue(lval2); 

pop(); 

or(); 

) 

else return 0; 


helr3(lval) 

int lvalCD; 

C int k/lval2C2D; 

k=heir4(lval); 
blanks(); 

if(ch()1='“')return k; 
if(k)rvalue(lval); 
whlle(l) 

Clf (match("“")) 

(push!); 

If(heir4(lval2))rvalue(lval2); 

pop(); 

xor(); 

> 

else return 0; 

> 

1 

heir4(lval) 

int lvalCD; 

( int k,lval2C2D; 

k=heir5(lval); 
blanks!); 

it(ch()l=*&')return k; 
if(k)rvalue(lval); 
whiled) 

(if (matchC't”)) 

(push!); 

if(heir5(lval2))rvalue(lval2); 

pop(); 

and(); 

) 

else return 0; 

) 

) 

heir5(lval) 

int lvalCD; 


int k, lval2C 2D; 
k = heir6(lval ); 
blanks!); 

if((streg( line + lptr,"==")==0K 

(streq(Iine*lptr/ M l=")==0))return k; 
if(k)rvalue( lval); 
whiled) 

(if (match("==")) 

(push(); 

if(heir6(lval2))rvalue(lval2); 

pop(); 

eq()/ 

> 

else if (match(" !=•')) 

(push!); 

if(heir6(lval2))rvalue(lval2); 

pop(); 

ne( ); 

) 

else return 0; 

) 

> 

heir6( lval) 

int lvalCD; 

( 

int k,lval2C 2D; 
k=heir7(lval); 
blanks!); 

it((streq(line+lptr,"<")==0 )& 

(streq(line+lptr*">" )= = 0H 
(streq! 1 ine + lptr ,"<=") ==0H 
(streq(line«-lptr, n >= n ) ==0))return k; 
if (streq( line*lptr* M »"))return k; 
if(streq(line*lptr/"<<" ))return k; 
if(k)rvalue(lval); 
while(l) 

(if (match("<=")) 

(push!); 

if(heir7(lval2))rvalue()val2); 

pop(); 

if(cptr=lvalCOD) 

if(cptrCidentD==pointer) 

(ule(); 

continue; 

> 

if(cptr=lval2C01) 

if(cptrCidentD==pointer) 

(ule(); 

continue; 

) 

led; 

) 

else if (match(">=")) 

(push!); 

if(heir7(1va12))rvalue!Ival2); 
pop(); 

if(cptr=lvalC0D) 

if(cptrCidentD==pointer) 

(uge(); 

continue; 

> 

if(cptr=lval2C0D) 

if(cptrCidentD==pointer) 

(uge(); 

continue; 

) 

ge(); 

) 

else if((streq(line*lptr, M <"))i 

(streq(line*lptr,"«")== 0 )) 

(inbyte(); 

push!); 

if(heir7(lval2))rvalue!lval2); 
popd; 

if(cptr=lvalC0D) 

lf(cptrCideotD==pointer) 

(ult(); 

continue; 

) 

if(cptr=lval2C0D) 

if(cptrCidentD==pointer) 

(ult(); 

continue; 

> 

ltd; 

> 

else if((streq(l ine*lptr,">"))& 

(streq(l ine+lptr / ,, » ,, )==0)) 

(inbyte!); 

push(); 

If(heir7(lval2))rvalue(lval2); 

popd; 

if(cptr=lvalC0J) 

if(cptrCidentD==pointer) 

(ugt(); 

continue; 

) 

if(cptr=lval2C0D) 

if(cptrCidentD==pointer) 

(ugt(); 

continue; 

) 

gtd; 


Number 45 

186 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 


else return 0; 

) 

> 

/* >>»» start of ccb <«<« */ 

heir7(lval) 

int lvdlCD; 

C 

int k,lval2C2D; 
k=heir8(lval ); 
blanks( ); 

if ((streq(line+lptr / ">>")==OH 

(streq(line+lptr,"<<")==0))return k; 
if(k)rvalue(lval); 
uhile(l) 

(if (iratch( M >>") ) 

CpushO; 

if(heir8(lval2))rvalue(lwal2); 

pop(); 

asr(); 

) 

else if (■atch( ,, « M >) 

CpushO; 

if(heir8(lval2))rvalue(lval2); 

pop(); 

asl(); 

) 

else return 0; 


helc8(lval) 

int lvalCD; 

( 

int k,lval2C21; 
k=heir9(lval); 
blanks(); 

lf((ch()! = '-fr'H(ch()l = '- 4 
if(k)rvalue(lval); 
whiled) 

(if CwatchC'e")) 
(push(); 


))return k; 


if(heir9(lval2))rvalue(lval2); 
if Ceptr=lvalCOD) 

if((cptrCidentD==pointerH 
(cptrCtype3==cint)) 
doublereq(); 


pop(); 

add(); 

) 

else if (matchC 


pop(); 

sub(); 

) 

else return 0; 

) 

) 

hell9(lval) 

int lvalCi; 

( 

int k,lval2C21; 
k=heir10(1val); 
blanks(); 

if((ch()l= # *')4(ch()!='/ # )& 

(ch()1='%'))return k; 
if(k)rvalue(lval); 
whlle(1) 

(if (■atch("*")) 
CpushO; 


CpushO; 

If(heir9(lval2))rvalue(lval2); 
if (cptr=lvalC01) 

if((cptrCidentl==pointer)C 
(cptrC typel==cint)) 
doubleregO; 


it(helr9(lval2))rvalue(lval2); 

pop(); 

nult(); 

) 

else if («atch("/")) 

CpushO; 

lf(helrlO(lval2))rvalueClval2); 

pop(); 

divO; 

) 

else if (reatchCV*)) 

CpushO; 

if(heirl0(1val2))rvalue(1val2); 

PopO; 

ood(); 

> 

else return 0; 

) 


heii lO(lval) 

int lvalCi; 


int k; 
char *ptr; 
if (matchC***")) 

Cif((k=helrl0(lval))==0) 
Cneedlva1(); 
return 0; 

> 

if(IvalClD)pushC); 
rvalue(lval); 


inc(); 

ptr=lvalCO 3; 

if((ptrCidentl==pointer)l 
(ptrC typel==cint)) 
inc(); 

store(lval); 
return 0; 

> 

else if(aatch("—")) 

Cif((k=helrlO(lval))==0) 

Cneedlva1( ); 
return 0; 

) 

if(lvalCll)push(); 
rvalue(lval); 
dec(); 

ptr=lvalC0); 

if((ptrCidentl==pointer)C 

(ptrCtypel==cint)) 

dec(); 

store(lval); 
return 0; 

> 

else if (raatchC*-")) 

(k = heirl0(lval); 
if (k) rvalue(lval); 
neg(); 
return 0; 

) 

else if(matchC**")) 

Ck = heir10(1 va 1); 
if(k)rvalue(lval); 
lvalCll=cint; 

if(ptr=lvalC0D)lvalCll=ptrCtype3; 
lvalC03=0; 
return 1; 

> 

else if CmatchC’C")) 

Ck=heirl0(lval); 
if (k==0) 

CerrorC"illegal address"); 
return 0; 

) 

else if ( lvalC IDreturn 0; 
else 

Cimmed(); 

outstr(ptr=lvalC03); 
n 1 (); 

lvalCll=ptrCtypel; 
return 0; 

) 


tk=helrll(lval); 
if(matchC)) 

Cit(k==0) 

CneedlvalC); 
return 0; 

) 

if(lvaltll)push(); 
r valued val); 
inc(); 

P tr = lvalCOD; 

if((ptrCidentl==polnter)l 
(ptrCtypel==cint)) 
inc(); 

store(lval); 
dec(); 

if((ptrCidentl==pointer)C 
(ptrC typel==cint)) 
dec(); 
return 0; 

) 

else it(match("—")) 

Cif(k==0) 

CneedlvalC); 
return 0; 

3 

if(lvalCll)push(); 
rvalueClval); 
deed; 

ptr=lvalCOD; 

if((ptrCidentl==pointer)^ 
(p trC typeD==cint)) 
dec(); 

store(lval); 
incO ; 

if((ptrCident3 = =pointer H 
(ptrCtypeD==cint)) 
inc(); 
return 0; 

> 

else return k; 

) 

> 

/* >>»» start of cc7 <<«« V 

heirlK lval) 

int *1val; 

C int k;char *ptr; 

k=primary(lval); 
ptr=lvalC0D? 
blanks(); 

i f ((ch( )•== *C *) | (ch()=='( *)) 
whiled) 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

187 


(if(match("(") ) 

Ci f(ptr = = 0) 

(errorC'can't subscript"); 

)unk(); 

needbrack!")"); 
return 0; 

) 

else if(ptr(ident3==pointer)rvalue(lval); 
else if(ptrCident3l=array) 

(error("can't subscript"); 
k=0; 

) 

push(); 
expression! ); 
needbrack!")"); 

if (ptretype)==cInt)doublereg(); 

pop(); 

add(); 

lval(03=0; 

1valC13=ptretype); 
k=l; 

) 

else if(ma tch("(")) 

(if(ptr==0) 

(califunction(O); 

) 

else lf(ptr(ident)l=functlon) 

(rvalue!1val); 
calllunction(O); 

) 

else cal Ifunction(ptr); 
k= 1 valCO 3 = 0; 

> 

else return k; 

> 

if(ptr==0)re turn k; 
if(ptrtident3==function) 

(immed!); 
outstr(ptr); 
nl(); 
return 0; 

> 

return k; 

) 

primary!lval) 

int Mval; 

( char *ptr,snametnanesize3;int numtl); 

int k; 

if(Eatch("(")) 

(k=helrl(lval); 
needbrack!")"); 
return k; 

> 

if (symnatne(snane) ) 

(if(ptr=findloc(sname)) 

CgetlocCptr); 
lvalt 03=ptr; 
lvaltl3=ptr(type!; 

lf(ptr(ident)==pointer)lval(13=cint; 
i f(ptrtident)==array)return 0; 
else return 1; 

) 

if(ptr=findglb(sname)) 

if(ptrCiden131=function) 

(lval(03=ptr; 
lvalt13=0; 

if(ptrtident3!=array)return l; 
iramed(); 

outstr(ptr);nl(); 
lvalt13=ptrCtype3; 
return 0; 

) 

ptr = addglb(snarae# function,cint/0); 
lvalt03=ptr; 
lvaltl3=0; 
return 0; 

> 

if(constant(nun)) 

re turn(1val(0 3 = 1val113 = 0); 

else 

(error("invalid expression"); 
imned();outdec(0);nl(); 

JunkO; 

return 0; 

> 

) 

store(lval) 

int Mval; 

( if ( lvaltl3==0)putineiL(lvait03); 

else putstk(lvaltl3); 

) 

rvalue(lval) 

int Mval; 

( if((lvalto3 |= 0) & (lvaltl) == 0)) 

getraemO valt03); 
else indirect(lval(l3); 

) 

test(label) 

int label; 

( 

needbr ack("("); 
expression(); 

needbtack(")")J 

testJump(label); 


) 

constant(val) 

int valt); 

( if (number(val)) 

immed! ); 

else if (pstr(val)) 
immed!); 

else if (qstr(val)) 

(iismed();printlabel(lltlab);outbyte(' + );) 
else return 0 ) 
outdec(val(0 3); 
nl(); 
return 1; 

) 

number(va1) 

int valt); 

( int k,minus;char c; 

k=minus=l; 
whlle(k) 

(k=0; 

if ( match("♦")) k=l; 

if ( iratch( "-")) (minus=(-ninus);k = 1;> 

> 

if(nuraeric(ch())==0)return 0; 
while (numeric(ch( ))) 

(c = inhyte( ); 
k=k*10+(c-'0'); 

) 

if (rrlnus<0) k=(-k); 

valt03=k; 

return 1; 

) 

pstr(val) 

int valt); 

( int k;char c; 

k = 0; 

if (match("'")==0) return 0; 
while((c=gch())1=39) 

k=(k (255)*256 ♦ (cU27); 
valt03=k; 
return 1; 

)* 

qstr(val) 

int vait3; 

€ char c; 

if (match(quote)==0) return 0; 

valt03=litptr; 

while (ch()!='"*) 

(if(ch()==0)break; 
if(1itpt r>=11tmax) 

(error("string space exhausted"); 
while(reatch(quote)==0) 

if(gch()==0)break; 
return 1; 

> 

lltqtlltptr*+3=gch(); 

> 

gch(); 

litqtlitptr**)=0; 
return 1; 

) 

/* >>>>>> start of cc8 <<««< */ 

/* Begin a comment line for the assembler */ 
comment!) 

( outbyte(';*); 

) 

/* Print all assembler info before any code is generated */ 
header!) 

( comment!); 

outstrC'smal1-c coopller rev 1.1"); 
nl(); 

> 

/* Print any assembler stuff needed after all code */ 
trailer!) 

( /* ol("EkD"); */ 

) 

/* Fetch a static memory cell into the primary register */ 
ge tmem(sym) 

char *sym; 

( if((symtident3l=pointer)&!symttypel==cchar ) ) 

(ot("LDA "); 
outstr(sya*name); 
nl (); 

call("ccsxt"); 

) 

else 

(ot("LHLD "); 
outs tr(sy ra+name); 
nl(); 

) 

> 

/* Fetch the address of the specified symbol */ 

/* into the primary register */ 

getloc(sym) 

char *sym; 

( immed(); 

outdec(((syra(offset)i255)+ 

((symtof f set* 135.255 )«8 ))- 

3p)> 

nl(); 

olC'DAD SP"); 

1 

/* Store the primary register into the specified */ 


Number 45 

188 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 



/* static memory cell •/ 

putmera(sym) 

char *sym; 

( if((symCldentll=pointer)&(syroCtypeD==cchar)) 

(o1("MOV A,L" ) ; 
otC'STA "); 

) 

else otC'SHLD "); 
outstr(sym+name); 
nl(); 

) 

/* Store the specified object type in the primary register */ 
✓ * at the address on the top of the stack */ 

putstk(typeobj) 

char typeobj; 

( pop(); 

if(typeobj==cchar)ca11!"ccpchar"); 
else call("ccpint"); 

) 

/* Fetch the specified object type indirect through the */ 

/* primary register into the primary register •/ 

indirect!typeobj) 

char typeobj; 

( if(typeobj==cchar)callC'ccgchar"); 

else cal 1("ccgint"); 

) 

/* Swap the primary and secondary registers */ 
swap!) 

C ol("XCHG"); 

) 

/* Print partial Instruction to get an Immediate value */ 

/* into the primary register */ 

immed() 

t otC'LXI H,"); 

) 

/* Push the primary register onto the stack */ 
push!) 

( o1("PUSH H"); 

} sp=sp-2; 

/* Pop the top of the stack into the secondary register */ 
pop() 

C o1!"POP D n ); 

sp=sp>2; 

) 

/• Swap the primary register and the top of the stack */ 
swapstk!) 

t ol ("XTHL"); 

) 

/* Call the specified subroutine name */ 
calUsname) 

char *sname; 

C o t("CA LL "); 

outstr(sname); 
nl!); 

) 

/* Return from subroutine */ 
ret!) 

( ol!"PET"); 

) 

/* Perform subroutine call to value on top of stack */ 
ca1lstk!) 

( inured!); 

outstr ! M s>5"); 
nl!); 

swapstk!); 
ol! "FCHL"); 
sp=sp*2; 

) 

/* Jump to specified internal label number */ 
jump! label) 

int label; 

( ot!"JHP "); 

printlabe1!label )) 
nl!); 

) 

/* Test the primary register and jump if false to label */ 
testjump!label) 

int label; 

C ol("KUV A,h"); 

o 1!"ORA L"); 
ot!"JZ "); 
printlabelflabel); 
nl!); 

> 

/* Print pseudo-op to define a byte */ 
de fbyte!) 

( otf'DB "); 

) 

/•Print pseudo-op to define storage */ 
de fstorage!) 

< ot!"DS "); 

) 

/• Print pseudo-op to define a word */ 
defwordf) 

C ot!"OW "); 

) 

/* Modify the stack pointer to the new value indicated */ 
modstkinewsp) 

int newsp; 

( int k; 

k=newsp-sp; 
if!k==0)return newsp; 
if(k>=0) 


Cif!k<7) 

Cif(kU) 

Col!"IKX SP"); 
k—; 

) 

while(k) 

(ol!"POP B"); 
k=k-2; 

) 

return newsp; 

) 

) 

if!k<0) 

Cif(k>-7) 

(lt(kil) 

(ol!"DCX SP M ); 
k++; 

) 

while(k) 

(o 1 ("PUSH B"); 
k=k42; 

) 


swap!); 

immed();outdec(k);nl(); 
olC'DAD SP"); 
o IC'SPHL"); 
swap!); 
return newsp; 

) 

/• Double the primary register •/ 
doublereg() 

( olC'DAD H"); 

> 

/* Add the primary and secondary registers •/ 

/* (results in primary) •/ 

add!) 

C o 1("DAD D"); 

) 

/• Subtract the primary register from the secondary */ 

/* (results in primary) •/ 

sub! ) 

( callC'ccsub"); 

) 

/• Hultiply the primary and secondary registers •/ 

/* (results in primary •/ 

mult!) 

( callC'ccsult"); 

> 

/* Divide the secondary register by the primary */ 

/* (quotient in primary, remainder in secondary) */ 

div!) 

( cal1("ccdiv"); 

) 

/• Compute remainder (mod) of secondary register divided •/ 

/* by the primary */ 

/* (remainder in primary, quotient in secondary) •/ 

mod( ) 

( div(); 

swap!); 

> 

/• Inclusive 'or* the primary and the secondary registers */ 

/* (results in primary) */ 

or!) 

(call!"ccor");) 

/• Exclusive 'or' the primary anc seconday registers •/ 

/* (results in primary) */ 

xor ( ) 

(call!"eexor");) 

/* 'And' the primary and secondary registers */ 

/* (results in primary) •/ 

and! ) 

CcallC'ccand");) • 

/* Arithmetic shift right the secondary register number of */ 
/* times in primary (results in primary) •/ 

asr( ) 

(cal 1!"ccasr");) 

/• Arithmetic left shift the secondary register number ot */ 
/* times in primary (results in primary) */ 

as 1( ) 

CcallC'ccasl");) 

/• Form two's complement of primary register •/ 
neg( ) 

(call!"ccneg");) 

/• Form one's complement of primary register •/ 
com!) 

(call!"cccora"); ) 

/* Increment the primary register by one •/ 
inc!) 

ColC'INX H");> 

/* Decrement the primary register by one •/ 
dec!) 

(ol("DCX H");> 

/• Following are the conditional operators */ 

/• They compare the secondary register against the primary •/ 
/• and put a literal 1 in the primary if the condition is */ 
/* true, otherwise they clear the primary register •/ 

/* Test for equal */ 
eq() 

(call!"cceq");) 


Page 18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

189 



/* Test lor not equal */ 
neC) 

(call("ccne");) 

/* Test lor less than (signed) */ 
lt() 

Ccal 1("cclt");) 

/* Test lor less than or equal to (signed) */ 
le() 

(call("ccle");) 

/• Test lor greater than (signed) */ 
gt() 

(cal1("ccgt");) 

/* Test for greater than or equal to (signed) */ 
ge() 

(callC'ccge" )/ > 

/* Test for less than (unsigned) */ 
ult() 

(callO'ccult");) 

/* Test lor less than or equal to (unsigned) »/ 
ule() 

(cal1("ccule");) 

/* Test lor greater than (unsigned) */ 
ugt() 

(cal 1( "ccugt''); ) 

/* Test lor greater than or equal to (unsigned) */ 
uge( ) 

(cal1("ccuge");) 

/* <<<<< End ol compiler »>» */ 





Number 45 

190 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 




























UNIX Time-Sharing System- - 


The C 

Programming 

Language 


BY D. M. RITCHIE, S. C. JOHNSON, 
M. IE. LESK, AND B. W. KERNIGHAN 

Bell Laboratories 
600 Mountain Avenue 
Murray Hill, NJ 07974 

C is a general-purpose programming 
language that has proven useful for a 
wide variety of applications. It is the 
primary language of the UNIX* system, 
and is also available in several other en¬ 
vironments. This paper provides an over¬ 
view of the syntax and semantics of C 
and a discussion of its strengths and 
weaknesses. 

C is a general-purpose programming 
language featuring economy of expres¬ 
sion, modem control flow and data 
structure capabilities, and a rich set of 
operators and data types. 

C' is not a “very high-level” language 
nor a big one and is not specialized to 
any particular area of application. Its 
generality and an absence of restrictions 
make it more convenient and effective for 
many tasks than supposedly more power¬ 
ful languages. C has been used for a wide 
variety of programs, including the UNIX 
operating system, the C compiler itself, 
and essentially all UNIX applications 
software. The language is sufficiently 
expressive and efficient to have com¬ 
pletely displaced assembly language 
programming on UNIX. 

•UNIX is a trademark of Bell Laboratories. 

© 1978, American Telephone and Telegraph 
Company; Reprinted by permission. 


C was originally written for the PDP- 
11 under UNIX, but the language is not 
tied to any particular hardware or operat¬ 
ing system. C compilers run on a wide 
variety of machines, including the 
Honeywell 6000, the IBM System/370, 
and the Interdata 8/32. 

I. THE LINGUISTIC HISTORY 
OF C 

The C language in use today 1 is the 
product of several years of evolution. 
Many of its most important ideas stem 
from the considerably older, but still 
quite vital, language BCPL 2 developed by 
Martin Richards. The influence of BCPL 
on C proceeded indirectly through the 
language B, 3 which was written by Ken 
Thompson in 1970 for the first UNIX 
system on the PDP-11. 

Although neither B nor C could really 
be considered dialects of BCPL, both 
share several characteristic features with 
it: 

(/) All are able to express the funda¬ 
mental flow-control constructions 
required for well-structured pro¬ 
grams: statement grouping, deci¬ 
sion-making (if), looping (while) 
with the termination test either at 
the top or the bottom of the loop, 
and branching out to a sequence of 
possible cases (switch). It is inter¬ 
esting that BCPL provided these 
constructions in 1967, well before 
the current vogue for “structured 
programming.” 


(if) All three languages include the 
concept of “pointer” and provide 
the ability to do address arithmetic, 
(iff) In all three languages, the argu¬ 
ments to functions are passed by 
copying the value of the argument, 
and it is impossible for the function 
to change the actual argument. 
When it is desired to achieve “call 
by reference,” a pointer may be 
passed explicitly, and the function 
may change the object to which the 
pointer points. Any function is 
allowed to be recursive, and its 
local variables are typically “auto¬ 
matic” or specific to each 
invocation. 

(z'v) All three languages are rather low- 
level, in that they deal with the 
same sorts of objects that most 
computers do. BCPL and B restrict 
their attention almost completely 
to machine words, while C widens 
its horizons somewhat to characters 
and (possibly multi-word) integers 
and floating-point numbers. None 
deals directly with composite 
objects such as character strings, 
sets, lists, or arrays considered as a 
whole. The languages themselves do 
not define any storage allocation 
facility beside static definition and 
the stack discipline provided by the 
local variables of functions; like¬ 
wise, I/O is not part of any of these 
languages. All these higher mecha¬ 
nisms must be provided by explicit¬ 
ly called routines from libraries. 

B and BCPL differ mainly in their syn¬ 
tax, and many differences stemmed from 
the very small size of the first B compiler 
(fewer than 4K 18-bit words on the PDP- 
7). Several constructions in BCPL en¬ 
courage a compiler to maintain a repre¬ 
sentation of the entire program in mem¬ 
ory. In BCPL, for example, 

valof $ ( 

resultis expression 

$) 

is syntactically an expression. It provides 
a way of packaging a block of many 
statements into a sort of unnamed inter¬ 
nal procedure yielding a single result 
(delivered by the resultis statement). The 
valof construction can occur in the mid¬ 
dle of any expression, and can be arbi¬ 
trarily large. The B language avoided the 
difficulties caused by this and some other 


Page ?0 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

191 




constructions by rigorously simplifying 
(and in some cases adjusting to personal 
taste) the syntax of BCPL. 

In spite of many syntactic changes, B 
remained very close to BCPL seman¬ 
tically. The most characteristic feature of 
both languages is their nearly identical 
treatment of addresses (pointers). They 
support a model of the storage of the 
machine consisting of a sequence of 
equal-sized cells, into which values can be 
placed; in typical implementations, these 
cells will be machine words. Each identi¬ 
fier in a program corresponds to a cell, 
and a cell may contain a variety of values. 
Most often the value is an integer, or 
perhaps a respresentation of a character. 
All the cells, however, are numbered; the 
address of a cell is just the integer giving 
its ordinal position. BCPL has a unary 
operator lv (in some versions, and also in 
B and C, shortened to &) that, when ap¬ 
plied to a name, yields the address of the 
cell corresponding to the name. The in¬ 
verse operator rv (later *) yields the value 
in the cell pointed to its argument. Thus 
the statement 

px = &x; 

of B assigns to px the number that can be 
interpreted as the address of x; the 
statements 

y = *px + 2; 

*px = 5; 

first use the value in the cell pointed to 
by px (which is the same cell as x) and 
then assign 5 to this cell. 

Arrays in BCPL and B are intimately 
tied up with pointers. An array declara¬ 
tion, which might in BCPL be written 

let Array = vec 10 

and in B 

auto Array [10]; 

creates a single cell named Array and 
initializes it with the address of the first 
of a sequence of 10 unnamed cells 
containing the array itself. Since the 
quantity stored in Array is just the 
address of the cell of the first element 
of the array, the expression 

Array + i 

is the address of the ith element, counting 
from zero, likewise, applying the in¬ 
direction operator, 

* (Array + i) 


refers to the value of the ith member 
of the array. This operation is so frequent 
that special syntax was invented to 
express it: 


Array [i] 

Thus, despite its asymmetric appear¬ 
ance, subscripting is a commutative 
operation; the above example could 
equally well be written 

i [Array] 

In BCPL and B there is only one type 
of object, the machine word, so when 
the same language operator is applied to 
two operands, the calculation actually 
carried out must always be the same. 
Thus, for example, if one wishes to pro¬ 
vide the ability to do floating-point 
arithmetic, the “+” operator notation 
cannot be used, since it implies an integer 
addition. Instead (in a version of BCPL 
for the GE 635), a was placed in 
front of each operator that had floating¬ 
point operands. As may be appreciated, 
this was a frequent source of errors. 

The machine model implied by the 
definitions of BCPL and B is simple 
and self-consistent. It is, however, in¬ 
adequate for many purposes, and on 
many machines it causes inefficiencies 
when implemented. The problems be¬ 
came evident to us after B began to be 
used heavily on the first PDP-11 version 
of UNIX. The first followed from the fact 
that the PDP-11, like a number of mach¬ 
ines (including, for example, the IBM 
System/370), is byte addressed; a 
machine address refers to any of several 
bytes (characters) in a word, not the word 
alone. Most obviously, the word orienta¬ 
tion of B cut us off from any convenient 
ability to access individual bytes. Equally 
important was the fact that, before any 
address could be used, it had to be shift¬ 
ed left by one place. The reason for 
this is simple: there are two byte per 
PDP-11 word. On the one hand, the 
language guranteed that if 1 was added to 
an address quantity, it would point to the 
next word; on the other, the machine 
architecture required that word addresses 
be even and equal to the byte number 
of the first byte in the word. Since, 
finally, there was no way to distinguish 
cells containing ordinary integers from 
those containing pointers, the only solu¬ 
tion visible was to represent pointers 
as word numbers and then, at the point 
of use, convert to the byte representation 
by multiplication by 2. 


Yet another problem was introduced 
by the desire to provide for floating¬ 
point arithmetic. The PDP-11 supports 
two floating-point formats, one of which 
requires two words, the other four. 
In neither case was it satisfactory to use 
the trick used on the GE 635 (operator 
like “ .+ ”) because there was no way to 
represent the requirement for a single 
data item occupying four or eight bytes. 
This problem did not arise on the 635 
because integers and single-precision 
floating-point both require only one 
word. 

Thus the problems evidenced by B 
led us to design a new language that 
(after a brief period under the name NB) 
was dubbed C. The major advance pro¬ 
vided by C is its typing structure, which 
completely solved the difficulties men¬ 
tioned above. Each declaration in a C 
program specifies (sometimes implicitly) 
a type, which determines how much stor¬ 
age the object requires and how it is to be 
interpreted. The original fundamental 
types provided were single character 
(byte), integer, single-precision floating¬ 
point, and double-precision floating¬ 
point. (Others discussed below were 
added later.) Thus in the program 

double a,b; 

a = b + 3; 

the compiler is able to determine from 
the declarations of a and b the fact that 
they require four words of storage each, 
that the “ + ” means a double-precision 
floating add, and that “3 ” must be con¬ 
verted to floating. 

Of course, the idea of typing variables 
is in no way original with C; in fact, 
it was the general rule among the most 
widely used and influential languages, 
including ALGOL, FORTRAN, and PL/I. 
Nevertheless, the introduction of types 
marked an important change in our own 
thinking. The typeless nature of BCPL 
and B had seemed to promise a great 
simplification in the implementation, 
understanding, and use of these lan¬ 
guages. By the time that C was created 
(circa 1972), advocates of languages like 
ALGOL 68 and PASCAL recommended a 
strongly enforced type structure on 
psychological grounds; but even dis¬ 
regarding their arguments, the typeless 
nature of BCPL and B seemed inap¬ 
propriate, for purely technological 
reasons, to be available hardware. 


Number 45 

192 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 



n. THE TYPE STRUCTURE OF C 

The introduction of types in C, al¬ 
though a major departure from the tra¬ 
dition of BCPL and B, was done in such 
a way that many of the characteristic 
usages of the earlier languages survived. 
To some extent, this continuity was an 
attempt to preserve as much as possible 
of the considerable corpus of exisitng 
software written in B, but even more 
important, especially in retrospect, was 
the desire to minimize the intellectual 
distance beween the past and the future 
ways of expression. 


• (Array + i) 
is the ith member itself, and 
Array [i] 

is another notation for the same thing. 
In all these cases, of course, should 
Array be an array of, or pointer to, 
some objects other than integers, the 
scale factor is adjusted appropriately. 
The pointer arithmetic, as written, is 
independent of the type of object to 
which the pointer points and indeed of 
the internal representation of the pointer. 

2.2 Derived types 


defines a template, called tag, for a 
structure containing three members', an 
integer i, a floating point number /, 
and a three-character array c. The de¬ 
claration 

struct tag x, y [10], *p; 

declares a structure x of this type, an 
array y of 10 such structures, and a point¬ 
er p to this kind of structure. The hier¬ 
archical nature of derived types is clearly 
evident here: y is an array of structures 
whose members include an array of 
characters. References to individual 
members of structures use the . operator. 

x.i 

x.f 

y[i] -c[o] 

(*p) • c[l] 

Parentheses in the last line are necessary 
because the.binds more tightly than*. 
It turns out that pointers to structures 
are so common that special syntax 
is called for to express structure access 
through a point. 

P—>c[l] 

P~>i 

This soon becomes more natural than the 
equivalent 

(*p) ,c[l] 

(*P) • i 

A union is capable of holding, at 
different times, objects of different 
types, with the compiler keeping track 
of size and alignment requirements. 
Unions provide a way to manipulate 
different kinds of data in a single part 
of storage, without embedding machine- 
dependent information (like the relative 
sizes of int and float) in a program. 
For example, the union u, declared 

union { 

int i; 
float f; 

}u; 

can hold either an int (written ui) or 
a float (written u.f.). Regardless of the 
machine it is compiled on, it will be large 
enough to hold either one of these 
quantitites. A union is syntactically 
identical to a structure; it may be con¬ 
sidered as a structure in which all the 
members begin at the same offset. 


2.1 Pointers, arrays and address 
arithmetic 

One clear example of the similarity of 
C to the earlier languages is its treatment 
of pointers and arrays. In C an array of 
10 integers might be declared 

int Array [10]; 

which is identical to the corresponding 
declaration in B. (Arrays begin at zero; 
the elements of Array are Array[0 ], 
..., Arrayf 9] . As discussed above, the 
B implementation caused a cell named 
Array to be allocated and initialized with 
a pointer to 10 otherwise unnamed cells 
to hold the array. In C, the effect is 
bit different; 10 integers are allocated, 
and the first is associated with the name 
Array. But C also includes a general rule 
that, whenever the name of an array 
appears, in an expression, it is converted 
to a pointer to the first member of the 
array. Strictly speaking, we should say, 
for this example, it is converted to an 
integer pointer since all C pointers are 
associated with a particular type to which 
they point. In most usages, the actual 
effects of the slightly different meanings 
of Array are indistinguishable. Thus in 
tlie C expression 

Array + i 

The identifier Array is converted to a 
pointer to the first element of the array; 
i is scaled ( if required) before it is added 
to the pointer. For a byte-addressed 
machine, the scale factor is the number of 
bytes in an integer; for a word-addressed 
machine the scale factor is unity. In any 
event, the result is a pointer to the ith 
member of the array. Likewise identical 
in. effect to the interpretation of B, 


As mentioned above, the basic types 
in C were originally int, which represents 
an integer in the basic size provided by 
the machine architecture; char , which 
represents a single byte; float, a single- 
precision floating-point number; and 
double, double-precision floating-point. 
Over the years, long, short, and unsigned 
integers have been added. In current C 
implementations, long is at least 32 
bits; short is usually 16 bits; and int 
remains the “natural” size for the 
machine at hand. Unsigned integers 
exist mainly to squeeze an extra bit out 
of the machine, since the sign bit need 
not be represented. 

In addition to these basic types, C 
provides a conceptually infinite her- 
archy of derived types, which are formed 
by composition of the basic types with 
pointers, arrays, structures, unions, and 
functions. Examples of pointer and array 
declarations have already been exhibited; 
another is 

double *vecp, vector[100]; 

which declares a pointer veep to double- 
precision floating numbers, and an array 
vector of the same kind of objects. The 
size of an array, when specified, must 
always be a constant. 

A structure is an aggregate of one or 
more objects, usually of various types, 
which can be treated as a unit. C struc¬ 
tures are essentially the same as records 
in languages like PASCAL, and semanti¬ 
cally, though not syntactically, like PL/I 
and Cobol structures. Thus, 

struct tag { 

int i; 

float f; 

char c[3]; 

>; 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

193 



Unions in C are more analogous to PL/I’s 
CALL than to the unions of ALGOL 68 
or the variant records of PASCAL, be¬ 
cause it is the responsibility of the pro¬ 
grammer to avoid referring to a union 
that does not currently contain an ob¬ 
ject of the implied type. 

A function is a subprogram that 
returns an object of a given type: 

unsigned unsf(); 

declares a function that returns unsigned. 
The type of a function ignores the 
number and types of its arguments, 
although in general the call and the de¬ 
finition must agree. 

2.3 Type composition 

The syntax of declarations borrows 
from that of expressions. The key idea 
is that a declaration, say 

int ... ; 

contains a part “ ... ” that, if it appeared 
in an expression would be of type int. 
The constructions seen so far, for ex¬ 
ample , 

int *lptr; 

int lfunc(); 
int iarr [10]; 

exhibit this approach, but more compli¬ 
cated declarations are common. For 
example, 

int *funcptr(); 

int (*ptrfunc)(); 

declare respectively a function that 
returns a pointer to an integer, and a 
pointer to a function that returns an 
integer. The extra parentheses in the 
second are needed to make the * apply 
directly to ptrfunc, since the implicit 
function-call operator () binds more 
tightly than *. Functions are not varia¬ 
bles, so array or structures of functions 
are not permitted. However, a pointer to 
a function, like ptrfunc, may be stored, 
copied, passed as an argument, returned 
by a function, and so on, just as any 
other pointer. 

Arrays of pointers are frequently used 
instead of multi-dimensional arrays. The 
usage of a and b when declared 

int a[10] [10]; 
int *b [10]; 


may be similar, in that a [5] [5] and 
b [5] [5] are both legal references to a 
single int, but a is a true array: all 100 
storage cells have been allocated, and 
the conventional rectangular subscript 
calculation is done. For b, however, 
the declaration has only allocated 10 
pointers; each must be set to point to an 
array of integers. Assuming each does 
point to a 10-element array, then there 
will be 100 storage cells set aside, plus the 
10 cells for the pointers. Thus the array 
of pointers uses slightly more space and 
may require an extra initialization step, 
but has two advantages: it trades an 
indirection for a subscript multiplication, 
and it permits the rows of the array to be 
of different lengths. (That is, each ele¬ 
ment of b need not point to a 10- 
element vector; some may point to 2 
elements, some to 20). Particularly with 
strings whose length is not known in 
advance, an array of pointers is often 
used instead of a multidimensional array. 
Every C main program gets access to its 
invoking command line in this form, for 
example. 

The idea of specifying types by ap¬ 
propriating some of the syntax of 
expressions seems to be original with C, 
and for the simpler cases, it works well. 
Occasionally some rather ornate types are 
needed, and the declaration may be a bit 
hard to interpret. For example, a pointer 
to an array of pointers to functions, each 
returning an int, would be written 

int (*(*funnyarray)[])(); 

which is certainly opaque, although 
understandable enough if read from the 
inside out. In an expression, funnayarray 
might appear as 

i = (*(*funnyarray)[j] )(k); 

The corresponding Algol 68 declaration is 

ref [] ref proc int funny array 

which read from left to right in corre¬ 
spondence with the informal description 
of the type if ref is taken to be the equiv¬ 
alent of C’s “pointer to.” The Algol may 
be clearer, but both are hard to grasp. 

III. STATEMENTS AND 
CONTROL FLOW 

Control flow in C differs from other 
languages primarily in details of syntax. 
As in PL/1, semicolons are used to 


terminate statements, not to separate 
them. Most statements are just expres¬ 
sions followed by a semicolon; since 
assignments are expressions, there is no 
need for a special assignment statement. 

Statements are grouped with braces { 
and } , rather than with words like begin - 
end or do-od, because the more concise 
form seems much easier to read and is 
certainly easier to type. A sequence of 
statements enclosed in { } is syntac¬ 
tically a single statement. 

The if-else statement has the form 

if ( expression ) 
statement 
else 

statement 

The expression is evaluated; if it is “true” 
(that is, if expression has a non-zero 
value), the first statement is done. If it is 
“false” ( expression is zero) and if there is 
an else part, the second statement is 
executed instead. The else part is option¬ 
al; if it is omitted in a sequence of nested 
iFs, the resulting ambiguity is resolved in 
the usual way by associating the else with 
the nearest previous else-less if. 

The switch statement provides a multi¬ 
way branch depending on the value of an 
integer expression: 

switch ( expression ) 
case const: 

code 
case const : 
code 

default: 

^ code 

The expression is evaluated and compared 
against the various cases, which are la¬ 
beled with distinct integer constant 
values. If any case matches, execution 
begins at that point. If no case matches 
but there is a default statement, execu¬ 
tion begins there: otherwise, no part of 
the switch is executed. 

The cases are just labels, and so con¬ 
trol may flow through one case to the 
next. Although this permits multiple 
lables on cases, it also means that in gen¬ 
eral most cases must be terminated with 
an explicit exit from the switch (the 

break statement below). 

The switch construction is part of C’s 
legacy from BCPL; it is so useful and so 
easy to provide that the lack of a 
corresponding facility of acceptable 
generality in languages ranging from For- 


Number 45 

194 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 



tran through Algol 68, and even to Pascal 
(which does not provide for a default), 
must be considered a real failure of 
imagination in language designers. 

C provides three kinds of loops. The 
while is simply 

while ( expression ) 
statement 

The expression is evaluated; if it is true 
(non-zero), the statement is executed, 
and then the process repeats. When 
expression becomes false (zero), execu¬ 
tion terminates. 

The do statement is a test-at-the- 
bottom loop: 

do 

statement 

while ( expression ); 

statement is performed once, then ex¬ 
pression is evaluated. If it is true, the loop 
is repeated; otherwise it is terminated. 

The for loop is reminiscent of similar¬ 
ly named loops in other languaged, but 
rather more general. The for statement 

for (exprl ; expr2 ; expr3) 
statement 

is equivalent to 

exprl ; 

while (exprl) 
statement 
expr3 ; 

} 

Grammatically, the three components of 
a for loop are expressions. Any of the 
three parts can be omitted, although the 
semicolons must remain. If exprl or 
expr3 is left out, it is simply dropped 
from the expansion. If the test, expr2, is 
not present, it is taken as permanently 
true, so 

for (;;) 


is an “infinite” loop, to be broken by 
other means, for example by break, 
below. 

The for statement keeps the loop 
control components together and visible 
at the top of the loop, as in the idiomatic 

for (i = 0; i < N;i = i+1) 


which processes the first N elements of an 
array, the analogue of the Fortran or 
PL/1 DO loop. The for is more general, 
however. The test is re-evaluated on each 
pass through the loop, ana there is no 
restriction on changing the variables 
involved in any of the expressions in the 
for statement. The controlling variable 
i retains it value regardless of how the 
loop terminates. And since the compo¬ 
nents of a for are arbitrary expressions, 
for loops are not restricted to arithmetic 
progressions. For example, the classic 
walk along a linked list is 

for (p = top; p != NULL; p = p - > next) 


There are two statements for control¬ 
ling loops. The break statement, as men¬ 
tioned, causes an immediate exit from the 
immediately enclosing while, for, do or 
switch. The continue statement causes 
the next iteration of the immediately 
enclosing loop to begin, break and con¬ 
tinue are asymmetric, since continue does 
not apply to switch. 

Finally, C provides the oft-maligned 
goto statement. Empirically, goto’s are 
not much used, at least on our system. 
The operating system itself, for example, 
contains 98 in some 8300 lines. The PDP- 
11 C compiler, in 9660 lines, has 147. 
Essentially all of these implement some 
form of branch to the top or bottom of 
a loop, or to error recovery code. 

IV. OPERATORS AND 
EXPRESSIONS 

C has been characterized as having a 
relatively rich set of operators. Some of 
these are quite conventional. For 
example, the basic binary arithmetic 
operators are +, -, * and /. To these, C 
adds the modulus operator %: m%n is the 
remainder when m is divided by n. 

Besides the basic logical or bitwise 
operators & (bitwise AND), and I (bit¬ 
wise OR), there are also the binary 
operators A (bitwise exclusive OR), 
>> (right shift), and << (left shift), 
and the unary operator — (ones comple¬ 
ment). These operators apply to all inte¬ 
gers; C provides no special bit-string type. 

The relational operators are the usual 
>, > = , <, <=, == (equality test), and 
!= (inequality test). They have the value 
1 if the stated relation is true, 0 if not. 

The unary pointer operators * (for 
indirection) and & (for taking the ad¬ 
dress) were described in Section 1. When 


y is such as to make the expressions 
&*y or &*y legal, either is just equal to 
y. Note that & and * are used as both 
binary and unary operators (with dif¬ 
ferent meanings). 

The simplest assignment is written =, 
and is used conventionally: the value of 
the expression on the right is stored in 
the object whose address is on the left. 
In addition, most binary operators can be 
combined with assignment by writing 

a op= b 

which has the effect of 
a = a op b 

except that a is only evaluated once. For 
example, 

x += 3 

is the same as 

x = x + 3 

if x is just a variable, but 
p[i+j + 1] + = 3 

adds 3 to the element selected from the 
array p, calculating the subscript only 
once, and, more importantly, requiring it 
to be written out only once. Compound 
assignment operators also seem to cor¬ 
respond well to the way we think; “add 3 
to x” is said, if not written, much more 
commonly than “assign x + 3 to x.” 

Assignment expressions have a value, 
just like other expressions, and may be 
used in larger expressions. For example, 
the multiple assignment 

i = j = k = 0; 

is a byproduct of this fact, not a special 
case. Another very common instance is 
the nesting of an assignment in the 
condition part of an if or a loop, as in 

while (c = getchar()) != EOF) ... 

which fetches a character with the func¬ 
tion getchar, assigns it to c, then tests 
whether the result is an end of file mark¬ 
er. (Parentheses are needed because the 
precedence of the assignment = is lower 
than that of the relational !=.) 

C provides two novel operators for 
incrementing and decrementing variables. 
The increment operator + + adds 1 to its 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

195 



operand; the decrement operator -- 
subtracts 1. Thus the statement 

+ + i; 

increments i. The unusual aspect is that 
+ + and -- may be used either as prefix 
operators (before the variable, as in + + i), 
or postfix (after the variable i + +). In 
both cases, the effect is to increment i. 
But the expression + + i increments i 
before using its value, while i + + incre¬ 
ments i after its value has been used. If 
i is 5, then 

x = i + +; 
sets x to 5, but 

x = + + i; 

sets x to 6. In both cases, i becomes 6. 
For example, 

stack[i + +] = ... ; 

pushes a value on a stack stored in an 
array stack indexed by i, while 

... = stack[--i]; 

retrieves the value and pops the stack. Of 
course, when the quantity incremented 
or decremented is a pointer, appropriate 
scaling is done, just as if the “1” were 
added explicitly: 

*stackp + + =...; 

... = *--stackp; 

are analogous to the previous example, 
this time using a stack pointer instead of 
an index. 

Tests may be combined with the log¬ 
ical connectives && (AND), || (OR), and 
! (truth value negation). The && and || 
guarantee left-to-right evaluation, with 
termination as soon as the truth value is 
known. For example,in the test 

if (i < = N && array [i] >0 ... 

if i is greater than N, then array [i] 
(presumably at that point an out-of- 
bounds reference) will not be accessed. 
This predictable behavior is especially 
convenient, and much preferable to the 
explicitly random order of evaluation 
promised by most other languages. Most 
C programs rely heavily on the properties 
of && and ||. 

Finally, the conditional expression, 
written with the ternary operator ?:, 


provides an analogue of if -else in expres¬ 
sions. In the expression 

el ? e2 : e3 

the expression el is evaluated first. If it is 
non-zero (true), then the expression e2 
is evaluated, and that is the value of the 
conditional expression. Otherwise, e3 is 
evaluated, and that is the value. Only one 
of e2 and e3 is evaluated. Thus to set 
z to the maximum of a and b, 

z = (a > b) ? a : b;/* z = max(a, b) */ 

We have already discussed how inte¬ 
gers are scaled appropriately in pointer 
arithmetic. C does a number of other 
automatic conversions between data 
types, more freely than Pascal, for 
example, but without the wild abandon 
of PL/1. In all contexts, char variables 
and constants are promoted to int. This is 
particularly handy in code like 

n = c - ‘O’; 

which assigns to n the integer value of the 
character stored in c, by subtracting the 
value of the character *0’. Generally, in 
fact, the basic types fall into only two 
classes, integral and floating-point; char 
variables, and the various lengths of int’s, 
are taken to be representations of the 
same kind of thing. They occupy differ¬ 
ent amounts of storage but are essentially 
compatible. Boolean values as such do 
not exist; relational or truth-value expres¬ 
sions have value 1 if true, and 0 if false. 

Variables of type int are converted to 
floating-point when combined with floats 
or doubles and in fact all floating arith¬ 
metic is carried out in double precision, 
so floats are widened to double in 
expressions. 

Conversions that involve “narrowing” 
an expression (for example, when a 
longer value is assigned to a shorter) are 
also well behaved. Floating point values 
are converted to integer by truncation; 
integers convert to shorter integers or 
characters by dropping high-order bits. 

When a conversion is desired, but is 
not implicit in the context, it is possible 
to force a conversion by an explicit 
operator called a cast. The expression 

{type) expression 

is a new expression whose type is that 
specified in type, for example, the sin 
routine expects an argument of type 
double; in the statement 


x = sin((double) n); 

the value of n is converted to double 
before being passed to sin. 

V. THE STRUCTURE OF 
C PROGRAMS 

Complete programs consist of one 
or more files containing function and 
data declarations. Thus, syntactically, a 
program is made up of a sequence of 
declarations; executable code appears 
inside functions. Conventionally, the run¬ 
time system arranges to call a function 
named main to start execution. 

The language distinguishes the notions 
of declaration and definition. A decla¬ 
ration merely announces the properties 
of a variable (like its type); a definition 
declares a variable and also allocates 
storage for it or, in the case of a function, 
supplies the code. 

5.1 Functions 

The notion of function in C includes 
the subroutines and functions of FOR¬ 
TRAN and the procedures of most other 
languages. A function call is written 

namefarglist) 

where the parentheses are required even 
if the argument fist is empty. All func¬ 
tions may be used recursively. 

Arguments are passed by value, so 
the called function cannot in any way 
affect the actual argument with which it 
was called. This permits the called pro¬ 
gram to use its formal arguments as 
conveniently initialized local variables. 
Call by value also eliminates the class 
of errors, familiar to FORTRAN pro¬ 
grammers, in which a constant is passed 
to a subroutine that tries to alter the 
corresponding argument. An array name 
as an actual argument, however, is con¬ 
verted to a pointer to the first array 
element (as it always is), so the effect 
is as if arrays were called by reference; 
given the pointer, the called function 
can work its will on the individual 
elements of the array. When a function 
must return a value through its argument 
list, an explicit pointer may be passed, 
and the function referencec the ultimata 
target through this pointer. For example, 
the function swapfpa, pb) interchanges 
two integers pointed to by its arguments: 


Number 45 

196 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 



swap(px, py) /* flip int’s 

pointed to by px 
and py */• 

int *px, *py; 

int temp; 

{ 

temp = *px; 

*px = *py; 

*py = temp; 

} 

This also demonstrates the form of 
a function definition: the name is fol¬ 
lowed by an argument list; the arguments 
are declared, and the body of the func¬ 
tion is a block, or compound statement, 
enclosed in braces. Declarations of local 
variables may follow the opening brace. 

A function returns a value by 
return expression ; 

The expresssion is automatically coerced 
to the type that the function returns. 
By default, functions are assumed to re¬ 
turn int; if this is not the case, the func¬ 
tion must be declared both in the cal¬ 
ling routine and when it is defined. 
For example, a function definition is 

double sqrt(x) /* returns square root 
of x */ 

double x; 

{ 

} 

In the caller, the declaration is 

double y, sqrt(); 

« 

y = sqrt(y); 

A function argument may be any of 
the basic types or a pointer, but not an 
array, structure, union, or function. 
The same is true of the value returned 
by a function, (the most recent versions 
of the language, still not standard every¬ 
where, permit structures and unions as 
arguments and values of functions and 
allow them to be assigned.) 

5.2 Data 

Data declared at the top level (that is, 
outside the body of any function defi¬ 
nition) are static in lifetime, and exist 
throughout the execution of the pro¬ 


gram. Variables declared within a func¬ 
tion body are by default automatic-. 
they come into existence when the func¬ 
tion is entered and vanish when it is 
exited. Automatic variables may be 
declared to be register variables; when 
possible they will be placed in machine 
registers, which may result in smaller, 
faster code. The register declaration 
is only considered a hint to the compiler; 
no hardware register names are men¬ 
tioned, and the hint may be ignored if 
the compiler wishes. 

Static variables exist throughout the 
execution of a program, and retain their 
values across function calls. Static vari¬ 
ables may be local to a function or (if 
defined at the top level) common to 
several functions. 

External variables have the same life¬ 
time as static, but they are also accessible 
to programs from other source files. That 
is, all references to an identically named 
external variable are references to the 
same thing. 

The “storage class” of a variable can 
be explicitly announced in its 
declaration: 


static int x; 
extern double y [ 10]; 

More often the defaults for the context 
are sufficient. Inside a function, the 
default is auto (for automatic). Outside 
a function, at the top level, the default 
is extern. Since automatic and register 
variables are specific to a particular call 
of a particular function, they cannot be 
declared at the top level. Neither top- 
level variables nor functions explicitly 
declared static are visible to functions 
outside the file in which they appear. 

5.3 Scope 

Declarations may appear either at the 
top level or at the head of a block 
(compound statement). Declarations in 
an inner block temporarily override those 
of identically named variables outside. 
The scope of a declaration persists until 
the end of its block, or until the end of 
the file, if it was at the top level. 

Since function definitions may be 
given only at the top level (that is, they 
may not be nested), there are no internal 
procedures. They have been forbidden 
not for any philosophical reason, but 
only to simplify the implementation. It 
has turned out that the ability to make 
certain functions and data invisible to 


programs in other files (by explicitly 
declaring them static) is sufficient to 
provide one of their most important 
uses, namely hiding their names from 
other functions. (However, it is not 
possible for one function to access the 
internal variables of another, as internal 
procedures could do.) Similarly, the 
ability to conceal functions and data in 
one file from access by another satisfies 
some of the most crucial requirements of 
modular programming (as in languages 
like Alphard, CLU, and Euclid), even 
through it does not satisfy them all. 

VI. C PREPROCESSOR 

It is well recognized the “magic num¬ 
bers” in a program are a sign of bad 
programming. Most languages, therefore, 
provide a way to define symbolic names 
for constants, so that the value of a magic 
number need be specified in only one 
place, and the rest of the code can refer 
to the value by some mnemonic name. 
In C such a mechanism is available, but 
it is not part of the syntax of the 
language; instead, symbolic naming is 
provided by a macro preprocessor auto¬ 
matically invoked as part of every C 
compilation. For example, given the 
definitions 

# define PI 3.14159 

#define E 2.71284 

the preprocessor replaces all occurrences 

of a defined name by the corresponding 
defining string. (Upper-case names are 
normally chosen to emphasize that these 
are not variables.) Thus, when the pro¬ 
grammer recognizes that he has written 
an incorrect value for e, only the defini¬ 
tion line has to be changed to 

# define E 2.71828 

instead of each instance of the constant 
in the program. 

Providing this service by a macro 
processor instead of by syntax has some 
significant advantages. The replacement 
text is not restricted to being numbers; 
any string of characters is permitted. 
Furthermore, the token being replaced 
need not be a variable, although it must 
have the form of a name. For example, 
one can define 

# define forever for(;;) 
and then writen infinite loops as 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

197 



forever { 

} 

The macro processor also permits 
macros to have arguments; this capability 
is heavily used by some I/O packages. 

A second service of the C preprocessor 
is library file include: a source line of 
the form 

#include “name” 

causes the contents of the file name to be 
interpolated into the source at that 
point, (includes may be nested.) This 
feature is much used, especially in 
larger programs, for making sure that 
all the source files of the program are 
supplied with identical # defines, global 
data declarations, and the like. 

VII. ENVIRONMENTAL 
CONSIDERATIONS 

By intent, the C language confines 
itself to facilities that can be mapped 
relatively efficiently and directly into 
machine instructions. For example, 
writing matrix operations that look ex¬ 
actly like scalar operations is possible in 
some programming languages and 
occasionally misleads programmers into 
believing that matrix operations are 
as cheap as scalar operations. More 
important, restricting the domain of the 
C compiler to those areas where it knows 
how to do a relatively efficient job 
provides the freedom to design sub¬ 
routine libraries for the remaining tasks 
without constraining them to fit into 
some language specification. When the 
compiler cannot implement some facility 
without heavy costs in nonportability, 
complexity, or efficiency, there are many 
benefits to leaving out such a facility: it 
simplifies the language and the compiler, 
frequently without inconveniencing the 
user (who often rejects a high-cost 
built-in operation and does it himself 
anyway). 

At present, C is restricted to simple 
operations on simple data types. As a 
result, although the C area of operation 
is comparatively clean and pleasant, the 
user must know something about the 
polluting effects of the environment to 
get most jobs done. A program can 
always access the raw system calls on 
each system if very close interaction with 
the operating system is needed, but 
standard library routines have been imple¬ 


mented in each C environment that try to 
encourage portability while retaining 
speed and flexibility. The basic areas 
covered by the standard library at present 
are storage allocation, string handling, 
and I/O. Additional libraries and utilities 
are available for such areas as graphics, 
coroutine sequencing, execution time 
monitoring, and parsing. 

The only automatic storage manage¬ 
ment service provided by C itself is the 
stack discipline for automatic variables. 
Two subroutines exist for more flexible 
storage handling. The function 
calloc(n,s) returns a pointer to a 
properly aligned storage block that will 
hold n items each of which is s bytes 
long. Normally s is obtained from the 
sizeof pseudo-function, a compile-time 
function that yields the size in bytes of a 
variable or data type. To return a block 
obtained from calloc to the free storage 
pool, cfree(p) may be called, where p is 
a value returned by a previous call to 
calloc. 

Another set of routines deals with 
string handling. There is no “string” data 
type, but an array of characters, with a 
convention that the end of a string is 
indicated by a null byte, can be used for 
the same purpose. The most commonly 
used string routines perform the func¬ 
tions of copying one string to another, 
comparing two strings, and computing 
a string length. More sophisticated string 
operations can often be performed using 
the I/O routines, which are described 
next. 

Most of the routines in the standard 
library deal with input and output. Most 
C programmers use stream I/O, although 
there is no reason why record I/O could 
not be used with the language. There are 
three default streams: the standard input, 
the standard output, and the error 
output. The most elementary routines for 
dealing with these streams are getchar() 
which reads a character from the standard 
input, and putchar(c), which writes the 
character c on the standard output. In the 
environments in which C programs run, it 
is generally possible to redirect these 
streams to files or other programs; the 
program itself does not change and is 
unaware of the redirection. 

The most common output function is 
printf(format, datal, data2,...), which 
performs data conversion for formatted 
output. The string format is copied to the 
standard output, except that when a 
conversion specification introduced by a 
% character is found in format it is 


replaced by the value of the next data 
argument, converted according to the 
specification. For example, 

printf (”n = %d, x = %f”, n, x); 

prints n as a decimal integer and x as a 
floating point number, as in 

n = 17, x = 12.34 

A similar function scanf performs for¬ 
matted input conversion. 

All the routines mentioned have 
versions that operate on streams other 
than the standard input or output, and 
printf and scanf variants may also process 
a string, to allow for in-memory format 
conversion. Other routines in the I/O 
library transmit whole lines between 
memory and files, and check for error or 
end-of-file status. 

Many other routines and utilities are 
used with C, somewhat more on UNIX 
than on other systems. As an example, 
it is possible to compile and load a C 
program so that when the program is run, 
data are collected on the number of times 
each function is called and how long it 
executes. This profile pinpoints the 
parts of the program that dominate the 
run-time. 

VIII. EXPERIENCE WITH C 

C compilers exist for the most widely 
used machines at Bell Laboratories (the 
IBM S/370, Honeywell 6000, PDP-11) 
and perhaps 10 others. Several hundred 
programmers within Bell Laboratories 
and many outside use C as their primary 
programming language. 

8.1 Favorable experiences 

C has completely displaced assembly 
language in UNIX programs. All applica¬ 
tions code, the C compiler itself, and the 
operating system (except for about 1000 
lines of initial bootstrap, etc.) are written 
in C. Although compilers or interpreters 
are available under UNIX for Fortran, 
Pascal, Algol 68, Snobol, APL, and other 
languages, most programmers make little 
use of them. Since C is a relatively low- 
level language, it is adequately efficient 
to prevent people from resorting to 
assembler, and yet sufficiently terse and 
expressive that its users prefer it to PL/1 
or other very large languages. 

A language that doesn’t have every¬ 
thing is actually easier to program in than 


Number 45 

198 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 



some that do. The limitations of C often 
imply shorter manuals and easier training 
and adaptation. Language design, espe¬ 
cially when done by a committee, often 
tends toward including all doubtful 
features, since there is no quick answer to 
the advocate who insists that the new 
feature will be useful to some and can be 
ign ored by others. But this results in long 
manuals and hierarchies of “experts” who 
know progressively larger subsets of the 
language. In practice, if a feature is not 
used often enough to be familiar and does 
not complete some structure of syntax or 
semantics, it should probably be left out. 
Otherwise, the manual and compiler get 
bulky, the users get surprises, and it 
becomes harder and harder to maintain 
and use the language. It is also desirable 
to avoid language features that cannot be 
compiled efficiently; programmers like to 
feel that the cost of a statement is com¬ 
parable to the difficulty in writing it. C 
has thus avoided implementing operations 
in the language that would have to be 
performed by subroutine call. As com¬ 
piler technology improves, some exten¬ 
sions (e.g., structure assignment) are 
being made to C, but always with some 
principles in mind. 

One direction for possible expansion 
of the language has been explicitly 
avoided. Although C is much used for 
writing operating systems and associated 
software, there are no facilities for multi¬ 
programming, parallel operations, syn¬ 
chronization, or process control. We 
believe that making these operations 
primitives of the language is inappro¬ 
priate, mostly because language design is 
hard enough in itself without incorpo¬ 
rating into it the design of operating 
systems. Language facilities of this sort 
tend to make strong assumptions about 
the underlying operating system that may 
match very poorly what it actually does. 

8.2 Unfavorable experiences 

The design and implementation of C 
can (or could) be criticized on a number 
of points. Here we discuss some of the 
more vulnerable aspects of the language. 

8.2.1 Language level 

Some users complain that C is an 
insufficiently high-level language; for 
example, they want string data types and 
operations, or variable-size multi-dimen¬ 
sional arrays, or generic functions. Some¬ 
times a suggested extension merely 


involves lifting some restriction. For 
example, allowing variable-size arrays 
would actually simplify the language 
specification, since it would only involve 
allowing general expressions in place of 
constants in certain contexts. 

Many other extensions are plausible; 
since the low level of C was praised in the 
previous section as an advantage of the 
language, most will not be further 
discussed. One is worthy of mention, 
however. The C language provides no 
facility for I/O, leaving this job to 
library routines. The following fragment 
illustrates one difficulty with this 
approach: 

printf(”%d\n”, x); 

The problem arises because on machines 
on which int is not the same as long, x 
may not be long; if it were, the program 
must be written 

printf(”%D\n”,x); 

so as to tell printf the length of x. Thus, 
changing the type of x involves changing 
not only its declaration, but also other 
parts of the program. If I/O were built 
into the language, the association 
between the type of an expression and 
the format in which it is printed could 
be reconciled by the compiler. 

8.2.2 Type safety 

C has traditionally been permissive in 
checking whether an expression is used in 
a context appropriate to its type. A 
complete fist of examples would be long, 
but two of the most important should 
illustrate sufficiently. The types of formal 
arguments of functions are in general not 
known, and in any case are not checked 
by the compiler against the actual argu¬ 
ments at each call. Thus in the statement 

s = sin(l); 

the fact that the sin routine takes a 
floating-point argument is not noticed 
until the erroneous result is detected by 
the programmer. 

In the structure reference 

p -> memb 

p is simply assumed to point to a struc¬ 
ture of which memb is a member; p might 
even be an integer and not a pointer at 
all. 


Much of the explanation, if not justifi¬ 
cation, for such laxity is the typeless 
nature of C’s predecessor languages. 
Fortunately, a justification need no 
longer be attempted, since a program is 
now available that detects all common 
type mismatches. This utility, called lint 
because it picks bits of fluff from 
programs, examines a set of files and 
complains about a great many dubious 
constructions, ranging from unused or 
uninitialized variables through the type 
errors mentioned. Programs that pass 
unscathed through lint enjoy about as 
complete freedom from type errors as 
do Algol 68 programs, with a few excep¬ 
tions: unions are not checked dynamical¬ 
ly, and explicit escapes are available that 
in effect turn off checking. 

Some languages, such as Pascal and 
Euclid, allow the writer to specify that 
the value of a given variable may assume 
only a given subrange of the integers. This 
facility is often connected with the usage 
of arrays, in that any array index must be 
a variable or expression whose type 
specifies a subset of the set given by 
the bounds of the array. This approach 
is not without theoretical difficulties, 
as suggested by Habermann. 4 In itself 
it does not solve the problems of variables 
assuming unexpected values or of ac¬ 
cessing outside array bounds; such things 
must (in general) be detected dynam¬ 
ically. Still, the extra information pro¬ 
vided by specifying the permissible range 
for each variable provides valuable 
information for the compiler and any 
verifier program. C has no corresponding 
facility. 

One of the characteristic features of 
C is its rather complete integration of 
the notion of pointer and of address 
arithmetic. Some writers, notably 
Hoare, 5 have argued against the very 
notion of pointer. We feel, however, that 
the facilities offered by pointers are too 
valuable to give up lightly. 

8.2.3 Syntax peculiarities 

Some people are annoyed by the terse¬ 
ness of expression that is one of the 
characteristics of the language. We view 
C’s short operators and general lack of 
noise as a benefit. For example, the 
use of braces for grouping instead 

of begin and end seems appropriate in 
view of the frequency of the operation. 
The use of braces even fits well into 
ordinary mathematical notation. 


Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

199 



Terseness can lead to code that is hard 
to read, however. For example, 

* + + * argv 

where argv has been declared char **argv 
(pointer to an array of character pointers) 
means: select the character pointer 
pointed at by argv (*argv), increment it 
by one (++*argv), then fetch the 
character that that pointer points at 
(* + + *argv). This is concise and efficient 
but reminiscent of APL. 

An example of a minor problem is the 
comment convention, which is PL/l’s 
I* ... */. Comments do not nest, so an 
effort to “comment out” a section of 
code will fail if that section contains a 
comment. And a number of us can testify 
that it is surprisingly hard to recognize 
when an “end comment” delimiter has 
been botched, so that the comment 
silently continues until the next comment 
is reached, deleting a line or two of code. 
It would bemore convenient if a single 
unique character were reserved to intro¬ 
duce a comment, and if comments always 
terminated at an end of line. 

8.2.4 Semantic peculiarities 

There are some occasionally surprising 
operator precedences. For example, 

a » 4 + 5 

shifts right by 9. Perhaps worse, 

(x & MASK) == 0 

must be parenthesized to associate the 
proper way. Users learn quickly to 
parenthesize such doubtful cases; and 
when feasible lint warns of suspicious 
expressions (including both of these). 

We have already mentioned the fact 
that the case actions in a switch flow 
through unless explicitly broken. In 
practice, users write so many switch 
statements that they become familiar 
with this behavior and some even prefer 
it. 

Some problems arise from machine 
differences that are reflected, perhaps 
unnecessarily, into the semantics of C. 
For example, the PDP-11 does sign 
extension on byte fetches, so that a 
character (viewed arithmetically) can 
have a value ranging from -128 to 
+ 127, rather than 0 to +255. Although 
the reference manual makes it quite 
clear that the precise range of a char 
variable is machine dependent, program¬ 


mers occasionally succumb to the tempta¬ 
tion of using the full range that their local 
machine can represent, forgetting that 
their programs may not work on another 
machine. The fundamental problem, of 
course, is that C permits small numbers, 
as well as genuine characters, to be stored 
in char variables. This might not be 
necessary if, for example, the notion of 
subranges (mentioned above) were intro¬ 
duced into the language. 

8.2.5 Miscellaneous 

C was developed and is generally used 
in a highly responsive interactive environ¬ 
ment, and accordingly the compiler 
provides few of the services usually 
associated with batch compilers. For 
example, it prepares no listing of the 
source program, no cross reference table, 
and no indication of the nature of the 
generated code. Such facilities are avail¬ 
able, but they are separate programs, not 
parts of the compiler. Programmers used 
to batch environments may find it hard 
to live without giant listings; we would 
find it hard to use them. 

IX. CONCLUSIONS AND 
FUTURE DIRECTIONS 

C has continued to develop in recent 
years, mostly by upwardly compatible 
extensions, occasionally by restrictions 
against manifestly nonportable or illegal 
programs that happened to be compiled 
into something useful. The most recent 
major changes were motivated by the 
extension of C to other machines, and 
the resulting emphasis on portability. 
The advent of union and of casts reflects 
a desire to be more precise about types 
when moving to other machines is in 
prospect. These changes have had relative¬ 
ly little effect on programmers who 
remained entirely on the UNIX system. 
Of more importance was a new library, 
which changed the use of a “portable” 
library from an option into an effective 
standard, while simultaneously increasing 
the efficiency of the library so that users 
would not object. 

It is more difficult, of course, to 
speculate about the future. C is now 
encountering more and more foreign 
environments, and this is producting 
many demands for C to adapt itself to 
the hardware, and particularly to the 
operating systems, of other machines. 
Bit fields, for example, are a response to 
a request to describe externally imposed 


data layouts. Similarly, the procedures 
for external storage allocation and 
referencing have been made tighter to 
conform to requirements on other 
systems. Portability of the basic language 
seems well handled, but interactions with 
operating systems grow ever more com¬ 
plex. These lead to requests for more 
sophisticated data descriptions and initial¬ 
izations, and even for assembler windows. 
Further changes of this sort are likely. 

What is not likely is a fundamental 
change in the level of the language. 
Realistically, the very acceptance of C has 
compelled changes to be made only most 
cautiously and compatibly. Should the 
pressure for improvements become too 
strong for the language to accommodate, 
C would probably have to be left as is, 
and a totally new language developed. We 
leave it to the reader to speculate on 
whether it should be called D or P. 

REFERENCES 

1. B. W. Kemighan and D. M. Ritchie, The C 
Programming Language, Englewood Cliffs, 
N.J.: Prentice-Hail, 1978. 

2. M. Richards, “BCPL: A Tool for Compiler 
Writing and Systems Programming,” Proc. 
AFIPS SJCC, 34 (1969), pp. 557-566. 

3. S. C. Johnson and B. W. Kernighan, “The 
Programming Language B,” Comp. Sci. 
Tech Rep. No. 8, Bell Laboratories (January 
1973). 

4. A. N. Habermann, “Critical Comments on 
the Programming Language PASCAL,” 
Acta Informatica, 3 (1973), pp. 47-58. 

5. C. A. R. Hoare, “Data Reliability,” ACM 
SIGPLAN Notices, 10 (June 1975), 
pp. 528-533. 



Number 45 

200 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 



Structured 


programming, 


Compound Statements 

When you write a program, you write 
a list of statements: 

x = x - 1 
a = b + c 
b = b * 2 —c 
x = b - a 

The idea behind a compound state¬ 
ment is to make one statement—a mole¬ 
cule—out of a set of statements —some 
atoms. This is done in tiny-c by 

[ x= x-1 
a = b + c 
b = b * 2 — c 
x = b - a ] 

Anywhere you can write a simple 
statement you can also write a compound 
statement. This sounds simple, but the 
effect is powerful. For example most 
programming languages have an if state¬ 
ment similar to this: 



BY T. A. GIBSON AND S. B. GUTHERY 

tiny-c associates 
P.0. Box 269 
Holmdel, N.J. 07733 

Perhaps you have heard structured 
programming described as “go-to-less” 
programming. Or programming with just 
if-then-else and do-while control state¬ 
ments. Such remarks oversimplify what 
structured programming is all about. 
The essence of structured programming 
is PROGRAM CLARITY. You can 
write programs in small, modular parts 
with easy-to-follow program flow. You 
can use well-chosen, descriptive variable 
names. This leads to clear, humanly 
understandable programs. That is the real 
objective of structured programming. 

We discuss here three principle ideas 
that make program clarity possible. 
These are: modularity, predictable pro¬ 
gram flow, and local variables. 

MODULARITY in software is just as 
important as modularity in hardware. 
It makes it humanly possible to deal 
with complexity. A module is a brick 
or atom used for building bigger modules. 
Seen from within, a module may be 
very complex but from the outside it is 
an indivisible whole. Software modularity 
is achieved through the use of FUNC¬ 
TIONS. 


© 1980, tiny-c associates 


PROGRAM FLOW is predictable if 
you can point to any statement and easily 
answer the question “under what condi¬ 
tions is this statement executed?” This is 
particularly important if the program is 
20 or 30 pages long and still has bugs. 
Scanning the whole program and draw¬ 
ing arrows is no fair. That’s not consid¬ 
ered an easy way to answer the question. 
Predictable program flow can be achieved 
in many ways. In C, it is done with COM¬ 
POUND STATEMENTS. 

Functions also make it possible to 
hide variables used in a strictly local 
context. The variable n is very popular; 
it’s used frequently to count things. 
Have you ever had a program blow up 
because you were using n in two places 
for two purposes? The fix was to change 
one of them to nl. A better idea is in 
the concept of LOCAL and GLOBAL 
variables. 

David Gries suggests structured pro¬ 
gramming be called “simplicity theory,” 
and characterizes it as “an approach to 
understanding the complete programming 
process” [Gries 1974]. As a pleasant divi¬ 
dend, structured programming is more 
enjoyable than monolithic programming. 
It should certainly, therefore, be a part 
of personal computing. To begin our look 
at tiny-c as a structured programming 
language, let’s look at the foundation of 
functions and predictable program flow — 
the compound statement. 


if (logical expression) statement 
So you can write 
if(x>0) x = x — 1 

But make the statement part compound, 
and you have this capability: 

if (x>0) [ 
b = b*2-c 
a = b + c 
x = x - 1 

1 

This multiline if is not some special 
kind of if. It is still: 

if (logical expression) statement 

But the statement part is compound. The 
compound statement is treated as an in¬ 
divisible unit. It is either all done or all 
not done depending on the value of the 
logical expression. 

The compound statement also is a 
natural for LOOPS. There is a big dif¬ 
ference among the various programming 
languages in how you write loops, but 
they all have one thing in common. 
A loop has a beginning and an end. 
A compound statement can be used to 
express this. The looping statement is: 

while (logical expression) statement 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

201 




Notice the similarity with the if. 
Only the keyword has changed. Here’s 
how while works. The logical expression 
is evaluated. If it is true, then the state¬ 
ment is executed, and then the while is 
done again. The effect is a repeated if, 
i.e., a loop. As long as the logical expres¬ 
sion remains true, the statement is done 
again and again. Eventually something in 
the statement causes the logical expres¬ 
sion to become false, and the loop 
terminates. Of course, the statement can 
be compound, as in: 

while (x>0) [ 
a= b+c 
b = b*2—c 
x = x— 1 
3 

The compound statement is a natural 
way to delimit the beginning and end of 
loops. 

With one simple idea, the compound 
statement, two things are achieved. The 
if statement is more powerful than is 
common in non-structured programming 
languages. The concept of a loop col¬ 
lapses to a simple repeated if or while 
statement. In both situations you are 
stating conditions under which the 
statement — whether simple or com¬ 
pound—is to be executed. 

Nesting Compound Statements 


ANYWHERE YOU CAN WRITE 
A SIMPLE STATEMENT, YOU 
CAN WRITE A COMPOUND 
STATEMENT 


That is a fundamental rule. A compound 
statement contains simple statements. 
Therefore a compound statment can 
contain compound statements. Figure 1 
illustrates this. 


FIGURE 1 

[ x = x- 1 
a = b+c 
b = b* 2 — a 
x = b—a 

1 

a= b+c is a simple statement. The rule says a 
compound statement can be written here. For 
example: 

[ x — x 1 
[ a=b+c 

w=y+2*x+w 

y -17 

1 

b = b*2—a 
x = b-a 


The substitution of a compound for a 
simple shown in Figure 1 is certainly al¬ 
lowable, but is of no practical value. 

The real utility in nested compounds is 
in writing nested if and while state¬ 
ments. Figure 2 is therefore a more real¬ 
istic example of the use of compound 
statements. 


FIGURE 2 

if(x>0) [ 

while (x <limit) [ 
if (case==l) [ 
y = 0; w = 99 

I 

if (case==2) [ 
y = 99; w = 0 

] 

nextaction 
x = x+l 

1 


In Figure 2 if you remove everything 
except the brackets, you have this: 

[[[][]]] 

This is what is meant by nested com¬ 
pound statements. Brackets are used to 
form program units the same way paren¬ 
theses are used to create arithmetic state¬ 
ments. The main difference is that a 
pair of brackets is preceded by a function 
name, or a logical expression. In the first 
case you’re naming the contents of the 
brackets and in the second you’re stating 
the conditions under which the contents 
are to be executed. 

Readable Program Flow 

In Figure 2, look at the “y = 0” in 
the fourth line. How can it be reached? 
Only if case is 1, and x is less than limit. 
No go-to can lead here, either accident¬ 
ally or on purpose. 

How can “nextaction” be reached? 
Only if x is less than limit, and then only 
after possible changes to y and w. This 
program has simple, predictable flow. The 
only way a statement other than a 
while can be reached is from directly 
above. Whiles can also be reached from 
their matching ] below. 

Indenting and the Placement of Brackets 
in Compound Statements 

The brackets alone define the “struc¬ 
ture” of a program. Indenting means 
nothing. But one of the purposes of 
structured programming is to make pro¬ 
grams more readable and, hence, more 


understandable. A good ghoice of in¬ 
denting style is very important to pro¬ 
gram readability. There are several styles 
to choose from. The actual choice is not 
too important. But once you choose a 
style, stick to it. Consistency IS import¬ 
ant. 

One easily explained style is to align 
matching brackets vertically. This looks 
like: 

if (x>0) 

[ statement 
statement 

»» 

>> 


A problem with this is that when editing 
the first statement, care must be taken to 
keep the [ intact. So some use this 
style: 


if (x>0) 

1 

statement 

statement 



This takes an extra line. Also there is 
a visual break between the if and its 
statements. So some take the left bracket 
and move it to the end of the preceding 
line: 

if (x>0) [ 
statement 
statement 


The right bracket is now vertically 
aligned with the if or while that pre¬ 
ceded the compound statement. 

You may pick one of these, or invent 
a style of your own. But, we repeat, 
whatever you decide to do, do it con¬ 
sistently. 

Functions 

A large software project can usually 
be broken into natural parts, and each 
part programmed and debugged as a 
separate unit. Each of these units then 
becomes a reliable building block for the 
construction of still larger parts of the 
project. Sometimes units can be designed 
to be useful in many projects. 

In various programming languages 
these building blocks are called subpro¬ 
grams, subroutines, or, as in C, FUNC- 


Number 45 

202 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 




TilONS. Here is a tiny-c function for 
any computer versus human game: 

game [ 

getready 

while (stillplaying ( ) ) [ 
humantum 

if (stillplaying ()) computerturn 

i 

gameover 

1 

The name of the function is “game”. 
The compound statement that follows 
is called the body of the function. Each 
[ can be read as “do all of this”, and its 
matching ] read as “end of this”. Game 
divides the design of a game program 
into five parts: 

getready (which initializes things, and 
prints instructions if requested), 
stillplaying (which determines if the game 
is still going, and returns true if it is, other¬ 
wise false), 

humainturn (which conducts the human’s 
turn), 

computerturn (which conducts the com¬ 
puter’s turn), 

gameover (which computes and prints 
scores, makes remarks about the human’s 
skill, promotes the human, or whatever). 

The game function is the first step in 
divide-and-conquer or top-down pro¬ 
gram development. Let’s carry this 
development one step further. The get¬ 
ready function can be expanded this way: 

getready [ 

ps “Do you want instructions?” 
if (gc () ==‘ y 0 instructions 

] 

Getready divides the initialization into 
two parts: instructions, and setupboard. 
(.Note : ps prints a character string, gc() 
reads a character, and ==‘y’ tests if the 
character is a y.) 

Notice that both game and getready 
are universal. They can be used in many 
game programs. Programming in this 
fashion eventually leads to a library of 
useful, general purposes functions these 
can be pulled off the shelf into a soft¬ 
ware project. You know they work be¬ 
cause they were used before. Your pro¬ 
gramming becomes more productive, and 
more pleasant. 

The next time you’re programming a 
sizable project, i.e., anything more than 
a page, try to identify subsets of the 
logic usable in other projects. Capture 
these as functions. 

It is gratifying to discover a general 
purpose function where none was 
suspected. 

Local and Global Variables 

A LOCAL VARIABLE is one that is 
known only inside a function. It can be 
used and changed only within the body of 


the function. Even its name is unknown 
outside the function. In fact, its name 
can be used in other functions without 
conflict. This is what makes local vari¬ 
ables useful . 

Take a look at Figure 3. There are 
four local variables in these two func¬ 
tions. The variables n and maximum 
are local to a function. The variables n 
and total are local to anotherfunction. 
If either of these functions calls the 
other, the values of n will not be con¬ 
fused since they only have meaning in¬ 
side the body of their own functions. 
It helps to think of local variable names 
as being preceded by the possessive form 
of the function to which they are local; 
for example, afunction’s n and another- 
function’s n. 


FIGURE 3 

afunction [ 
int n, maximum 
n=0 

while (n<maximum) [ 


n=n+l 

1 

1 

anotherfunction [ 
int n, total 


n = n + 2 
total = total+n 


1 


The value of locals is obvious to any¬ 
one who has spent a nasty debugging 
session trying to find out where, in a 
huge program, some variable is getting 
changed. 

Of course not all variables can be 
local. Some must be shared by many 
functions. These are called GLOBALS. 
They should be used infrequently, as 
they do cause debugging headaches. 
Choosing good, descriptive names for 
globals alleviates the problem. A global 
named “k”is inviting disaster. Call it 
“klingonsleft” and you’re less likely to 
accidentally use it for two purposes. 
Also you’ve given a reader of your pro¬ 
gram a pretty good clue to the variable’s 
use. 

Summary of Structured Programming 

These concepts: functions, locals and 
globals, and compound statements are 
probably the main tools of structured 
programming. It’s really that simple. 


Many variations and improvements are 
possible. The most important improve¬ 
ment is to the concept of locals and 
globals. This is a special case of the more 
general notion of nested scope of vari¬ 
ables. But we will not go into that here. 

Tiny-c and (BIG) C 

The examples in this article all use 
tiny-c. If you move to BIG C, there are 
a few differences. Tiny-c is a training 
language, just like BASIC. Technically, 
it is a COGNATE of C, not a subset. 
The syntax differences are: 

In C, all statements must end with a semi 
colon(;). In tiny-c they end with the end of 
a line, or a ; or ]. 
or a ; or ]. 

In C, all functions must have parentheses 
around the arguments. In tiny-c they can 
frequently be omitted. 

In C, compound statements use j } in¬ 
stead of [ ], array references use [ ] 
instead of ( ). 

So figure 2 in C looks like: 

if (x>0){ 
while (x < limit){ 
if (case==l){ 
y = 0;w= 99; 

I 

if (case = = 2){ 
y = 99; w = 0; 

I 

nextaction ( ); 
x = x+1; 


Notice that the function call nextaction 
( ); must have the parenthesis, even with 
no arguments. And the semicolons 
shown must all be there. 

The game function is written in C 
like this: 

game ( ) ; | 
getready() ; 
while (stillplaying ()) { 
humantum () ; 

if (stillplaying()) computerturn() ; 

I 

gameover() ; 

I 

There are also differences in the input/ 
output library functions. These differ¬ 
ences are less important than the syntax 
differences, because in C input/output 
is done with function calls, and not built 
into the syntax of the language. 

In C, to print an integer requires this: 

printf ( “ %d”, x) ; 

In tiny-c this suffices: 

pn x 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

203 



Summary of tiny-c and C 


In deriving a training cognate of C, 
we moved to lower case characters ( [ 
instead of { ), removed punctuation 
distracting to students, and introduced 
much simpler input/output functions. 
The resulting language, tiny-c, is as 
easy to learn as BASIC, and serves as a 
good stepping stone into structured 
programming. 

BIBLIOGRAPHY 

Gibson, T. and Guthery, S., The tiny-c 
Owner’s Manual , tiny c associates, 
1978. 

Gibson, Paul, “Stopwatch: A tiny-c 
Program,” CREATIVE COMPUTING, 
Vol. 5, No. 3 (March 1979). 

Gibson, Tom, “Caution: Structured Pro¬ 
gramming Can Be Habit-Forming,” 
CREATIVE COMPUTING, Vol. 5, 
No. 1 (January 1979). 

Gries, David, “On Structured Program¬ 
ming - A Reply to Smoliar,” CACM, 
Vol. 17, No. 11 (November 1974). 
Hancock, L., “Growing, Pruning & Climb¬ 
ing Binary Trees with tiny-c,” DR. 
DOBB’S JOURNAL, Vol. 4, Issue 6 
(June/July 1979). 

Hancock, L., “Dear Doctors, ” letter 
to DR. DOBB’S JOURNAL, Vol. 4, 
Issue 3 (March 1979), on page 9. 
Hancock, L., “Implementing a tiny inter¬ 
preter with a CP/M flavored C,” 
DR. DOBB’S JOURNAL, Vol. 5, 
Issue 1, (January 1980). 

Kern, Christopher O., “A User’s Look at 
tiny-c,” BYTE, Vol. 4, No. 12 (De¬ 
cember 1979). 

Kernighan, Brian W. and Ritchie, Dennis 
M„ THE C PROGRAMMING LAN¬ 
GUAGE, Prentice-Hall Software Series, 
1978. 

Madden, J. Gregory, “C: A Language for 
Microprocessors?,” BYTE, Vol. 2, 
No. 10 (October 1977). 

Newberry, Steve, “A Great Way to 
Learn Structured Programming, tiny— 
c,” part of the article “An Overview 
of CP/M Compatible Software,” DR. 
DOBB’S JOURNAL, Vol. 5, Issue 1 
(January 1980). 

Nussbaum, Frank, “Reader Cs Pascal 
Alternative,” letter to BYTE, page 
142, Vol. 3, No. 11 (November 
1978). 

Shapin, Ted, “Review of tiny-c Owner’s 
Manual,” DR. DOBB’S JOURNAL, 
Vol. 4, Issue 2 (February 1979). 

Zahn, C. T., C NOTES: A Guide to the 
C Programming Language , Yourdon 
Press, 1979. 



Number 45 

204 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 





HELP 

'WITH 



BY LEE BARKER 

Chicago, II. 

OSil’s Fortran, Basic, and Cobol CP/M package was 
purchased a year ago and a number of problems encountered. 
The most serious of these being that Cobol wouldn’t work. 
Last month the updated version was obtained with some of 
the old problems fixed, and a few new ones added. Enclosed is 
a modified hsting of the OSI’s 10 routines that corrects a few 
of the se problems. 

Not covered here is the most serious problem with the new 
operating system. There is a routine in 6502 code, 81 bytes 
into track 0 to initialize the 16 ports starting at 0CF00H. 
CP/M in loading overwrites these ports. If these ports are used 
before being re-initialized the system will lock. 

Other problems include—control S works perhaps 20% of 
the time, but not at all in basic. Microsoft’s Basic was designed 
for the 8080 using the IN, OUT instructions. Since the OSI 
uses ACIAs Basic’s IN, OUT, WAIT do not work. Also if the 
control character 9 is needed for cursor addressing or the 
printer, a string of CHR$(32)s will be obtained instead. 
(TAB) As an alternative, the CURSOR.ASM listing is a 
method of associating a string directly with an address on the 
screen. This simplifies building screens in that only one 
variable is needed to describe a string and its location rather 
than the usual four. 

I hope these listings will provide some help to others who 
may have had similar problems. 

P.S. To Re-init ports 


Fix: 


LXI 

H,0CF2O 

DCR 

L 

DCR 

L 

MVJ 

M,3 

MVJ 

M,17 

JNZ 

Fix + 3 



99 

^ *100 


m 




title 0S1B10S.ASM 

Rewritten 1-0 routines for the 0S1 witn CP/M 

Set up for CRT at 0FC00H 
LPT at 0CF00H 
MODEM at 0CF02H 

Problems with system as delivered: 

1. "S usually didn't worn witn CP/M 

2. “S didn't wor* at all in basic 

3. ChR»(y) prints as a string o t spaces 

4. OSl uses ACiA's so iN OUT A WAiT oon't work 

5. Program's must be rewritten to redirect output 
b. Track 0 initialized the lb ports at UCFQ0H 

which CP/M in loading would clobber. 

if any of tnem were used, tne system wou-Ld lock. 

Corrections: 




; are for #1 to 

5. #0 is handled seperateiy. 

BE00 


ORG 0BE00H 

; jump table 

FC00 

= 

CRT EQU 

OFCOOH ; Main terminal port 

CF00 

s 

LPT EQU 

0CF00H ; Line printer 



; CP/M jump table 

BE00 

CD2DBE 

START: CALL 

CONT ; Cold 

BE03 

CD2DBE 

CALL 

CONT ; Warm 

BE06 

C300BF 

JMP 

READY 

BE09 

C309BF 

JMP 

TTY IN 

BE0C 

C316BF 

JMP 

TTYOUT 

BE0F 

C328BF 

JMP 

PRINT ; Line printer 

BE 12 

C345BF 

JMP 

POUT ; Peripnerai 

BE 15 

C336BF 

JMP 

PIN 

BE 18 

CD2DBE 

CALL 

CONT 

BE IB 

CD2DBE 

CALL 

CONT 

BE IE 

CD2DBE 

CALL 

CONI 

BE21 

CD2DBE 

CALL 

CONI 

BE24 

CD2DBE 

CALL 

CONT 

BE27 

CD2DBE 

CALL 

CONT 

BE2A 

CD2DBE 

CALL 

CONI 



C0NT: 


BF00 


ORG 0BF0OH 

; CP/M OSl 1-0 



; Was a key pressed on the CRT/ 

BF00 

3A00FC 

READY: LDA 

CRT 

BF03 

IF 

RAR 


BF04 

3EO0 

MV1 

A.O 

BF06 

DO 

RNC 


BF07 

3D 

DCR 

A 

BF08 

C9 

RET 




; Input a character from the CRT. 

BF09 

3A00FC 

TTYIN: LDA 

CRT 

BF0C 

IF 

RAR 


BF0D 

D209BF 

JNC 

TTY IN 

BF10 

3A01FC 

LDA 

CRT*1 

BF13 

E67F 

AN1 

127 

BF15 

C9 

RET 




; Output a character to the CRT. 

BF16 

F5 

TTY0UT: PUSH 

PSW 

BF17 

3A00FC 

LDA 

CRT 

BF1A 

IF 

RAR 


BF1B 

DA57BF 

JC 

TEST 

BF1E 

IF 

RAR 


BF1F 

D217BF 

JNC 

TTYOUT*1 

BF22 

79 

MOV 

A, C 

BF23 

3201FC 

STA 

CRT*1 

BF26 

FI 

POP 

PSW 

BF 27 

C9 

RET 




; Output a character to tne line printer. 

BF28 

E5 

PRINT: PUSH 

H 

BF29 

F5 

PUSH 

PSW 

BF2A 

2A53BF 

LHLD 

ADDR 

BF2D 

7E 

PL00P: MOV 

A.M 

BF2E 

IF 

RAR 


BF2F 

IF 

RAR 


BF30 

D22DBF 

JNC 

PLOOP 

BF 

23 

1NX 

H 

BF34 

71 

MOV 

M, C 

BF35 

FI 

POP 

PSW 

BF36 

El 

POP 

H 

BF37 

C9 

RET 




; Input a chr. 

from tne modem (ADDH+2) 

6F30 

2A55bF 

PIN: LHLD 

AODR+2 

BF3B 

7E 

MOV 

A.M 

bFjC 

IF 

RAR 


BF3D 

D2JBBF 

JNC 

PIN*.} 

BF40 

23 

1NX 

H 

BF41 

7E 

MOV 

A ,M 

BF42 

E67F 

AN1 

127 

BF44 

C9 

REI 




; Output a chr. 

to the modem. 

BF45 

2A55BF 

POUT: LHLD 

ADDR*2 


£ 


Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

205 






101 

BF48 

F5 

PUSH 

PSW 

102 

BF49 

7E 

MOV 

A,M 

103 

BF4A 

IF 

RAR 


104 

BF4B 

IF 

RAR 


105 

BF4C 

D249BF 

JNC 

POUT-*.4 

106 

BF4F 

23 

INX 

H 

107 

BF50 

71 

MOV 

M,C 

108 

BF51 

FI 

POP 

PSW 

109 

BF52 

C9 

RET 


110 



; 


111 

BF53 

00CF00CF 

ADDR: DB 

00,207,00,20/ 

112 



; 


113 



; Test for what 

key was entered. 

114 

BF57 

3A01FC 

TEST: LDA 

CRT+1 

115 

BF5A 

Eb/F 

AN1 

127 

116 

BF5C 

FE13 

CPI 

19 ; “S 

117 

BF5E 

C217BF 

JNZ 

moui +1 

110 

BF61 

C357BF 

JMP 

TEST 

119 



; 


120 



; Single entry 

point for the following routines. 

121 

BF64 

3D 

USR: DCR 

A 

122 

BF65 

3D 

DCR 

A ; If passed integer 

123 

BF66 

CA79BF 

JZ 

1NTEG ; Print CHR$(integer mod 25b) 

124 

BF69 

3D 

DCR 

A 

125 

BF6A 

CA7DBF 

JZ 

STRING ; Print exact string to LPT 

126 



; 


127 



; Input a single character. 

128 

BF6D 

CD09BF 

CHAR: CALL 

TTY IN 

129 

BF70 

6F 

MOV 

L, A 

130 

BF71 

2600 

MV I 

H,0 

131 

BF73 

E5 

PUSH 

H 

132 

BF74 

2A0501 

LHLD 

0105H 

133 

BF77 

E3 

XTHL 


134 

BF/8 

C9 

RET 


135 



; 


136 



; Print the CHR 

passed as an integer 0-255. 

137 

BF79 

4E 

1NTEG: MOV 

C,M 

138 

BF7A 

C316BF 

JMP 

TTYOUT 

139 



; 


140 



; Print a string to tne line printer (inc Chn*(y)). 

141 

BF 70 

EB 

STRING: XCHG 


142 

BF7E 

46 

MOV 

B,M 

143 

BF/F 

23 

1NX 

H 

144 

BF80 

5E 

MOV 

E,M 

145 

BF81 

23 

1NX 

H 

146 

BF82 

56 

MOV 

D,M 

147 

BF83 

EB 

XCHG 


148 

BF84 

04 

1NR 

B 

149 

BF85 

05 

SLOOP: DCR 

B 

150 

BF86 

C8 

RZ 


151 

BF87 

4E 

MOV 

C,M 

152 

BF88 

23 

1NX 

H 

153 

BF89 

CD00CF 

CALL 

LPT 

154 

BF8C 

C385BF 

JMP 

SLOOP 

155 



; 


156 

BF8F 


END 








2 

3 



; title 

CURSOR.ASM 

4 



; USR call to 

print string with direct cursor addressing. 

5 



; String is in 

the form "#yyxx." 

7 

BFlO 

= 

CRT EQU 

OBFIbH ; prints to CRT reg. C 

8 

BF09 

= 

CRT1N EQU 

0BF09H ; Returns entered key in reg a 

10 

BFb4 


ORG 0BF64H 


12 

BFb4 

3D 

START: DCR 

A 

13 

BF65 

3D 

DCR 

A ; integer passed'.' 

14 

BFbo 

CA/9BF 

JZ 

1NTEG ; Yup 

15 

BFo9 

3D 

DCR 

A 

16 

BF6A 

CA/DBF 

JZ 

STRING 

17 

BF6D 

CD09BF 

CALL 

CRTiN 

18 

BF70 

6F 

MOV 

L, A 

19 

BF71 

2600 

MVi 

H, 0 

20 

BF73 

E5 

PUSH 

H 

21 

BF74 

2A0501 

LHLD 

0105H ; MAKiNT 

22 

BF77 

E3 

XTHL 


23 

BF 78 

C9 

RET 


24 



; 


25 

BF79 

4E 

1NTEG: MOV 

C,M 

26 

BF7A 

C316BF 

JMP 

CRT 

27 



; 


28 

BF7D 

EB 

STRING: XChG 


29 

BF7E 

7E 

MOV 

A, M 

30 

BF7F 

40 

MOV 

B,M 

31 

BFoO 

04 

1NR 

B 

32 

BF81 

23 

1NX 

H 

33 

BF02 

5E 

MOV 

E,M 

34 

BF83 

23 

1NX 

H 

35 

BF84 

5o 

MOV 

D,M ; DE points to string 

36 

bF85 

EB 

XCHG 


37 

BF86 

FE05 

CPI 

5 ; A = ien. 


BF88 

DABEBF 

JC 

SKIP 

39 

BF8B 

7E 

MOV 

A, M 

40 

BF8C 

FE23 

CPI 

35 ; 

41 

BF8E 

C2BEBF 

JNZ 

SKIP 


» =-= 7 


4 


42: 

BF91 E5 


PUSH 

H 

; save in case plain string 

43: 

BF92 CDC8BF 


CALL 

TEN 


44: 

BF95 D2D9BF 


JNC 

FAIL1 

; Y wasn't numeric 

45: 

BF98 83 


ADD 

E 


46: 

BF99 FE18 


CPI 

24 

; Y 

47: 

BF9B D2D9BF 


JNC 

FA1L1 

; Y > 0 to 23 

48: 

BF9E 57 


MOV 

D, A 


49: 

BF9F CDC8BF 


CALL 

TEN 


50: 

BFA2 D2D9BF 


JNC 

FA1L1 

; X wasn't numeric 

51: 

BFA5 83 


ADD 

E 


52: 

BFA6 FE50 


CPi 

80 


53: 

BFA8 D2D9BF 


JNC 

FA1L1 

; X > 0 to 79 

54: 

BFAB 0E14 


MVI 

C,20 

; Cursor address code 

55: 

BFAD CDIbbF 


CALL 

CRT 


56: 

BFBO 4A 


MOV 

C,D 


57: 

BFB1 CD16BF 


CALL 

CRT 


58: 

BFB4 4F 


MOV 

C, A 


59: 

BFB5 CDIbbF 


CALL 

CRT 


oO: 

BFB8 23 


1NX 

H 

; first byte of string 

61 : 

BFB9 D1 


POP 

D 

; didn't need it 

62: 

BFBA 78 


MOV 

A ,B 


63: 

BFBB D605 


SU1 

5 


64: 

BFBD 47 


MOV 

B, A 


65: 

BFBE 05 

SKIP: 

DCR 

B 


66: 

BFBF C8 


RZ 


; done 

67: 

BFCO 4E 


MOV 

C,M 


68: 

BFC1 23 


INX 

H 


69: 

BFC2 CD16BF 


CALL 

CRT 


70: 

BFC5 C3BEBF 


JMP 

SKIP 


71: 

BFC8 CDD2BF 

TEN: 

CALL 

TEST 


72: 

BFCB DO 


RNC 



73: 

BFCC 07 


RLC 



74: 

BFCD 5F 


MOV 

E,A 


75: 

BFCE 07 


RLC 



76: 

BFCF 07 


RLC 



77: 

BFDO 83 


ADD 

E 

; times 10 

78: 

BFD1 5F 


MOV 

E, A 


79: 

BFD2 23 

TEST: 

INX 

H 


80: 

BFD3 7£ 


MOV 

A ,M 


81: 

BFD4 D630 


SU1 

40 


82: 

BFD6 FEOA 


CPi 

10 


83: 

BFDO C9 


RET 



84: 






85: 

BFD9 El 

FA1L1: 

POP 

H 


86: 

BFDA C3BEBF 


JMP 

SKIP 

; print string 

87: 






88: 

BFDD 

END 









Number 45 

206 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 








BY DENNIS ALLISON Associativity: ao(boc) = (aob)oc for 

all a, b, c in the group. 

ALGORITHMS Identity Element: there is an element 

i in the group such that aoi=ioa = a 
Algorithms are published in many for any a in the group, 
places. For many years there was an Inverse Element : for any a in the 

algorithms column in the Communica- group there exists an element a' in the 

tions of the ACM (it’s now published as group (the inverse of a) such that 
pari: of ACM’s Transactions on Mathema- a° a’ = i 
tical Software). I learned a lot reading 

those algorithms and trying to understand jf one a i so has the ax i om 
how they work); they are still worth 

reading and understanding. Commutativity: aob = boa for all a 

and b in the group. 

BLOCK INTERCHANGE 

then the group is an Abelian group and 
Suppose we have an array of N objects a number of useful and interesting pro- 
which we partition into two parts, one perties follow immediately, 
with m objects in it and the other with Consider the additive group of integers 
n - N - m. The problem is to interchange modulo N. The elements of the group are 
the two parts with a minimum of data the integers 0, 1, . . . , N—1. The opera- 
moves and no significant temporary tion is ordinary addition except that 
storage. Symbolically we can represent results greater than or equal to N are 
the task as reduced by N. 

If we partition N into two elements so 
that N = m + n, then the elements 0, n, 
2n, 3n, . . . form a cyclic subgroup. A 
subgroup is simply a subset of the ele¬ 
ments of a group which themselves form a 
group. A cyclic group is one which for all 
elements in the group 

aoaoao ...o a = a 

for some number of repeated operations. 
The number of operations required is 
called the order of the group. For our 
group this is given by N/gcd(m,n) where 
1 N gcd(m,n) is the greatest-common-divisor. 

Each of the elements 1, 2, 3,. . . belongs 
1 he program below is a modification to a distinct coset of the group and form 
of an algorithm published by Walter a disjoint covering. There are, of course, 
Fletcher [ACM Algorithm 284, CACM gcd(m.n) cosets. 

9:5, May 1966] based upon some results Fletcher’s published algorithm com- 
of group theory. puted the gcd(m,n) and then ran two 

A group is a mathematical system loops: an outer loop which selected one 
consisting of a non-empty set of elements of the cosets and an inner loop which 
and a single binary operation, o, which selected an element, interchanged it with 
obeys the axioms: the next generated element of the sub¬ 



group n locations forward (modulo 
N) and continued until the entire coset 
was moved. 

My version of the algorithm, pro¬ 
grammed below in C, does not compute 
the gcd. Again, there are two loops: an 
outer loop which simply counts the total 
number of interchanges which must, 
eventually, equal N. The inner loop 
simply looks for the periodic return to 
the initial value and then selects the next 
coset. All in all, an elegant solution with 
only N interchanges. 



SAVING THE POINTER IN DOUBLY 
LINKED LISTS 

A doubly linked list consists of nodes 
which contain two pointers and the 
associated data. One pointer points 
forward to the next list node; the other 
points backward to the previous node: 



The flexibility of a doubly linked list is 
often offset by the additional storage 
required for the second pointer. For 
many algorithms which traverse doubly 
linked lists one can use a trick and save 
the storage space required for one of 
the pointers. 


Page 38 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

207 










The trick relies upon a property of the 
exclusive-or operation which is available 
on most computers. For any numbers a 
and b one has 

a = (a A b) A b , 

where A is the exclusive- or operator. 
The trick is to store the exclusive-or of 
the FWD and BKWD pointers at each 
node. Traversal of the list then requires 
three pieces of information: the old 
direction, the address of the current node 
(to decode the next node), and the 
address of the last node visited. 


To see how this works, suppose we 
are at node N 5 and we’ve just come from 
node N 4 so both addresses are available. 
Using Nj to indicate the address of the 
node, the contents of the link fields 
would be 


N 3 A n 5 

N s : 

n 4 a n* 

N 6 : 

n s a n 7 

Data 


Data 


Data 


and we could get a forward move by 

n 6 = n 4 a (N 4 a n 6 ) 

and a backwards move directly from the 
stored address. Of course one would have 



/ 


to update the window information to 
allow successive moves in any direction. 

Notice that the program must know 
something of the list structure in order 
to interpret the pointer field. Considered 
just as values they are inscrutable! 

I don’t know much about the history 
of this trick. Charles Wetherell (author 
of “Programming Pastimes and Pleasures” 
in this journal) showed it to me with 
considerable glee some years ago; he’d 
found it, if memory serves, in block 
memory allocation and recovery support 
system in an operating system. 


Number 45 

208 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 





□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□ 
□ 


□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 


□ 


MITS DOS 

Disk to Disk 
Copy Routine 


□ 


□ 


□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 


BY ANDREW L. BENDER, M. D. 

Neurological Services Inc. 

Westwood, NJ 07675 

Often there is a need to prepare floppy disks, or removable 
packs, with sets of “standard” predetermined files. One 
example is the construction of “library disks;” another is the 
preparation of distribution copies of programs. Being in the 
position of needing both library disks and distribution disks I 
had used the “COP” routine supplied with MITS DOS. This 
routine is: quite fast and very flexible; however, it is difficult 
to use. It must be invoked each time you want to copy a 
single file:; six parameters must be given for each file copied. 
If anything goes wrong during the copy or assignment of 
files, the routine unforgivingly aborts with little or no informa¬ 
tion as to why it failed. 

In order to remedy the above faults and ease the burden of 
preparing libraries, I wrote a disk to disk copy program which 
I call “CPY.” CPY will accept a list of files to be copied in a 
text file which you, the user, prepare with the text editor 
“EDIT” system program. The list of files gives the name 
and disk number of each file to be copied. The CPY program 
is given the number of an output disk and the files in the list 
are copied one by one to that disk. Once the copy has started 
there is no need for the user to intervene. The files must 
retain the same name on the output disk as on the input disk. 

During the copy several things are checked and certain 
actions are taken. If a file is specified as being on the output 
disk in the list, no copy will occur. In the case of a file being 
specified to be copied onto the output disk when it already 
resides on the output disk, no copy will occur. If a file cannot 
be found to be copied, the directive is just ignored as if it were 
not present. An I/O error will abort the copy. 

The philosophy in structuring the error checking and 
handling was that the routine was going to be used only by 
people familiar with files, file structures and data processing. 
It was not written to be used as an application program by a 
general user. Whenever an error occurs during processing 
the error code number is printed along with the file number 
on which the error occurred. 


Use of CPY 

To call the program: 

^ CPY textfilename, textfile disk, outputdisk 
( ^ supplied by DOS) 

Where textfilename is the name of the list of files prepared 
with the text editor program. Note that the leading ampersand 
(&) in the file name should not be included as CPY will supply 
this internally. Textfile disk is the disk unit on which the file 
list can be found. Outputdisk is the number of the disk onto 
which the files will be copied. For example if you wish to 
copy the files specified in RLIBS on disk zero to disk one the 
caU would be: ^CPY RLIBS,0,1 

Let’s carry the example along: Suppose the file directory of 
disk zero looked like this: *HEXOUT *OCTOCT *OPEN$ 
*HAZ2000 #LINK #ASM #EDIT #CPY #FDMP 
#ABSDMP #LDR #MAP &RLIBS &MAPSYM &BLANG 
&CP Let’s further assume the directory of disk one looked 
like: #INIT #LINK #DEBUG #EDIT #CNS #COP 
#ASM Let’s further assume that RLIBS on disk zero looked 
like: 

00100 *HEXOUT, 0 
00110 *DECOUT, 0 
00120 *OCTOCT, 0 
00130 #CPY, 0 
00140 #ASM, 0 

Now let’s trace the operation of the routine: Processing the 
first file in the list (*HEXOUT, 0) the CPY program will 
copy its text from disk zero to disk one. The next file 
*DECOUT will not be found on disk zero, so a message that 
the requested file wasn’t found on the input disk will be 
printed. The program will then examine the requests on lines 
120 and 130 copying the text of both files from disk zero to 
disk one. At line 140 the file # ASM is already on disk one so 
it will not do any copy. The CPY program will then exit to 
DOS since line 140 was the last line in the file. 


Page 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 


209 



DISK CONTROL 

Just prior to initiation of copy, the program will ask if the 
output disk is to be unloaded. At this time, if you want to put 
a disk on the output drive you should change the disk before 
typing in the response which can be Y or N. If you state Y, the 
disk will be dismounted, then an immediate mount will be 
issued. It is this action that makes it necessary to physically 
change disks before answering the message. You can, of 
course, rewrite that portion of the program if that annoys you, 
but it seems to be the fastest way to handle it. Keying in “N” 
assumes that you want to copy onto the current output disk. 

PROGRAM DOCUMENTATION 

The program listing documents what is happening here. I 
used several undocumented MITS DOS entry points. They are 
documented in the appendix. Two text messages in DOS were 
also used: 010A6H is the start of “ENTER FILE NAME” 
and 0101DH is the start of “ENTER DRIVE”. Two param¬ 
eters used in DOS were also used: 01321H which is a byte 
containing the highest disk number and 01322H is a byte 
which says how many sequential files are permitted. I would 
recommend putting all of these entries into your SYSENT 
element. I called the number of disks ND$$$ and the number 
of files NF$$$. 

PROGRAM TESTING 

I tested this program for about a month on a two drive 
system. I never tested it on drive numbers higher than 1. I 
think it will work without problems because I used the conver¬ 
sion subroutines for larger numbers. It is a real pain getting a 
routine up and running only to find that you have become 
part of the debugging. I tried to avoid putting the user in this 
position. There doesn’t seem to be any problem, but if you 
find one please let me know. One note of caution concerns 
attempts to copy the list of files with this program. Remember 
that during program operation the list of files (FILE #3) is 
open for input. This condition will not allow you to open this 
file as an input file (FILE #1) for copying. You can handle 
this situation in two ways: Use COP to copy the file or prepare 
a second identical file on the input disk. I don’t feel this is a 
bug, just a limitation imposed by DOS. 

AVAILABILITY 

I can supply a copy of the program and its accompanying 
routine on your clean, error-free, HARD SECTORED MITS 
FORMAT 8” disk. You must send the disk in a reusable 
mailing container. A chipboard box will be fine. Please enclose 
$8.00 to cover postage and handling in money order or cash. 
We cannot accept stamps, checks or any requests from any 
foreign countries with “black lists.” You are free to distribute 
this program for any NON-COMMERCIAL use, but you may 
not modify it or use it for commercial use without expressed 
permission in writing from Neurological Services Inc. This 
distribution notice must accompany ALL copies made for 
distribution. 


□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□ODD 


□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 


APPENDIX 

This is a narrative description of some non-published 

entry points in MITS DOS. Not all of these entry points 

are described. 

Address Description and SYSENT label name 

[Neurological Services System] 

X’005 D’ LDEM - Loads the DE register pair from the 
memory locations pointed to by the HI, 
register pair. HL is incremented by two on 
exit. (m,m+l) are loaded into DE. 

X’006E’ MOVE8—Moves eight bytes from DE to HL. 
BC = 0 on exit. DE and HL are updated. 

X’0071’ MOVE—Moves the number of bytes con¬ 
tained in BC from DE to HL on exit DE and 
HL are updated and BC = 0. 

X’10A6’ [NOT IN OUR SYSENT] -An ASCII String 
“ENTER FILE NAME” used by MSG, 
ASKSS and other routines. CR/LF precede: 
the message and it ends with the high order 
bit set. 

X’lOlD’ [NOT IN OUR SYSENT] - An ASCII String 
“ENTER DRIVE” similar to the above 
string in construction. 

X’02EE’ CCEL1 —Conversion cell for binary to ASCII 
conversion. Used to set base of conversion to 
either 8 or 10 depending on how you want 
the output (octal or decimal). 

X’02EC’ CCELL—See above. You set both of them 
before use. 

X’02B7’ BINCVS —Converts the contents of HL to an 
ASCII digit string in memory. If CCELL and 
CCEL1 are set to 10, conversion is decimal 
and if they are set to 8, conversion is octal. 
The call to this subroutine should be fol¬ 
lowed by a DW containing the address of 
where the first of the six digits of ASCII is 
to be stored. An example: 

CALL BINCVS ; DO CONVERSION 

DW ASCOUT ; WHERE THE ASCII 

GOES 

X’OF75’ ASKSS—This subroutine is used to get the 
first or next parameter from a processor call. 
It must be followed by a DW which de¬ 
scribes a string to be output in the event that 
the parameter is missing. On return, DE is 
pointing to the first byte of the parameter. 
If ASKSS finds a C/R code (x’OD’) it will 
output the message described at the DW and 
wait for a response to be typed in. 

X’OFBE’ AANSS-Converts ASCII characters to DE 
to binary. Result in A register on exit. This 
must be followed by an error retijrn address 
in case an error in conversion occurs, the 
program will jump to the error return 
address. Conversion stops on a comma, 
blank or C/R. 


□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 

□ 


□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□ 


Number 45 
210 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 



X 

tn 


Z CD Uh- 

*-1 2 X 

Q <c 22 

« UP- OB 2 

o u 

-J *-< r- qcc 

ZDZ Po 


O _1U U.H 
fli >H 2 

2 2 P- 2 

2 OQ 
x i- 3 <r 
cn iu cd x uj 

<t Q 3: U) ct 
— .m Q 


x o 

<i 2 

z <r 


*-H CC 04 
2 UJ 

a • 

2 2 0 
O 3 • 
2 I 

t— UJ 

CC2UJU. 
<1 <-< 2 2 
h- JH O 

cn _i 


(OKh 
CO u o 
uj <i o 


2 2 

<r u. uj 

U.I3 t- 

2 U eh UJ u 

<r 2 a <c 

2 CO h O CC 

U <1 

Ul O 2 X 

—I r— o cn u 

•-< 2 mm 

LUJLCIU 
2 2 1-2 
2 <X 2 X <X 

0 2 2 0 1-2 

UJCUH 
2-12 X UJ 
Q h UJ 2 UJ J 

Q U_I O mm 

<r u. - u. 

H- 2 Ci 

t- *-< C 2 UJ 

UJ I 1-0 3 5 

tn h uj o o o 


cn 2 h 2 

2 « <i <r 

UJ 2 2 2 

2 Ul 2 UJ 


<X 2 2 3 O 
3 cn O O 2 
Ci h O I 2 
dojcnui 


2 2 2 2 


<022 
C 2 O 
J 2 2 2 


a o 

2 n 

3 2 


2 cn cn 

ZOCOUH^ 

c u cn 2 u tn 

U O Q *-• 

I- 2 a P- a 

V 3 U <r 2 

-J o <r 2 p- 


2 ► 


2 O 
2 <t O 

cn cn o 


2 t- cn < 

J 2M L 
MM 2 3 

2 0 2 3 


2 2 
<r 2 
X <x 


3 0 3 

0 2 O 

« 2 

P- 3 O *- 
3 Ci O 3 
2 <T _J 2 


2 0 2 0 
<1 X 2 
2 2 1 - 
2 0 cn 
O *-M cn K 
O K 2 <r 
« cnx 

2 2 MM I- ( 

3 mm Q * 

t- cn 2 cn : 

2 2 2 2 C 

cn a <x v * 


mm 2 cn 
cn 2 u 
cn 2 3 c 
<r o 2 


j 2 cn 
. 2 2 
3 o o 


-200 MM 4 


JQ4I-2 
. Cl *- 2 2 

3 <r cn cn 2 


2 2 2 
-J 2 2 

►M O <X 

2 cn 2 


2 3 J t- 
2 * mm 3 
M- 2 2 
2 t- 
2 o a 3 
0 2 2 0 
2 2 0 


t- cn * 
2 2 

cn 3 2 2 

2 2 2 _i 
2 2 2 m- 
0 2 0 2 


O <X <E 
0 2 *- 
2 2 cn 


Cl 2 2 MM UJ 

I- <rt-«vM2» « 2 - 2 

z 0 2 02 rv 3 22 

30323 :3 2 «M.tD<I >- a -O rv •- 

ozcozcnc3zui > > > > a. - - 3 

<100232 j:«2X<r«rX0000QX00 


. - , 2 2 

>- CD 2 O t- 

2 cn 2 a 3 


- 3 2 cn 2 a 3 *- 2 

M U O <r O X O O • UXXOOOiOX 2 <tOOO<IOOO 


CM MM m 
2 0 + 

2 C-J CM 

2 0 1- f— r- 
2 *2022 


rs r-j 


MU.—I U- •- —J U_ » ^ LJ Jd Jtl 2 Pi 2 * X O X 

OOOO<COOOao<C2MM0.22OOO22MM2 


*r cm m *M 

2 0 + — 

2 CM t-J HM 

2 r-i 2 o 1- *— *- 

2 CM 2 -2022 


22 rj O >- 00 CD 

221-022 <r<t >- in 

222 •• 2 O O 2 2 2 r J 

«002X00mm22<L00 


X 2 .J MM 2 
««<n jil.jii.jm 
2 p- a 3 « o <c <rx 
xcnj202Ucno_j 


MM MM 3 
3 3 0 

x x x 


XCCNMH<TH 

2 0 2X302 
mm q -j j r j <r 


3X2NXh<_jmmmm^mm 3XX22N2 2JXinjC2CH MM JX2 hJ3Cm mm ^ j <r <T mm N h j <r <r -j j 
^^■y?^-^^ >< ^‘~ , “- ,Ni ^2:2«02^3X<C23«M-002X22^2X3«00XN3t— <C302N223K«3022C3X : 

OMMQ-.MMro2X203XMMMMOQ3oo30MM(i.ocn220 i 5o3oP i 3xor203rwoo3o303rS;oo“o3o ? ? 


o 


— o 


oooooooooo 

» n-oMnn-OHnn 
(MHM)-M-0000 

OOOOOOm<mMmMmM 

OOOOOOOOOO 

OOOOOOOOOO 


000 

vn-o 

000 


oooooooc 

MDO-OMNn* 

O O O -H mM mM mH * 


> o in © o 
) m - n n 
-j r-i cm cm rs 


0000 
<r in s> rv 
r-i r-j r-i rs 


00000 

O O* O *M CM 

rs rs m m m 


o o o o < 

m <r in s) r 

to to to to f 


u u 

>00000000000000000000000000000 

oo-OHnnvii3-cMjj».OMrifTTii3>oMDO'OHrjmvii3-o'- 

| jnw<rw<r<rv<rvinininmi3ininininm-0'0-0'0'0-o-o-c 

>OOOOOOOOOOOOOOOOOOOOOOOOOOOOCC 

> 00000000000000000000000000000 : 


o c o o o 

a > Ohm 
M3 S3 V is. tv 


ooooocco 

^'TinorvODD-© 

■vivv'v’v.'vtvm 


to CM 
S3 MM 

rs rs 
rs cm 
o o 
o o 

tv CM CM 
in S3 tv 
CM O O 


rv iv m3 

o rv mm 

m< o rs < 

o o o < 

o o o < 

n in mm m in mm 

S3 -m S3 mi H<r 

•n to to to to o 


000 

000 

000 


to < 

O S3 < 

rs cm < 

o rs S3 tv < 

OOO fv C 

OOO MM < 

S3S3tVf0WCM»-i«0CM>0 
NO-o»oo(Mon<r 
~ “ ootooooro 


O o M 


in to in 
mm cm o 
to o o 


3000000 

3000000 

3000000 


rv mm ro <r in s) h 
rv o o o o o -4 
mm cs rs cm rs cm rs cm cm cm 
oooooooooo 
oooooooooo 
oooooooooo 


♦ o v h <r in 
CM CM CM 
CM rs N 
OOO 
OOO 
OOO 


o <r < 

o S3 r 

o mm r 

o o cm o <r < 

<r o o mm in < 

0000 o < 

S3 in MM s) CM S3 c 
rv mm v o tn rv . 
o tn o o © m r 

rs rv cm in 

m r*3 m <r <r <r 

m cm cm cm rs r-j 
000000 
000000 
000000 


MM o 

rv cm tn 
v in ud 
cm r-j CM 
000 
000 
000 


tn in in rs 
cs mm o o 
ornotn 

in o mm 

UD in S3 *o 
r-J CM CM CM 
0000 
0000 
0000 


00 O CM 

00 00 

00 on 
00 o rs 
00 00 

00 00 

m in m in in cm »-« 

O MM CM CN -M S3 CM 

in mo rn tno m 

♦ rv o mm rv 
rv tv rv o o o o 
cm cm r-j tn tn tn rn 
0000000 
0000000 
0000000 


o o 

S3 O 

O o 

rs S3 CM 
in iv tv 
o tn rn 


in in tn 
000 
000 
000 


rs o o 
rn o mm 
tn o rn 
rs o o o 
rv © © o 
000 o 

S3 rs in rn tn 
tv S3 mm rs o 
tn tn tn o tn 

S3 o m S3 iv 

mm rs rs rs rs 
tn tn tn in tn 
00000 
00000 
00000 


rn 00 -o 
rs -o o 
ss rs o rs 
o mm rs o - cm 
o o o o in o 
o rs o o o o 
rs 


me o mm o 

m o c *r o 

tv o o rs o 

o o ' o n O' 

o c in o © o m 

O O ' O O O MM 


s) iiT tv rs o rs ss rs in rs rs rv rs S3 rs >o rs in rs cj tv r< . 

iv MMorvrvMMfv-OMMom-OMMrvoiV'OMM©v 0 © - 
otnMMorsmoomoorsmmrnoomoor. mr 


m m o cm in v rs in v rs m 
oss'orvrvrvtvooc -4 — 


N»vomT,,M, 

mmm<rvT<nj3inins3-o-oNNVNooo - — nri 
“mmmmmmmmmmmmminmm<Mr->r« 

0000000000000-0000 


">•0 — - V-C- ‘Ml 
cm rjm»nm*nc-*3-«r 

rjrnmmmmmmmmmmmmmmm<r<r'*4TMT <r<i« c*t «r<r<rn-«rn- 
ooooooooooooooooooor 00 00000 * 00 c. cc 

OOOOOOOOOOOOOOOOOOO ‘ OOOOOOOOOO 0 03 
OOOOOOOOOOOOOOOOOOOOOO 030C0 0 0CC0C 


2 2 
: V CD 2 
- 2 *1 D 
< »- cn cn 


- 2 
2 3 
2 2 
Ci 2 


3 IV 
2 S3 

* 2 rv 
- z> o 


) 2 O 
• 2 O 

: u 3 

. s) cn 
) m 2 
3 in 3 


j 2 • a 2 . 

J O t— 2 <-M C 

< u 2 <r 2 3 


- 2 »H o • 


t- - <r 2 cn 2 


j 2 t- x 2 Q 


2 a 
cn 22 
L « 3 o 


j m cn <-< •-< l 


3 2 2 0 2 

- U Z 2 

* u cn t- a 

: * « enr 

JJh«3 

. 2 M 2 2 

3 2 0 

‘ U Cl) * * 

DUX 

- *» * h rs c 

► z> z rs rs < 

» u u m tn 

' 2 <r mm mm . 


t- 2 <t 

D *-m 3 Cfl 


2(02*- < 
2 2 « 
UUHLCL 


>-ZJ 

2 in ► . _ 

u«acnxx*-M2<-MX' 


« 2 2 <H w 


- r- r- 3 3 c 
< x x o a c 
j 2 2 2 2 c 


cn x 
► x 2 


►+ 0 2 2 


O 2 
2 
2 a 

2 x 
a 3 
x 2 

3 

2 X 


2 Q — 


2 2 
O 3 
2 2 


m 2 O 
O 3 
3 2 O 


4 a a 
: x o 

3 3 X 


2 *-m 2 

<X 2 2 

2 a 

MM 2 X 

a 0 3 

2 2 
o 

b- 2 2 Z 

o 2 cn 
2 2 a •-< 

-^-232X0 
U J«33huj3 
J •-< 2 2 *-< 2 2 1- 

12 2 2 Q 2 3 

i. -J X a <-< Z Cl. 

— mm cn 1 - cn t- 

E 2 MM 2 2 t- MM 3 

u a 2 2 « a o 
2 1-3 2 

2 : 3 r- 2 2 2 t— r— 

<j 0220222 

x o • u 2 cn o 


cn * l 
mm cn o 
a mm j 


mm mm cn a 


j x x 1 


o x 

h- 
2 n 


X 2 
3 2 
2 <1 


cn cn cn t- c 

<-* cn 2 3 cn cn 

a <r _/»- o mm 1 
*-< <r <r x ► 

* o 2 *- _i 2 < 

21 - 02 c 


2 2 *- 
0 2 2 
U 2 cn 


<1 cn 
2X2 
2 <-m 2 
o u 
2 2 
x a 3 
o 

3*- K 
0 2 2 
*- cn cn 


X X 

u <x 

<1 2 X 
t- >- 2 ¥> 

nuz* 
*ucn* 
2 - <r 2 
cn x *- 2 


2 *MMMMUj*rscnrs * m inm + 

20XX023X02>-tn2 02>-0«« 

2 cn<tcncn - ocncn<r 22 cncn<i 22 - a 
tnux 2 <rxxx<ix<ruo<ix<ruaa 2 fl 


o u 
in rs m o 

>■ 02h l-t _ 

202X0022 •- U U 


(Jmm£_2<I(_)X22 OXL 


3 2 3 
mm u 
J 2 O 


H H -j« H -J -J *-*-j_j _i <t_i _i <1 3 <1 2 _j <r <1 _i <r _j _J 2 h <1 <1 
XXX02X<T3<Z3X<I<r3<r3*-<I3<I3r-0axX«3a2N<t3a<I<t3X3r-r- 
220_ju3uaua_juoQuaouauaox_JU3ua_jo~3ua_juuQ3Xoo 


— u 


00000000 

00000000 

00000000 


0000000000000000000 00000 00000 

cocr'OMMrsmvin'orvcoO'OMMrsm^-in'O mbd-oh rs m <r in S3 

h h rs rs rs cm rs rs rs rs r-i rs tn m rn m tn m m tnmtn<r<r -t <r ^ t <r 

0000000000000000000 00000 00000 

0000000000000000000 00000 00000 

0000000000000000000 00000 00000 


0000000 
tv m o- o ^ rs tn 
f v <r n in in in 
0000000 
0000000 
0000000 


CJ u u u 

000000000000000000000000000000000000 
JSS!i5 2:9^ nn,ri ' 1 ' CP '® l> ' OHfjnvin ' or ' 1D[>1 0 H ^ r, ’ , f«'O r '®o- 

inininininin-o-o-o-O'O-O'O-o-csjNNNvmNVNNMDSKDcoaiCDiBaimii 

000000000000000000000000000000000000 

000000000000000000000000000000000000 

000000000000000000000000000000000000 


0000 
o »m rs tn 

O' O O' O' 

0000 

0000 

0000 


o in o rs 

o rv o <r , w M- 

o o o «r no o 

orsonmoo' o 


' * * 
<r 00 
noo 

MM © O 

rs o o 


o-MMrnoo'O rsoo o 
oooMMOoorvos30ooinoMMOo 

oooooootvo«roootno<roo 

o rs 00 tv o 

*-* •-• rs rs -o rs in rs in o mm in in o in o rs un »m ut © rs tv rs o rs in 

-OWNNNHOHHSHrtHHO-CHOHO-CONNNH 

ooootnnmotnootnnoMooinomoo-'' 1 ' 1 -''" 


m o 

-< O 

•c o 

O O ' 
OOP 

o o < 


_ OOOOOOOOOOOOOOOOOOOOmmTS 00000 00000 

>s o o o o o o o o o o o o o o o o o o o o <r <r o o o o o 00000 

n oooooooooooooooooooo<r<rooooo 00000 

7" OOOOOOOOOOOOOOOOOOOOtmtmOOOOO 00000 

yj 00000000000000000000*1^00000 00000 

^ 000000000000000000000000000 00000 


o o' rs 
0 0-00 
o o in o 


00 O OOOOOOM'OHlMjH-J-O-inSjH^O 

00 o oooooooo-H-nrsr_im«M 


__ „ „ __ 'r' 0 -r)' 0 -m-ootn<rNon___ . .... _ 

ooooooooooo-4HMNrsrjmmtn<t^<nninii3-fl'0-oNNNNoooH--«Nn 
OO O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOmmmMmmmMtMmMmMmmmm 

00 0000000000000000000000000000000000000000 
000000000000000000000000000000000000000000 


00000000000000000000000000000000000 
00 O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO 
000000000000000000000000000000000 


•» * * 

o 00 

o 00 

o 00 

o rs o o 

o o <r o mm o o 

O O IV o o o o 


o o 
o o 
o o 

O O ' 


rs rs rv rs in mm rs 

.m.m.mmmONSDmMmMOIV 

otNmmoorstnmoo 


mm tn s) rs rs 

o o IV S 3 S 3 

o m o o o 


0000000 

0000000 

0000000 


o o 
o o 
o o 


00000000 

00000000 

00000000 


Page 42 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

211 






cn 

LU 


p- oi 
a 2 
LU o 
Ci u 


) ui <r 
* x: lu 
) t-t ic ui 


CJ <L 2 t>- 
<r 3 u. 
cn <r o _i 


t- lu 2 ^ 3 

D£COJ<t 


(- HH UK 
Ul 3 O <E L 
O LLU 3 ) 


cn u mm cj o 

LU 3 Q u Cl *-t CJ 

-I G <r<T UJUTV31DI2 

w - o lu uj uj cj u_ to cn cc: 

LQHC£u:<i£i:oua.riij 


01 

> 

t~ X tO UI 

uot-a.ro ■+■ lu t- 

Ortu;v+ co _i i ui lu 

3h lc o roo aicnt-OLt- 
uiuct aii:«Hnuio2230)<r>- 
iioujcmorr Huuoru* 


o o 
- a: 
in a: 


j <r<r t-t co _j u_ _j u. o <t _i _i «x _j _i >- 
C3Qu:NLLN3<t30<r3r_Jt-<I3<E3Ci<X<I3C 
)aJOTUHLUQQ.UD3\lJ)oauOJUUat 


N_l t-«x_l «XW Cl 

2<T3UK<r3UJCit-2a.N2U 

ccuQictnuwccjaiHucciCi 


UJ 


OOOOOOOOOO OOO 

coO'OHnro<rbi'OMDO>Ortr-JM^iii'OMiiO'0«fjfo<j-n'ONCDO'Ortr-jr>)vin'ONCDO'0 
'OONrvrvNrsivrsNisrvoDajaDcoaDcocDODOooiO'O'ChO'a-O'O'O'O-o-oooooooooO'-i 
n cj cj cj cj cj cj cj cj cj cj cj cj cj cj cj cj cj c j cj c j cj cj cj cj cj cj cj cj cj cj cj ro ro ro ro ro ro ro to to ro ro 
OOOOOOOOOO ooo oooooooooooooooooooooooooooooo 
OOOOOOOOOO ooooooooooooooooooooooooooooooooo 


to ro 
o o 
o o 


<T O O 
S 3 O S 3 
CJ O CJ 
CJ O ' CJ 

O O rv O 
O O 111 o 

CJ 


*-* ui cj cj rv cj S 3 cj o 

CJ rt o N JJ rt N iH ' 

o ro o o cj ro ro to r 

©oons 3 ©M<rrvw 

rvrvrvrvrvoocow 

rvivrvivivooooo 

OOOOOww*-i.-4,-i 

OOOOOOOOOO 

OOOOOOOOOO 


in in o o o >ooo S 3 o < 

o in o o o <r o © ino< 

*-t U 1 o O O CJ O O CJ o < 

win© O' O'O cjo'O'Cjoc 

ocjo O'O o cj o ootooroooc 

ooo om O'rc o o t o io o o < 

O CJ 

cj iii cj in cj cj ui i 
>0 w o w o rv . 
o m o n o o ro r 

<ruiocjMS30MMS3*-<M'0©m' 
w w cj cj cj cj o n n n w j iii in i 
OOOOOOOOOOOOOOOC 


O ' 

o r*i 

O <T 


in-o-i 
i >o >o rv 
3 0 0 0 


CJ o 
ill O 
CJ O 
CJ O ' 

o o r 
o o « 
i c 

. w rj in 

: w S 3 *-. 

! ro o ro 

tO t N [ 

iv iv rv < 

ooo* 


IO 111 O O o ^ CJ 

h h <r ^ cj cj o 

*H w o O W W *H 

m ui cj Ci v o o 
i cj cj cj cj cj <r «r 


cj m cj cj r 

cj o rv cj < 

w W O w T 

•o ui rv in rv iv r j cj o iii •? s 

- - - c j <t o n * 

W O W w *■ 


O w w *-t ^ 


cj w cj cj m 
O W IV CJ CJ 
OIOOOO 


-o © m <r 
rv w o o 
ro m ro w 


O CJ > 

<r o < 

O w * 


CJ CJ * 

rv m r 


;-c<r •o-ooc 


- o <r o < 

- O O W * 

< CJ CJ Ci c 


in ui r*i o Li bi n w w <r in o o in o n rv in 

CJ CJ CJ CJ T O H O CJ M W CJ O CJ T O 'T Cl w CJ 

^*-IW*HOW-rHWW^l *H H o rt o H W*H 

niioorotooMOrtOvncjinN •« o cj rv t cj w w o o o 

< *> <r h o cj cj h cj *■ *t*h^-ioow o © w o cj r*i w «t <r cj 

I rl O H rl tO tH W *“l t- 4 O W W H H rl WOWW -IWWWOOW 

<Hjjror.cj'OifiO'rJ3rtNo»cj<tcjinoioii5^<roro-o'r 
- o n o o n *< n cj o in h cj <r o cj o h o <r o o h o n cj ih n 

-^OWWW*HOW*HOWwO*H-Ht* 10 WO*H -H^ — ,-1 W *-l W 

iw^r^-oM'OO'TO^-uiin^-rvo-jwT-iiii^rvui 
r v 11 O rt CJ CJ » TH © ^- w CJ O w w r- <r H O O © CJ W CJ 

> 0 *-JWWtHtH 0 W *-l © *H O *-t WOW H o '•! H -1 rl WtHW 

rofotoMOMOMONtoMoiiiHiiiHinnn-iinov 
i»rj'iiiinin<i'ONNooTiHCjcjioioj"Tiiiin'<!-cNN 
j cj cj cj cj cj cj cj cj cj io io ro to ro to io to to io ro to m io io to 


a. 


C G 
t- <1 
UJ 
01 CC 


« O 
Ll U 


UI C 2 LU •- 

t- O 

UI 03 LU LU 01 U 

t- oi a. oi ci 

w t— 2 T. 2 K C 

it: lu lu 3 lu a 

3 CD 01 3 01 2 C 

r 

— «► — «- *- •> 3 *' 


03 O 
UI 01 
-J 2 


cc cl t- 
U LU 3 

g o 


<r u. 

3 C 
Ci c 


CC UJ 
01 3 

LL Ci 


UI3h 

OI-2CI 

t- <r CD : 


-3 i-i t-i 


CCB3 
LU CD t- 
0 ) U <E 
3 t- 
CL 01 
LU O 
3 CL I- 

<r a: uj 

01 LU CD 


2 2 t-H 
1-1 3 U. 

a cc u. 


... Q 

t- UJ 
* 11 - 
X 03 


LCt -22 2 

iZUU U 

UI U t- }■£ 2 

LL C CC _| _l 

U CC 3 Ci X Ci 


LU LU CC *i X *#> t# 1 2 3 + 3 

t-t- OCQ C30 CD U. UUUU1 UlO 

ww LU <L >-in>-l— WQCJ022CDCDCDU 

Q CC CC ClLU ClCJCl3-_I-_I_|i-i03 03 01- Cl 

HH33<rucc<EuoucL<ru<ru»crrxxru 


0> £C W ic W 


iv a. u ui 2 c -o rvt— Hto inrv •« u. u_iv cjoivcc cjocdck cj._ 

>-O3 r *lOCD0:3UOCDCDCDi-iCDIjC>-OCC > -CDa:*-iOCJOV3CDCC3t-CDCCCC3C3ac3t-CDa:O3OCC3t-Oa:OCDCCc5cDLC* _ 
u ^ ^uoiKioiuu^uicncnxoicccLOiaccLOicc^.u - ^LLcncnccoiuoiccccoicnccoiuoicccoicnccoiuoicccoicccoicc • j a. 

“ ' '"<LocuiujiLCUja.oxuM:cL£UjQ.oruj«ruj<irui 4 uu 


.<ruruuaxrrrujrujuruuruj<Eu<tuuij 


N JJ JXJJ <1 © N © C w Ni i—i —I •—* —J —1 _J _i >-iCCCLUiCLi-‘_i_i <X _i —i _l 0 _i a_I 0 _ 1 i—i _I ►—i _l li_ C/D _J u_I _| 0 . 01—1 Q_ _| u. 01 _J Q_ _i _i a _I li _I t-i_IO. 

ZIIIZI<I 30 a: 2 DCCNlL 2 Ui 3 « 34 IC 3 « 3 X 2 ri- 03 «« 3 S€« 3 « 3 i:« 3 H 3 t« 33 « 3 «t 3430 « 43 £D« 0 «« 3 tD« 30 «« 3 t 43 i 43 3 «t 
-l_JCn_ l i-cnuC_. 03 U 0 -lU 3 _XUXU_JUCUC_|i-.- 3 ©CLruUC_JUUCUC-UQ 3 UC 3 UQXUru ± iuCJCC:UUC 3 a.UCU.UUQ i iCLUGa: 5 uQ 3 UQ 3 UQIU 3 


o o o c 
H CJ to <r 
CD 03 3 CD 


o o o o o o 
Ll >0 rv 03 0 - o 

Vft (l~l f. r , A . i i ’ ^ 


ooo 
w r j r*i 
O' O' O' 


o o o o o c 

<T UI <1 IV CD O' 
O' O' O' O' O' O' 


o o o o o 
o w rj tn «r 
o o o o o 

C J CJ C J C J C J 

o c o o o 
o o o o o 


«- u 

o o o o o c o < 

UI 'O N 03 O' O w ; 

O O O O C *1 W . 

cj cj ~i cj r. cj cj 
O O O O o o o 
o o o o o o o 


cj cj cj 
ooo 
coo 


CJ CJ CJ CJ CJ 

o o o o o 
o o o o o 



' CJ CJ CJ 
l CJ CJ CJ 
*■ o o o 


- CJ T iv < 

3 N N \ C 

► «r < 3 - l 

3 O o O C 

3 C C C C 

; o o c c 


i O iit o 

> O CJ c 

> OOO 

j rv cj '0 cj 

- -c *-* rv o 

INBMM 


> o o c c ; 
1 c o c © < 

> c o o c < 


1 O CJ 

> o o 

> o o 


O CJ < 

o o < 
c c < 


•C L'l 'O 111 C J ii 
rv.rHNrHiil- 
o ci o ci o r 


* * 

o o 
o o 
o o 
BOO' 
O O O ii 
OOO' 


Cl O 

-0 o 
CJ o 


D UI in *- CJ ill 
>BB OOB 


4 CJ CJ c 
i ui ui u 
' © o c 

5 O C C 

> o o c 


3 UI ui 

' o o 

3 O O 


<r T ui h 

m UI UI UI Si 

o o o o < 
o o o o c 
o o o o < 


1 UI 'COM' 

i ui sn *e > 
1 UI UI UI UI u 
: c o o © < 
> o © o © c 

3 © O O © C 


* He * «• ' i 

O O O O S3 < 

O O O O UI < 

o © © o o < 

O' © ' © C ' © < 

©ivoinc©oo< 

©S 30 C 00 CJ©< 
rv © ^ 

in W ui CJ C 3 UI W M U 
WOWOOWOC* 
BOBOBBOM 

3S3WC3S30C1S30 
■ NO 00*4*' SM 
JUl'C'O'O'O'C'C'C 
•occcoooc 
: 0 © 000©00 
JOOOOOOCO 


> ' W O CJ O O 

> UI c o o o o 

> CJ o o o o o 


c o 
o o 
o o 

O O ' 

o o * 
o o t 


## * 

o o o 

o o o 

o o o 

O O ' o 
OOB O 
OONO 


* * * * *■ » •* 

o o o o o o o 

o o o o o o o 

o o o o o o o 

O' ©O' ©O' o O ' *- 

©S3 OONOOBOOCJC 

om ©owoo'coocjo 


MOM 

M s; o n 
Ci CJ Cl M 
•O 'C -O 'C 

o o o c 

o o o o 
o o o o 


i *4 s: 111 -0 111 !«3 111 111 H rl 111 ill T 
'ONHNrtO'flHO'CrtiC 

300M0MMMM0MC 


UI 


UI 


3 M < 


luimwwinmwMuiinwwmmwMinwMmw'C 
■ * -!0S3*-i*-4OO'C*H©s3*-iw0OT^O<3*-4Orv 
‘lOMMMOMMMOMMOMMOC 


M M M © f 


2 © W 111 IV cj UI S3 w M N CJ V N O M m S3 w S3 W CJ in IV o M S3 O M si o M S3 O 
B C <r <r -f I- 4! < ^5 ^5 N N K C, <5 O 6 - « - m r-i fi ci m n r> t ^ >1 n inifi < 

'0'0'Cs3s3'C'0'CS3'0'0'0'Os3'0!vrvrvivivrvrvrvrv(vrvrvfV!VNivri'rvrvrviv 
0000000500000000000000000000000CCOOC 
oooooooooooooooooooooooooooooooooooc 
oooooooooooooooooooooooooooooooooooc 


o o 
o o 
o o 

UI M 

T-t O 

m n 


rv rv 

o o 

© o 
o © 


Number 45 

212 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 






a 

A 


a u 


a q 


aci u 


a a 


a u 
a a 



<r o n in »h «r iii k -o o n 

o v o o o n n h h <r « 

hO-hh «1 »H ^ o n 

IONOhN N N Oh <T n 

Oh»«n <r h n n 

_ O —1 Hi Hi O — HI .H 


in in hi oo^-o't 
o eg eg «h <i <t eg <r eg 

Hi iH Hi tH o o »h o -I 

f Mil eg o o o m m h gj 

eg « rg eg «o -c o eg — 

HHHHrjOOHHHH 


oninmngo <ro rggi 

«r h h eg ej o v o g oh 

O H rt H rH H eg *H O hH Hi 

rg n in 'O rs m cj onon 

^egOHHOiii vh «reg 

Q _ _ -< Hi c O Hi O -* 


negrginin>omO'©rgrg- , t 
5 eg eg o ^ o eg eg in - in «-• ( 
HHHHfgrlHrtegOO^' 

iNNvrgoinN»inoJ< 

‘g h eg eg - <f o h o h <f o ' 
1tHhihiOOhi.-.hiOO’ _,< 

oeg'oeginrsMisMinrvfor 

niiiii'Ogj’ONNOoo^’ 

^NNrsfsfSfs|>vOOOP < 

hi hi hi hi eg rg r g eg r 

2oooooooooo25 

20000000000©< 


gHin»egrgMRNO 
vh »- eg in -h eg eg «t 

-*h-< hihHOOhIhIhIO 

to ♦T — ’T'-'HH^.ego 

ShiOhiOOhihIhIhi 

vi*)M*iMnn«inrt 
i eg n « n «r -r iii n gi 
2000000000 
g eg eg eg eg eg eg eg eg rg 
2000000000 
2000000000 




A U U U U A U A 

a a ci ci ci ci a a 



o o 


03 > 


n m 
c o 


o o 



o o 
n <r 


eg eg 


n n 


o o 


o o 


^orvoin in -o *-, <? o rv in ~ ~r^<roinTHrx©>o hn^m n noin gjnm 

— v -• »r h-. o h h rg v « rg h h o ei <r o o o rg o o Onrg eg o ■c o o o 

t- O hh o h, hi h« hi hi hi -i o hi hi h* hi 


»r «r -0 sr in <r 0 h<tmh 00 'J eg gj iii i <r li g; gj o in in gj h nong^HN 

oihiiOho HHOongego n n eg eg h o « h g o o h h h rg „ ^ rt h h n 

—• O Hi Hi Hi -1 h1h1h1t-Ih1©i-Ih 1 HHHrtHHHrtOI'lH h-I hH hi Hi © hi hi Hi Hi 



onNbiNgniinncuieggjgonNHMiiHrgHHggegngjg rgingonogn in in hi 

g - o o h h r, o h g o eg o e i g h eg h h rg « eg h h eg h rg h o h h o e g g h g eg h n o eg 

O h1 hi Hi Hi Hi rg *1 Hi © hi h 1 i—l hi O n HI tH Hi h1 h 1 <r1 Hi h 1 Hi Hi h! Hi Hi Hi OhIhIOhHOhIhI O h« h1 


gnHrgfiH.rgonNejNNgigr, ogoogjogoiiiHogoiiigingogxinHig-g'rjgin 
egeg n no o h g oo ri h h eg n eg g eg g ei o g o g eg h g o g o eg h h g h o eg h h c h « o 

lH^lTH»HlHHlOOHllHl1lHlHHl-1»-.OHlOHl»-,CHlOHll-lOHlOHir < lOHlOHlT-1t-lHlHir0OHlT-1 


o^-o^’O^FSTHUiHiuiH-ijiH-iu-^imrvmrvtnrvnrvrorvrg'oeg'Orgfnin^inHiiiiHiinHirg'Org 
© o hi hi rg eg r; r*i n »r g in in <, o n n o o « •— rg rg ro m in in -o >o o n n o o h< hh rg rg eg n 
^■«j-*r«g<r*T«r*g*s-^r<r'«-«r«T-'T'T , g-'riniiTtnuTininininii-3niniiiiiiUTinij')inO'0'0<i'0'C'0'C 


oooocccooooo ooooooooooooooc oooooooooooooooo 
ooooooooooooooooooooooooooooooooooooooooooo 


Page 44 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

213 



UK © «h *4 • K 

LU 3 - - « - <10 3 

DOm#IJU+U+* O A i 


<r * • uj a 

A ■ O CJ * » 

i a u i u a <r • <i <r <z 


CK X X _l _J -J 

h-htnuiHH JH JH JO. 0-KHHd:AuAr>©>-iMz><rD' lc©_i©ka 

ZX333>«Mfl«0pUi5 232Q00lZ0Li:0N20«0W2 
uuJLCLCiutu<iuo. iiirHimcriuTioii ~xu x cc ui 


CL X X _) _| _j _j 

Khimn3UUHjuuujjii.iihHHjM-a 
2xx30_i_jz<ro:Lc:ii:<r<rooiu2a:coLMZ 
uujiLu.riiii<iui£iiauu.iiiz «ou tizu 


* * u ¥» 

z u. o a z iii 

UJ O K UJ UJ -J 

u-I O ’H M U_ *—< 

QUO I >h O U. 


CL CL Z _J 

K K K 3 UJ _J 
Z Z X O O <r 3 
UJ Ul UJ UJ U A 


UJ X 
© X 

<r <r <i 

X CL 

a >■ 

-JO A O' 


3 r 

AO X * 

u _j <r cd 

u. _i a: -■ 

<r o 


ooooooooooooooooooooooooooooooooo 

OHfgn«rbi'ONtDi>-OHri«<Tii-i'ONcoi>-Ortnn«riii>oNa!0'OHr i 
>■* ^ ^ »-< ^ ^ ^ (\j cm cm cm cm cm cm rj n r j n n n n n n n n n n <r <r <r 

oooooooooooooo© ocoooooooooo ooo ooo 
ooooooooooooooooooooooooooooooooo 

OOOOOOOOOOOOOOO OOOOOOOOOOOOOOO ooo 


oooomooooococoooooooooo 

O^NI*in<Mil'OMDO'Ortfi^<nn-OMD&.0« 
„ „ h rt « h h h ^ rt n n n rj cm cm cm cm cm cm n n 
ooooooooooooooooooooooo 

OOOOOOOOOOCOOOOOOOOOOOO 

©OOOOOOOOOOOOOCOOOOOOOO 


o m orjocooooocooooo 
o o h r. n <r b'-o n cd o o h r j m <r 

£ ~ I? ^ Z ^ -• ^ - cm cm cm cm cm 

OOOOOOOOOOOCOOOOO 
©OOOOOOOOOOCOOOOO 

oo ooooooooocoooo© 


o m - o cm © o o i'' o ©o 

o«ro^O' 0 O IT) © -oo 

O rt OO o OO © o ©o < 

^ nn'O-oifi'Oin'OiOHHH'O^H^rtNO'cr-jMNrjovOi 
• n o n h h h h o h o r j h o o r j r j o m “• n c n •© n h w \ . 

) nnooMONnmiii^oonMM - — ro ~ cm — mc-r 

)OOOr*P|»<|H|<)"OOI<lVi'l-OOr«fJ,-,>f^OfOT'«NO'-ri 1 

] o o o o o o o rt n h rj rj ri n r, n « « •: w n <r «r w » biif! n , 
: oooooooooooocoooooooccocoooooc 

JOOOOOOOOOOOOOOOOCOOCCOOOOOOOOc 
OOOOOOOOOOOOOO© OOOOO COOOOOO OO' 
OOOOOOOOOOOOOOO COOCOOOOOOOO OOC 


• inii3r'jviv^om(vjxfvii3ii3-H — h -c -o iii c h 

) 'COOOO’T»H-.r-.— 

I nfO’-'OOMMooonnMMnMMM»-M 

i o o o ^ f j i f ir^ r j n »iii o ^ v ii: >c o r j m -o .■x 

. O C C o C O O O C - « PI PI M f t f i C! M n M "1 

•ooooooooooooooooooooooo 
) ooooooooooooooooooooooo 
' ooooooooooocoooocoooooc 
ooooooooooooooooooooooo 


r^ooorvooocooooooooo 

r'COOfVOOOOOOOOOOOOO 
i-HOOCXOOOOOOOOOOOOO 
QOOOPVOOOOOOOOOOOOO 
'■'OOOIXOOOOOOOOOOO oo 
* © 0 ©«-i 0 © 0 ©© 00©000 0 0 


K *-• CL -I 

3 U. O U. 

Ul o u. 

rctz z 

« Ul CL UJ 

Z UJ CL Ul CL 

3> O A o 

UJ O X 

Jt« 3 
-4 Z 

u in >o o 

u. ' Z - 

O O CO (M 

*X K o >-l O 

>-nn n a cm 


U. O U. CD O IlCD 

z w 3 pi m 3 cm 

OV—'OA—OOA-< 


r x _i 

3 => =3 

2 Z X 

'T o o o o 

cm < -o Ho 

- - - o * 

O O O o 

•> - ► o - 

w ho 

o U CD <T «T © O CD 

P) 3N CM CM *• CM CM 

ooA — ooooruoo — 


o cn o i 

o <x uj r.i <r in th c 
Z CD CC » * * * < 


K K 3 K 3 
30 3 (OO 3 in 
OHQO.HOU. 


a CO CD CJ) 

o <E X • Z Z <T A Z A 

k - - o <r o <r - - <; . 

<ix <r a <r ■ <x -< <r uj <r <i <i u <i uj i c <r 


UP * A A 3 A A3A3 33A333 3AAAAAC0Z 

G A AAA A A A A A A A A A A A A A A A A A UJ 


CL X -J 

K K «X CO _l Cl K A 
ZXK3«30UJAZ 
UJUJCOClUAlllCAUJ 


CL X CD o 

h (0 H 33 h MU33AAAAAXU. 3XCLKA 
Z3U0COO3UU.ZOOAAAAAZXOUOUJZ 
UJilXXIKnUHIlICCCCMUxCLiZUI 


U _J A Z 
z x k co <r 3 u. 
JCOZZUJ03 
A A X U CL U A 


OOOOflfiH 

3 <r <r <r -o n o 
-« © o o o m cm 

5 h pj o <i h « 
r n pi -o if) n o 

3^^0000 


nnw rororonronroronro roronnronron 

ooo oooooooooooooooooo 
ooo oooooooooooooooooo 


oooooooooo 

oooooooooo 

oooooooooo 


^ O 'OO O 'O 'O' O' 

OO t*~! *T *T o V O 'TO'T ooo^roo 

30 mOO O 'CO 'OO'OOOC'OOO 

•h *■« *h cm cm © cm cm o 

of -cophoo ot'oont'oopjpipioonpioo 
toooo <r <r <r 'roooooooooooooooo 

3MOOOOOO OMOOOfOOOOPnOOOrOCOO 

vror'0^rarxr*)V4 , in<H(Mnin*HCMnin«Hran!xnnN 
) » «r iii in n in <i < n n o o o o h h r- pi p i P i Pi n o 

, M h « h h - h h n h pi pj pj pi ri n pi pi pi cm cm cm cm cm cm 

j rj cm cm cm cm cm rj cm cm cm cm cm cm cm cm cm cm cm cm cm cm cm cj cm cm 

30000 OOOOOOOOOOOOOOO ooo oco 
30000000000000000000000000 


o o o o 

OOOOO 

OOOOO 

o 

O ^ O CJ CJ o 

o <r <r o o o 

O CM CM O CM O 

<r <r m- m in 'C'C'O 

CJ r J CJ CJ CJ CM CM V 
CM CM CM CM CM CM CM CM 

oooooooo 

ooooooco 


rT piininoHHi>) 

W -O'OhO'OhO 

y onnoMMo 

H ooontNHPinN 
•—) OOOOOO^^-H^ 

rr oooooooooo 
O oooooooooo 
oooooooooo 
* oooooooooo 


OOOOOOOOOOOOOOOOOO o OOOOO 
OO'HOOOOOOOOOOOOOOOO'HOr-iOO 
Hnro-oMDO'OHPinvin-ciMDCPOHnrifi^n 
O O O O O O O H rl H rt H « H ri H H PI Pi PI PI PI PI PI 
OOOOOOOOOOOOOOOOOOC OOOOO 

oooooooooooooooooo cooooo 


bT M N N-fl D p| 4 P| N p| N N P| Np) p) |<] PI P) h iH 

bl bl PI N PI M N p| l<) N o O O O O O Mf) V h 

n i*) ri H h n n pi n « h pi pi n pj pi o m H w n n 

30HrinvbiNrivNOHrii'!«'in'ONri«fl'bi'0 
3 o o o o o o o « rt rt ri pi pi pi pi pi pi p i m n n n m 
300000000000000000000000 
300000000000000000000000 
300000000000000000000000 
300000000000000000000000 


Number 45 

214 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 








ADDENDUM 

De ar DDJ: 

I was reveiwing the CPM printer driver which I sent you 
and which you have indicated might be used in your August 
issue, and have found one potential problem for some users. 
I would advise that the following be used as an addendum to 
the program DIABLO . PRN. 

The program DIABLO contains one potential problem 
which is evidenced when the DIABLO keyboard is used as the 
console input device. If the console device is switched back 
to the primary device while a CONIN input is being made, 
a garbage character is read, since the status port is changed 
but the data port does not change until the routine is re-en¬ 
tered. To correct this problem, the assembly listing should be 
changed to show a jump to CONIN when the status shows 
not ready instead of looping to CON3. The correct listing 
should be: 

020C CA9BD4 JZ CONIN + BASE L Loop till ready 

In the article, I mentioned using Control P to turn a printer 
on and off as CDOS does. I have just finished a modification 
to my CPM CBIOS which adds this and several other features. 
I will pass this along at my next opportunity. 

Yours truly, 

Steve 



Pa<|e 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

215 



an 0000 to Z0O translator system 


BY ROBERT W. DEA 

198 Lloyd Ave. 

Fremont, Ca 94536 

This program will accept 8080 mnemonics as input and 
translate them to the corresponding Z80 mnemonics; it was 
written in Digital Group Business Basic. I currently own a 
Digital Group Z80 computer system with the 50K bytes of 
memory, 4 digital PHI decks, and a 30 cps printer. 

The 8080 to Z80 translator consists of a language skeleton 
and a grammar analyzer. The language skeleton in this case 
defines the structure of Intel 8080 mnemonics and the modi¬ 
fied Digital Group Z80 mnemonics. The grammar analyzer 
parses the language skeleton in a top down left right process 
and verifies the correctness of the input mnemonic and 
generates the corresponding Z80 output. The translator is 
totally driven by the language skeleton and can be easily 
changed to translate a subset of the Z80 mnemonics to 8080 
mnemonics. In fact it can be modified to perform any transla¬ 
tion which consists of a one-to-one transformation. 

This version Can edit 8080 mnemonics and store them into 
a tape file on my Digital Group system. It will read the edited 
8080 file generated and translate the mnemonics to the modi¬ 
fied Digital Group Z80 mnemonics and store them into 
another tape file for later input to my Z80 assembler. The 
difference between the Digital Group Z80 mnemonics and the 
Zilog mnemonics are those instructions that deal with the 
accumulator. A few simple changes to the skeleton will allow 
the generation of Zilog Z80 mnemonics. 

The skeleton definition has the following format. 


n,8080mn,Z80mn,sub1,sub2, . . . 


n 

8080m n 

Z80mn 

subn 


The number of subfields following 
The 8080 instruction 
The Z80 equivalent instruction 
Subfield definitions 

<A> — regular one to one register translation 
<33> — RST number translation 
<CB> — register pair translation 
<C> — register pair to accumulator 
<K> — accumulator to register pair 
<CE> — edit a comma 

<F> — edit following character string to output 
<3»> — one to one character string translation 


The data scanner ends its scan upon detecting a 999 in the 
(n) field. By removing these DATA statements and deleting 
the speed enhancement section along with the comments 
should reduce storage requirements by 30-40 % but increases 
translation time by 100-150%. 



TYPE (E) TO EDIT A 8080 SOURCE FILE 
TYPE <T) TO TANSLATE 8080 TO Z80 
>E 

8080 EDIT PROGRAM 
OUTPUT FILE ALWAYS ON DRIVE B1 
TYPE 8080 SOURCE IN FOLLOWING FORMAT 
LABEL OPERATION OPERAND COMMENT 
TYPE '*EXIT' TO EXIT TO MENU 
INPUT 8080 OUTPUT FILE NAME? TEST 
OUTPUT FILE TEST WILL BE ON DRIVE B1 
? MOV B»B 
? MOV BfM 
? MOV Mr C 
? NLT 
? MVI Br1 
? MVI Mr 1 
? LXI Bf377 
t LXI SP077 
? STAX B 
? LDAX B 
? SHLD 277 
? LHLU 277 
? STA 277 
? LDA 377 
? XCHG 
? SPHL 
? ANA B 
? ANA M 
? XRA B 
? XRA M 
? ORA B 
? ORA M 
? CMP B 
? RLC 
y RRC 
? RAL 
? RAR 
? CMA 
? STC 
? CMC 
y ani i 

? XRI 2b 

y 0RI 17 
? CPI 7 

y jnz label 

y JZ LABEL 
? JNC LABEL 
? UC LABEL 
? JP0 LABEL 
? JP LABEL 
? JM LABEL 
? CNZ LABEL 
? CZ LABEL 



Number 45 
216 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 





^ I 

=T I 






Id 

_l 

o 


































A 

X 

V 

















Ll 

© 

















A 




A 


A 





























NJ 












£ 

£ 




U’ 

£ 


£ 

0 ) 


© 

£ 










k 






£ • 



£ £ 








Ld 













A 

A 




V 

A 


A 

V 


V 

A 



£ 







£ 






A A 



A A 








3 

o 












U) 

CP 




£ 

CJ) 


l/) 

£ 


£ 

l/' 



A 







A 




r r 


© © 


J 

© © 

£ 







cr 













V 

V 




•k 

V 


V 



•k 

V 



X 







CJ) 




A A 


V V 


A 

V V 

A 







—) 













5 

£ 




» 

£ 


£ 

£ 


£ 

£ 



V 







V 




© © 




© 


© 




















•- 








«• 







£ 







£ 




V V 


k k 


V 

k k 

V 








© 












£ 

£ 




U 

£ 


£ 

X 


O 

£ 



c 







k 






» • 



r • 









O 












*■ 





z 




X 


X 




£ 







£ 




k k 


k k 


k 

k k 

k 



< 




o 

CJO 












tJ 

z 




£ 

N 


Cl. 

£ 


z 

Nl 



k 







— 




£ £ 


3 NJ 


£ 

X O 

£ 



_l 


< 


© 












£ 

£ 

£ 







£ 



m. 

£ 



3 







k 




k k 


z z 


k 

X X 

k 



CJ) 


III 


o 

Ld 











A 


•k 




£ 

; 



£ 


£ 

k. 



T 







< 




3 > 


£ £ 


n 

£ £ 

Nl 



z 


o 


© 

f- 




£ 

£ 

£ 

£ 

£ 

£ 


l f) 

£ 

£ 




A 



£ 

A 


A 

£ 



£ 

£ 

£ 





£ 

£ 

£ 


£ t 


k k 


£ 

k k 

£ 


£ 

< 





< 




A 

A 

A 

A 

A 

A 


V 

A 

A 



£ 

X 

£ 


A 

X 

£ 

X 

A 



k 

A A 





k 

A A 


k k 

£ 

£ £ 


k 

£ £ 

k 


A 

cr 


• 

© 

< 

_l 




if) L D 

0 ) 

l/) < 

U) 


£ 

X 

X 



A 

V 

A 


X 

V 

A 

V 

X 



£ 

< 

X 





£ 

< 

CD 


£ £ 

A 

A A 


£ 

A A 

£ 


3 

i- 


s 

n 


© 




V 

V 

V 

V 

V 

V 



V 

V 



< 

£ 

X 


V 

£ 

i/; 

£ 

V 



A 

V 

V 





A 

V 

V 


A A 

CJ) 

X X 


A 

X X 

A 


V 




O' 

h- 





£ 

£ 

k 

£ 

£ 

£ 


£ 

£ 

£ 



V 

•k 

V 


£ 


V 


£ 



X 

£ 

£ 





X 

£ 

£ 


X X 

V 

V V 


X 

V V 

X 


£ 

o 


1 - 


HH 

< 




k 

k 

k 

k 

& 

k 







£ 

£ 

£ 



£ 

£ 

£ 

k 



V 

k 

k 




£ 

V 

k 

k 


V V 

£ 

£ _ 


V 

£ £ 

V 


k 

CO 


CL 


Q 

CL 




£ 

£ 

£ 

£ 

£ 

£ 


□ 

£ 

£ 

£ 

£ 

* 




£ 

j 



z 


£ 


£ 

£ 




K 


£ 

£ 



k 

k k 



k k 



£ 

Nl 


Ld 1 - 

Ld 

t— 




CJ O 

r~> 

L' 

CJ 

CJ 


< 

' 

_! 

3 

X 

£ 

3 

£ 


3 

3 

£ 

J 



<■ 

k 

3 

3 




3 

k 

3 3 


k k 

£ 

£ £ 


k 

r r 

k 


o 



X 

X 




o 

o 

o o o 

O 

z 



(J 

3 

3 

X 

L 

X 

< 


£ 

3 

< 

X 

< 

3 

£ 

< 

£ 

X X 

£ 



< ■: 


7 

z 

£ 

£ £ 

n 

X X 

£ 

£ 

X X 

£ 


3 

O 


o 

o 

O 

O 


iT> 

© 

< 

< 

< 

< < 

< 

>- 

£ 

< 

< 

O 

(J <J 

3 

3 >- 

< 

U 

3 

3 

< 

>- c 

o 

O O 

►—( 

>- 


X >- 

z 

»—i 

k —1 

X 

X X 

3 


>- 

X 

“> -J 

n 

>- 

£ 

h- 


CL 

1—4 

1 - 

1 — 


© 


£ 

£ 

£ 

£ 

£ 

£ 



U 

LJ 

£ 

£ 

£ 

£ 

< 

£ 

(.3 

z 

£ 

£ 

3 

£ 

£ 

3 

£ 

£ 

o 


£ 

£ £ 

1—1 

i 

£ 


"> “> 

£ 

£ £ 

£ 


£ £ 

~> 


k 




CL 




cf 

Z 

k 

* 

k 

k 

* 

k 


£ 

£ 

£ 



•k 


3 

•k 

£ 

m. 



£ 

k 


< 

k 

k 


k 

k —1 

k k 

£ 

k 

k 

k 


k 

k k 

k 


k k 


k 

£ 

o 


>- 

>- 





Ld 

£ 

£ 

£ 

£ 

£ 

£ 





£ 

£ 

£ 

£ 

£ 

£ 


£ 

£ 

£ 

k 

£ 

£ 

£ 

£ 

£ 

k 


III 

£ £ 

k 

£ 

£ 


k k 

£ 

£ £ 

£ 

k 

£ £ 

k 


X 

CO 


X 

a. 

Ld 

J— 


Z 

X 

*- CJ 

C.' 

t-H 

< 

f—« 

X 

-1 

£ 

£ 

< 

3 X 

3 


X 

£ 

UJ 

k-H 

o 

£ 

X 

< 

k 

cr 

X 

£ 

X 

£ 

!— X 

£ 

IT 

X 

X 

£ £ 

n 

3 Nl 

X 

£ 

X o 

£ 

X 

< 

o 



o 


w 


Ld 

•— 

(J 

o 

Q O 


z 


< 

u 

z 

z 

Z 

z 


£ 

£ 

X 

X 

X 

X 

NJ 

£ 

< 

£ 

3 3 

►—i 


k 

3 £ 

7 

7 

7 


3 Z 

z 

z z 

£ 

n 

X X 

Nl 


o 

CO 


z 

o 




X 


< 

< 

< 

< 

< 

< 

& 

<J (J 

(J 

(J 

u o 

3 

Ni 

•> 

u 

3 

3 

(.3 

L 3 

k 

n 

3 0 0 

n 

k 


X - 

k—i 

»—i 

k-H 

k 

~> 3 

"> 


k 


“> “> 

“> 

k 

3 



Ld 


Ld 

Id 

cd 

1 - 

£ 

£ 

£ 

£ 

£ 

£ 

£ 

cr 

£ 

£ 

£ 

£ 

£ 

£ 

£ 

Z 

“ 

£ 

£ 

£ 

£ 

£ 


£ 

< 

£ 

£ 

£ 


k —1 

£ 

£ 

£ 

£ 

. 

£ £ 

£ 

£ £ 

•** 

£ 

r : 

£ 

a 

£ 



h- 


LL 

LL 

«■ 


f- 

& 




k 


CT' 



«■ 

«■ 




3 

C- 



• 


•k 

CJ 

k 

o 

k 

k 

k 

,?• 

X 

k CJ 

k 

k 

k 

O'- 

k k 

k 

k k 

O' 

k 

k k 

k 

O' 

k 



1 - 


>- 

>- 

£ 

£ 

£ 

rH 


rH 

*H 

«—1 

«H 

O' 


fO 

© 

O 

o 

»H 

© 

£ 

O' 

© 

© 

rH 

© 

© 

O' 

o 

£ 


*H 

o 

O' 

£ 

o O' 

© 

rH 

rH 

O' 

© © 

rH 

© © 

O' 

© 

© © 

© 

O' 

rH 



►—i 


h— 

I- A 

Id A 
























k 





k 

















CL 


£ 

£ 

£ 

£ 

V 















© 









© 





o 






















II 


< 

< 

< 

■C 

< 

< 

< 

< 

< 

< 

<. 

< 

< 

< 


< 

< 

< 

< 

< 

< 

< 



<C 

< 

< 

< 



< 

< 

< 

< 

< < 

< 

< < 

< 

< 

< < 

< 

< 

< 





h- 


h- 


CD 

h~ 

J— 

h~ 

1 - 

H— 

1 - 

I- 

H 

f- 

I- 

1 - 

1 - 

f- 

1 - 

< 

h- 

1 — 

1 - 

h~ 

1 - 

h- 

H 

>— 

< 

h- 

1 - 

1 - 

H- 

< 

>- 1 - 

I- 

h~ 

K 

>- 

1 - h- 

1 - 

1 - h~ 

1 - 

h- 

h- h- 

1 - 

i- 

1 - 


Z 



z 

Z 

3 

CD 


< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

1 - 

< 

< 

< 

< 

< 

< 

< 

< 

1 - 

< 

< 

< 

< 

1 - 

< < 

< 

< 

< 

< 

< < 

< 

< < 

<r 

< 

< < 

< 

< 

< 

Z 

Ld 

Z 

z 

I —1 

f-n CL 


X 

o 

o 

o 

o 

O 

Q 

a 

Q 

Q 

o 

CJ 

3 

Q 

(J 

< 

3 

3 

c 

3 

Q 

Q 

3 

Q 

< 

o 

a 

O 

O 

< 

o o 

o 

o 

Q 

o 

o o 

o 

o o 

o 

o 

o o 

o 

o 

o 

Ld 

CT Ld 

Ld 

cr 

CL 

Z 

Ll 

*—i 















a 









o 





o 















CL 


CL 

CL 

X 

CL 


HH 





















































o 

3 

o 

3 

o 

o 

o 

3 

3 

3 

3 

o 

o 

o 

O 

o 

O 

o 

o 

o 

3 

3 

o 

o 

o 

3 

o 

o 

o 

o 

~ o 

o 

o 

o 

o 

o o 

o 

o c 

o 

O 

o o 

o 

o 

o 

O 

o 

O 

O 

o 

3 

O 

o 

3 

H 

CM 

© 


© 

© 


© 

O' 

3 

r—t 

M 

© 


© 

vD 


© 

O' 

3 

t -4 

CM 



© 

vO 

N 

© 

O' 

3 rH 

CM 

© 

cf 

© 

vC N 

© 

O' 3 

rH 

CM 

© ct 

© 

vO 

N- 

CM 

© 


© 

© 


© 

J' 


r—i 


rH 

•H 

rH 

rH 


»—1 

*—i 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

© 

© 

© 

© 

© 

© 

© 

© 

© 

© 

d- 3 

■ 3 - 

4 - 

■d- 


* J* 


3 © 

© 

© 

© © 

© 

© 

© 






< 

3 

X 

X 

cr 

X 

o 

3 

cr 

o 

© 

O 


Q 

Z 

< 


in 

CM 


O 

X 


cl 

o 


X 

CD 

< 

3 

NJ 

Z 


0. 

“5 


0. 

“> 


3 

X 

CD 

< 


0. 

1 


3 

Id 

CD 

< 


Id 

CD 


O 

0. 


0. 

~) 


3 

Id 

CD 

< 


X 

~y 



3 


3 


3 

3 




X 

3 

X 

3 

X 

X 

3 

3 


© 

X 

ffl 

X 

m 

© 

X 

X 

3 

< 

© 

< 

© 

< 

< 

© 

m 

X 

3 

< 

3 

< 

3 

3 

< 

< 

CO 

k 

3 

k 

3 

k 

k 

3 

3 

< 

Nl 

k 

3 

k 

O 

X 



3 

Z 

NJ 

Z 

3 

X 

X 

X 

Z 

Z 

3 

3 

3 

3 

3 

3 

3 

3 


3 

3 

3 

3 

3 

3 

3 

3 

X 

< 

< 

< 

< 

< 

< 

< 

< 

■> 

U 

3 

3 

3 

3 

3 

3 

3 


Nl 

Z 


u 

z 


UJ 

cl 


o 

CL 


h 

Ul 

cr 







© 

N 






H 

CM 

H 


cr 

< 

3 

3 

H 


H 

_4 

< 

z 

>- 

Z 

z 

CL 

CL 

X 

cr 

3 

© 

3 

< 

X 

O 

3 


UJ 

a 


z 


UJ 

CD 

< 


3 

Z 


_l 

UJ 

CD 

< 


o 

CL 


Id 

OD 

< 

3 

CL 

“5 


_l 

UJ 

CD 

< 


CD 

< 

_l 


Id 

CD 

< 


UJ 

CD 

< 


_) 

UJ 

CD 


NJ 


3 


O 

X 



Nl 


3 


O 

X 

Z 

Nl 

Z 

3 

X 

X 

X 

Z 

Z 

Nl 

Z 

3 

X 

X 

3 

3 

3 

3 

3 

3 

3 

3 

CL 

CL 

CL 

CL 

CL 

cr 


000000000)0000000000000000000000000000000000000000000030000 

^/^aocoa'a'ooH^cMCMfOOd-^-inno«o^N®coa'a'oo^^cMCM»oK)^-cfininoof^f^cococ7'a'ooHrHCMCM»0(Od-^inin 

c4<McsiN<HMr)ioinioioioi r )toioionior)iontoinionio*3-3-&3-&&zt*&&&**&3-&*&3- i nir)f)Dir)DDir)inininir) 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


UJ 

_J 

*-« o 
lL CO 
Nl 
UJ 

o o 

CL »- 

D 

O O 
l/) CO 
o 
O CO 
CO 

O Ul 
CO >- 
< 
< _J 
l/) 
H- Z 

*H < 

O CL 
UJ K 

O O 


UJ J 


l/) 

UJ 


l/) 

UJ 


(X. 

UJ 

z 

< 

z 

UJ *H 
_J 

h-i fi. 
U tt 
UJ 
O > 
CO 

O CL 
CO Q 


(X. 

UJ 

z 

< 

z 

CM 

UJ 

-J cx. CD 
►H tt * 
U. UJ CD 
> 

o »-* > 

CO CL O 
N Q Z 




3 



rH 


3 

k 



k 


X 





© 

«— 

3 


»H 

3 

k 

k 

X 


k 

I 

© 

© 

k- 


© 

w 




>- 






3 



o 

a 

Q 

< 

o 

O 

3 

3 

3 

X 

3 

3 


n 

© 

CL 

l/) 


Z 

CD 

> 

O 

z 


> 

o 

z 


> > 
z z 


a c 

_j 

n n- 

N © 

© 

- X 

£D l /) 


X 

_l 


N- 
1^ 
— CM 


< — 

•• N 


3 

CD 


© 

N 

w 

N 

© 

k 

k 


3 


3 







N 

k 

N 

w 

X 

X 


I 


I 


3 




k 

CM 

3 

CM 

k 

o 

© 

© 

— 

© 

w 


X 




< 


X 


< 







m 


© 

















< 

< 








a 

O 

CL 

CL 




3 

3 

a 

a 

a 

O 

O 

X 

o 

z 

z 

O 

o 

CL 

CL 

X 

3 

CL 

3 

3 

3 

3 

3 

X 

3 

< 

< 

X 

X 

O 

O 

3 

CL 

CL 


I/) 


< 

Q 


N 

CM 


X 

© 


N 

P- 

CM 


l/) 


N 

© 


CD 

X 

3 

X 


< 

CL 

X 


< 

cr 

o 


CJ 

CL 

CL 


w r- f— 

>“>“3130000000000000000000000000000000000000000000000000000 
X X ppfLQ.HHCMCMlOO^^^XJOONNCOCOCMJ'OOHHCMCMlOlO^d-ininOONNCOCOJ'a'OOHHMCMlOlOd-^iniOO'O 

>">->“ZZ_J _)0000000000000000000000000000000000000000000000000000 
K ►- A w w O O 


Page 48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

217 


RLA 0560 RP II 580 DATA 5*"LDA"»"LD"r"<F>"»"A»("r"<S>"»"<F> 









X 

CO 

fO 

x 

x 


o 


o 




< 

CO 



r\. 

X 

fSJ 



cr 

< 




LU 

Q 

o 



X 


X 



X 

LU 




X 

X 

o 


z 

CD 

X 

CO 


o 



o 


4—4 

z 

cd 

CO 


X 

o 

z 



cj 

4—1 

»—1 

LJ 


X 

X 

z 

X 


x 

cj 

u 

X 

ru 

x 

X 

LJ 


x 

cd 

cr 

X 

0. 

z 

z 

x 

cj 

X 

LJ 


K) 

y£> 


>- 

CD 


CO 

ISI 


x 

< 


o 

Lu 

LU 


5: 

LJ 

_J 

LJ 



X 








cj 




CD 















4—1 


CD 


CD 




LJ 



CO 








z 




X 














o 







X 


-J 



CM 

tD 



tD 




4 —i 




CJ 














1- 

z 


O 


X 


X 


CD 




O' 



O' 





X 



< 




z 











o 


1- 


X 


Ll 


<: 



cn 

4-H 



o 




<D 

X 



X 




o 










1- 

4—4 




4—4 


lL 


h- 







» 




z 

X 



X 




1—4 



o 




D. 



X 

h~ 


X 


S 


3 





X 

• 



£ 




4—4 

< 







1- 



3 




z 



X 

CJ 


X 




CD 


X 



o 








X 

> 



in 




CJ 



in 




o 



> 

Z) 


III 


1- 




u 



CM 

fx. 



D. 




X 








X 



tH 




4—4 



z 

X 


T 


< 


CD 


h* 




LU 



LJ 




X 

X 



X 




X 







K 



o 

1- 


5 


X 


Z 


<: 



d- 

Z 



z 





cj 



X 




1- 



Z 




< 


o 

CJ 

ID 

o 



1- 


4—4 






< 



< Q 




X 

< 



X 




CD 



LJ 




X 


vO 


z 

CM 

X 




H- X 



o 


X 

z o 



Z ~ 



Z 

z 

X 

o 


z 




z 



X 




CD 


m 

n 

4-4 

CM 

h- 


z 


Z h- 


z 

vO 

• 

CO 

* 



£ 



o 


X 

rH 


X 




4H 



h- 




Z o 


7 


CM 

< 


o 


bj co 


c> 



i-H 

LJ S 



LU 



4—4 

X 




z 











< 



< 

O 


1 


4-4 • 


z 

o. 

3 4-4 

CM 



_l 



x ru 



X 

z 

in 

>- 






3 







X 

d- 



CO 


3 


h- X 


X h- 

LU O' h- 


O 

rO 

*-< D. 



c 



cj 

1—4 


CD 


1—4 




CO 



iH 




1- 

d- 


7 

o 

Z 

(J 


o u 


X 3 

X 

3 L> 


w 


Ll tt 



U. LJ 



X 

X 

X 



4-4 




3 









III 

4—4 

CO 

III 

J 


X 1- 


X Q. 

CQ 

CM 

z 


X 

LU 


*—■ 

> — 



X 


1- 

1- 


<J 




CO 

o 


rH 




X 

Z 

1 



X 

< 


CD < 


h~ 

< 

cc: 

X 

< 

o 

O > 


Q 

O n Q 



X 

o 

< 

Z 


U) 



i—4 


x 


w 




o 

X 

h- 

c. 

z 

1- 

CJ 


z 


< 3 


j— 

I 


tH 

CO *-» 


a 

X cc x •» 

X 

i—1 

X 

X 

X 

X 


< 



X 

1- 

rO 


tD rH 




X 


X 

< 




o 


K O 


Z CD 

1- 

Q 


o cr 

—» 

CM 

ONQ H 

o 

II 

z 

X 

X 

o 





a 

X 

d- 


rH 

X 



Q H- 


z 



o 


h- z 


< 

< 

X Z 



CM 

co Q o 

a 

1— ^ 

1- 


4—4 

< 

z 

CJ 


o 



rO 

X 



rsi 




Z 

rv. 

o 

4—4 

X 

o 

CD 


o 


a x 

H 

I 4-4 





w 

tD 

U) X X tD 

X 




X 



1- 



w 

z 

Z 


ll 

rH 



X 

c h- 

ii 

X 

> 

II 



CD 4—4 


Nl 

< 

1- 

tD 

CJ 

CO 

i- i- 

tD 

O' 

X X O' 


• • 

o 

X 

CD 

X 



iH 

—* 

tD 


X 



X 




K X 



3 < 




3 h- 


h tfl h 



z 

CD 


X X 

X 

*-H z X CL O 

z 


cc 

X 


z 


X 

CJ 

tD 

iH 

1- 

X 


i—4 

w 



X 

4-H X 

&r 

h- 

iH X 

tft 

o 


CD CJ h» 

X CO X 


CO A 

w 

» rH 

CL CL 

X 

a 

lii r h 

X 

i-H 

o o 

< 

o 

4—4 


X 


iH 

CJ 

4—4 

1- 

3 

X 

tfl 



> 

X Z 

4—4 

4—4 

vO 

7 

z 

• 

O 3 

CO X N < 

vO x 

0 C> 

V 



z z 

CJ LJ X X ^ LJ 

X 

II 

II co 

X 

X cr 

X 

O 

X 

tD 

u 

+ 

CJ 




X 


3 

< 

x *—• 

w 

n 

m x 

w 


>- 

CD X 

fO 

Z - 4-4 

fO CD 

O' cc* 

ID 

< 

o 

4—4 4—4 

+ 


1-0 0*. 

1- 

«-H 

O' 

X 

o 


rH 

> 

X 

—» 

£ 

4—4 

O' 

tfr 

iH 



in 

X 

* 

z 

X 

2 

Z 

— • 

< 



X h- 


O' 

co 


* 

» £ 

tD o 

» » i-H 


X 

o 1- 

z 

1- 3 

u 

+ 

z 

1- 

z 


— X 

u 

X 

X 


iH 

d- «h 


£ >- 

X 



X 

CD 

,y 

3 CD 


h- 4-4 

Q 

ii x isj 

CD 

o 


O' 


»H w 

iH 


X 

X 

LJ O 

z 

rH 

o 

CD X 

£ 

o 

A - 

X 

w 

rH 

+ 

rH tD 

X 

II z 

X 

o 

OD O 

X 

X 

X 

O Z 

LD X Z £ 

CD Z 

X I 


s 

» £ 

X 1- 

4-4 


A X X 

A 

• • 

• • CD 

CD 

CD O' 

4-4 

CJ 

(J 

II 

X 

II 

tD CD 

rH £ 

CJ 

tD 

X 




tD < 


CD 

3 Q 


>- 

< 

Z 4-4 

3 

CD Q 4-4 £ 

3 LJ 

h- 


II 

li II 

X X 

II 

z 

X X X z 

X 




II 


II 


tD 

II 

tD 

iH 

X II 

II 

X 

II 

L 

O X X 


4—4 



ID 





CD 

< II 

ID 


X 

tD 

iff tD 

CL X 

tD LU 

XXX 


o 

o ^ 

z 

Z rH 


»H 

z 

»H 

iH 

i-4 

u z 

tD 

& 


ID 

II 

1- II II 

tD IE 

z 

X 

z 

O Z 

X 



^ Z 

O 

ZXI tfl 

O >" 

X 5 


LJ LU CD 

z z 

O' CL 

X z z X 

X 

II 

II X 

X 

X o 

X o 

X 

o 

X 

<J 

Xt X 

X rH 

»—4 

X 

t—4 

i—4 

O H tD 

4—1 LU 

X X 

4—4 

X 

CD X 

4—4 

X 

X 

X X 

CD X X X O 

CD LJ 





4—4 4—4 

*—« O 

4—4 4—4 4—4 0 

4—4 

X 

5 X 

X 

X 

X 


X 




X 

•-I X 

isj 

4-4 X 

X 

CD X 4-4 

tt X 

4-4 x 


X 

X 


X 

X 

X X 


X X 

X 

X 


O 

O o 

3 O 

O 

o 

o o o o 

o 

o 

o o 

o 

o o 

o 

O 

o 

o 

o 

3 

3 3 

3 3 

3 

o 

3 

3 

3 3 0 

O O 

o o 

o 

o 

O O 

3 

o 

o 

o o 

O 

0 0 3 0 

o o 

o o 

o 

ao 

oi-icMrod-invcxco 

O' 

O «H 

CM 

fO d- 

in 

sO 

X 

co O' o 

•H CM 

fO d 

m 

xO h- co 

O' O H CM fO 

d- n 

NO 


CO O' 

O 

•H 

CM 

m d- 

n 

so co O' 

O rH 

cm tr 


iH 

«“C rH 

CM CM CM CM 

CM CM CM CM CM 

CM 

rO fO 

ro 

lO fO fO fO rO 

DiOd- 

d- d- 

d- d- 

d- 

d- d- 

d- 

d-innnnininn 

in 

n n 

sO 

vO 

vOvO'OvOvOvOsOvONf'-f'-h- 



A 

X 

V 


A 

X 

V 


A 


CD 

£ 


£ 

£ 










V 

A 


A 

A 





£ 





£ 

C/) 


< 

U) 





A 






V 


V 

V 





C/) 





£ 

£ 


£ 

£ 





V 




















£ 


£ 

£ 










X 

A 


A 

A 





£ 





1 

X 


X 

X 





w 





£ 

V 


V 

V 





£ 




£ 


£ 


£ 

£ 







£ 


A 

£ 

• 


& 

* 





£ 



£ 

CD 

A 

£ 


£ 

£ 



£ 

£ 

A 


X A 

V 

X 

A 


A 

A 



A 

A 

X 


X CD 

£ 

V 

X 


< 

< 



< 

CD V 


w 

V 


£ 

V 


V 

V 



V 

V 

£ 



£ 

£ 

* 

£ 


£ 

£ 



£ 

£ 





X 

£ 





£ 




£ 



£ 

CD 

D 

£ 


£ 

£ 

X 


£ 

£ 

r- 


X X 

3 

X 

o 

£ 

O D O 

£ 

X 

X 

X 

£ 

3 O X 

£ 

X 

>- 

X 

X 

z 

>- o o 

o 

>- 

z 

X 

£ 

* 

• 

* 

- 

• 

• 

* 

* 

• 

* 

* 

* 

* 

* 

Q 

£ 

£ 

£ 

£ 

£ 

£ 

£ 

£ 

£ 

£ 

ll 

£ 

i 

X 

4—4 

X 

> 

4—1 

X 

X 

< 

4—4 

f— 

X 

T 

n 

ID 

± 

X 

£ 

o 

> 

o 

£ 

X 

X 

3 

£ 

CJ 

o 

3 

X 

X 

•» 


Dl 

z 


o 

o 

O 

* 

X 

X 

X 

• 

» 

0 

• 

» 

» 


» 

» 

£ 

„• • 

i 

£ 

£ 







J- 

•k 



o 



* 

in 

ro 

O' 

rO 

ro 

o 

O' 

iH 

iH 

in 

O' 

3 

iH 

•H 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

i- 

1- 


f- 

l- 

K 

I- 

H 

1- 

i- 

H 

1- 


1- 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

CJ 

CJ 

o 

O 

o 

o 

Q 

CJ 

o 

Q 

O 

c 

Cl 

o 


o 

o 

3 

O 

O 

o 

o 

3 

o 

o 

o 

o 

3 

o 

O' 

o 

rH 

CM 

fO 

d- 

in 

vO 


CO 

O' 

3 

iH 

CM 

in 

SO 

vO 

vO 

vO 

vO 

vO 

sD 

vO 

vO 

vO 


r- 



X £ — 

* < o 




















Z' 



- 










CO 






























£ 










tD 



























£ 



a 










4—4 



























A 



£ 










a 






z 





















X 



A 
















^a 





















V 



X 










d - 






_1 





















£ 



V 










w 




*-a 


X 



















£ 

£ 

•k 



£ 








£ 


ifl 




o 


w 



















A A 

£ 



a 








J 


X 




CO 





















< 

CD A 



£ 








I 


a 






z 



















V V 

ID 



A 








a 


-a 




tfl 



z 


















£ 

£ 

V 



ID 








-a 


CO 




O' 


X 

CL 




















£ 



V 








X 


iH 




o 



LD 


















£ 

£ 




£ 








CD 


w 




a 


_l 



















•k 


£ 



a 








w 


tD 




«-a 



n 


















< 

< 




£ 





£ 



£ 


O 




o 


X 

CD 


















£ 

£ 

£ £ 








X 



a 


a 




00 


IS.’ 





















- X 



£ 





X 

£ 

£ 

£ 


«<a «-a 






X X 

1 
















£ 


£ 

£ 

£ X 


£ 

a 


£ 

£ 


a 

A 

A 

A 


o o 




ID 


XI 

X 









£ 

£ 



£ 

£ 


A 


A A 

A - 


A 

£ 


A 

A 


X < 

ID 

X 


CM CO 



o 

O' 


X X 










(J 

ISJ 



X 

o 


CD 


X X 

X X 


CJ 

A 


< 

ID 


Q V 

V 

V 





\ 

4—1 


X 

± 

z 




z 



£ 

z 

z 


£ 

CL 

CL 


V 

£ 

V V 

V CD 


V 

X 


V 

V 



z 




ID ID 



4—4 

a 


X 


< 




CJ 



X 




0. 




£ 

rsi 

£ 

£ 

£ 


£ 

V 


£ 

£ 



a 

a 

a 


<J CD 




r-a 


X 

X 







» 








£ 



«k 




a. 

z 


a 

a 



£ 

£ 

£ 


a a 

-a 


X 

vO 


< o 

a 

*a 


» 



» 

< 








< 

£ 


£ 

£ 

£ 


£ 

a 

£ 

£ 

£ 


X 

X 

X 

X 



o 


O 

in 




X 


< < 


K 

CJ 


h- 1- 




1- CJ 

1- 


CJ CJ 

O Q 


Q 

£ 

X CD 

m 

z 

X o 

o 

X 


3 3 

CO 


X 

CM 


z Q 

O 3 


X 


1- 

X 

X 

1- 

X 

X 

£ 

1- X 

X 

X 

ID 

1- £ 

cd m 

X X 


1 

Q 

CJ 

3 

3 

X 

z 

X 

X 


X ro co 






X 



>- 

X 

X 

X X 

X 

X X 

X 

> X X 

X 

X 

X 

X >- 

CD CD 

£ £ 

X 

£ 

1 

CD CD 

CD 

z 

a 

£ 

r 

a 


a^ w 

ID 


CD 

tD 


CD 1 CJ 

CJ 



2 

• 

X 

» 

£ 

X 

£ 

£ 

£ 

X 

£ 

£ 

£ 

£ 

X £ 

£ 

£ 



a. 

£ 

£ 

£ 

£ 

a 

£ 

a 

a 

£ 

a 

ID (D I 


X 

i—l 



CD 

Q 




► 



» 




£ 




•» 

£ ^ 



£ £ 

a. 

£ 

a 

a 

a 

a 

£ 

0) 

£ 

£ 

1 


CD Z 

a 


X 

O 


X U 




» 

£ 


£ 

£ 


£ 

£ 

£ 

•k 

£ 

£ 

£ 

£ 

^ £ 

£ 

£ 

Q X 


X 

£ 

£ 

z 

z 

X 

X 

< 

4—4 

X 

X 



«-a 

X 

a 


ISI 

CD < 

X 

X 

X 

£ 

H 

U 

£ 

CJ 

ISJ 

X 

£ 

X 

O 

CJ 

1- 

£ X 

"O 

4—1 

X X 

X 

< 

< 

<J 

m 

4-4 

z 

CJ 

X 

X 

h- 


—» ^a 



^a 


4 — CD 




< 

< 

CJ 

X 

X z 

z 

z 

£ 

CL 

X 

X 

X 

LD 

rsj £ 

CD 

CD 

X X 


K 

h- 

H 

3 

3 

a 

X 

X 

X 

X 

a 

3 3 

CM 

.H 3 


^a 

_l 

X 

___ 


X 

X 

X 

X 

X 

X 

X 

X 


X 

X 

X 

X 

X 

x - 

U) 

CD 

CD LD 

a. 

LD 

CD 

ID 

ID 

ID 

■O' 

£ 

£ 

£ 

z 

O' 

•d CO 


w 

CD 

in so 

< CD 

< 

CJ 




s 

£ 

£ 

£ 

£ 

£ 

O' 

£ 

£ 

£ 

£ 

£ 

£ Z ' 

£ 

£ 

£ £ 

O' 

£ 

£ 

£ 

£ 

z 

O' 

a 

a 

a 

a 

O' 


ID 

ID 


cm in 

4—i 


m 

O' 




* 





O' 

«k 




* 

- J' 




O' 

a. 

a 

a 

a 

a 

O' 

o 

rH 

rH 

CM 

O' tf> tft m lj 

w 

CM 

X < 



o 

3 

o 

o 

o 

o 

o 

3 

o 

O' 

3 

3 

3 

3 

iH 

3 O' 

ro 

ro 

in 3 

O' 

iH 

in 

3 

iH 

iH 







< O ISI 

U CL 

ID 


4—» 

CD 




































< 

rH 

tD 

z < 

X 

CD 


























< 

< 

< 

< 

< 

< 




X 

X X 

4— £ 

z 

£ 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< < 

< 

< 

< < 

< 

< 

< 

< 

< 

< 


h- 

h~ 

h- 

1- 

X X z 






II 

II 

II 

1- 

1- 

1- 

1- 

1- 

1- 



K 

K 

h- 



1- 

K 

H H- 

f- 

1- 

H- 1- 

1- 

1- 

i- 



1- 

< 

< 

< 

< 

< 

< 

4-1 4—4 

4-4 

4-4 

X 

X 

X 

X tD 

tD 

tD 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< 

< < 

< 

< 

< < 

< 

< 

< 

< 

< 

< 

Cl 

a 

o 

o 

O 

O Q Q O O X 

4—1 

4-1 

X < 

CD 

(J 

Q 

o 

Q 

o 

o 

Q 

c 

C 

c 

c 

CJ 

CJ 

X 

o 

O 

O O 

Q 

O 

Q Q 

Q 

Q 

□ 

o 

Q 

Q 










X 

Q O 

X 




























3 

CD 

c 

3 

3 

3 

3 3 

o 

3 3 

o o 

3 3 

o 

O 

O 

o 

o 

o 

o 

o 

o 

c 

o 

3 

O 

o 

3 

3 

3 

3 3 

3 

3 

3 3 

3 

3 

3 

3 

3 

3 

3 

rH 

CM 

ro 

d- 

in vD x co O' 3 

i— 1 CM 

(O d- 

in so 

rO 

d- 

in 

vO 


CO 

O' 

o 

iH 

CM 

rO 

d 

in 

vO 


CO O' 

3 

rH 

CM rO 

•d 

n 

vO 

r- 

CO 

O' 

3 

3 

3 

3 

3 

o 

3 O 

O 

O rH 


i-H 

rH t-H 








r*- 

I s - 

CO 

CO 

CO 

CO 

CO 

co 

CO 

CD 

CO CO 

O' 

O' 

O' O' 

O' 

O' 

O' 

O' 

O' 

O' 

rH 

tH 

rH 

rH 

rH 

rH 

»H rH 

iH 

rH 

H 

rH 

l—1 

rH rH 

iH 

rH 


Number 45 

218 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 49 





1 


t ft 

o 


• 



< 

• 

3 









h- 



3 

X 

3 









Ld 



U 1 

0 

X 3 









> 

f— 


z 

h- 

i— —> 










X 


< 

< 

CD 









1 - 

0 


cr 

z 

1 - 









0 

>H 


f- 


3' b- 









z 

cr 



7 

0 3 









M 




o 

a 










o 



(—4 

s i— 









O 

h— 


0 

1 — 

O 3 









CO z 


fv. 


< 

z O 









O O 

b- 

3 

o 

Z 










GO *-• 

Ll 

> 

X 

4—4 

• 3 









b- 

Id 

< 

N 

3 

X X 









b~ < 

3 

X 


3 

0 f— 









3 Z 



f- 

C 

H 









CL hh 

>- 

3 

X 


< O 









Z Ll 

6 

3 

3 

CD 

Z K 









hh LU 

cc 


Z 

3 

~ r 









Q 

Ll 

b- 


Q 

Z ►—i 









LU 


Z 

3 


o 









3 o 


_ 

X 

O 

4-h H- 









O X 

U Z 

Z 

1 - 

X 

1 - hh 









X O 

CC O 

3 


o 

< 



0 

3 

0 

3 

0 

3 

s. CO 

1 “ hh 

3 

3 

X 

Z h- 



Z CD 

CC 

Z CD 

CC 

Z CD 

CC 

o 

b- 

3 

hh 


HH 4—4 



O 3 

L- 

O 3 

b- 

O 3 


Ll) L— CC 

Z < 


X 

3 

3 CD 



— 3 


h- 3 


►- 3 


x x m 

c z 

XI 

0 

3 

3 3 



1 - 3 

Z 

I- HH 

— ’ 

1— HH 

3 

1— ►“ CM 

4-H 1—4 

ID 


X 

O 



< 3 

C 

< 3 

o 

< 3 

O 


1— Ll 

0 

O 

H 

Q 



7 

H 

7 

4—4 



o in 

< 3 

O 

in 

O 

CD Z 



X 

f- 

HH CD 

1 - 

4-h CD 

1 - 

LU Ll Z 

Z O 

3 CM 


;Z! 

3 < 


0 

3 Z 

< 

3 Z 

< 

3 Z 

< 

l/l •- Id 

f— < 

X iD 

m 

< 

0 


< 

3 0 


3 0 

7 

3 0 

z 

cr ll x 

3 CD 

1- CM 



7* 


3 

O 

1—4 

a 

4—1 

O 


< t-l h 

b_ 3 


f- 

cr 

o o 

0 

3 

f— 

3 

h- 

3 

b- 

3 

CL 1- 

O 0 

X 

o 

o 

X hh 

< * 


£ 3 

3 

£ 3 

3 

~ t 

3 

< 


0 z 

7* 

3 

O b- 

3 

X 

A 3 

Q 

A 3 

a 

A 3 

a 

Id 0 -* 

Lu h- 

b- 3 



X < 

3 

id 

O Z 


X Z 


id Z 



x 

LlJ 


Z 

CD 

b- 

cl 

k 

c 

o 


z 

o 


LlJ 

cr 


CL 

LlI 


Z 

CD 


0. 

h- 

Z 


O 

I- 


o 

LlJ 


Q 

< 


Z D 

3 

Z Q 

b- 

Z 

0 

z 

a 

O 3 

I— 

O 3 


o 

Z 

o 

3 

H-4 3 


4-4 3 

3 

4—4 

< 

4-H 

3 

f— HH 

3 

K 4-4 

O 

1 - 

CC 

1 - 

4—4 

< 3 

O 

< 3 

4—4 

< 

h- 

< 

3 

Z 

4—4 

Z 

L— 

z 


z 


4-H CD 

H 

►h CD 

< 

4-4 

o 

4—4 

X 

3 3 

< 

3 3 

3 

3 

X 

3 

3 

3 0 

3 

3 0 

4-4 

3 

(VJ 

3 

0 

a 


a 

3 

O 


CD 



S tft X X 
l-IKLJ 
Lr 


1— Ld X 
O K O 


< 1/5 
Z O 


A 

0 


A 

CD 


£ Z 
A CL 
Q Z 
V 


A 0. 


A 

O 


u 

Q 

A 

IxJ 

V 


A 

Ll 

V 


0 

< 

_i 


£ Z 

A Q; 

0 Z 

V •-* 


4—4 

z 

3 

CM 

h- 


a 


CM 

cr 

3 

< 

CM 


h- 







X 

r- 


O - 

X 




o 


X h- 



O 

■J. X 



O 0 X 

o 


o 

L' 


o 


h- 




0 

x r- 

3 

3 

< h- 

3 

4—4 

"r* 


o 

3 

o 

> 

X 

3 


< 



O 



0 

3 

o o 


vO 0 

1 ' 1 

O 

O 


vC 

0 

LlJ O 

o 


vO 

0 3. 

O O 


»0 0 3 

o — 


vO 

0 


3 


< 




0 

3 O 

* *-• 

3 

td 3 

.•o 

0 

Z 

h- 

0 

fO 

3 

< 

h- 

fO 

/♦ 

Z 



z 



3 

3 

fO H- 


fO 3 

3 

K 1 

i— 


fO 

3 

Z fO 

L- 


m 

3 Z 

K 1 r- 


lO 3 Z 

Kl 


fO 

3 


&* 

z 




3 

ZX) 

id 

A 

0 0 


II 

HH 



CM 

X 



z 







(d 




CM Id 





CM 

Id 




CM 

Id 



CM O 

b- 


CM 

<d 

X 

1 — 

X 





Id 


3 Ll 

CM 



3 

t/f 


o 




o 


+ 

h* 


Z 

H- 


z 

O 

1 - 

b- 


O 

H- 


1 - 



O 

b- 

H 



O H 

4— 


O 1 — 

3 


O 


0 

+ 

b- 



z 

O 

1 - 

X 3 1- 

O O 

X 

O 

z 

o 

z 

X 

C 

3 

X 

X 

C"t 

3 


X 

3 


X 

X 

3 

X 3 

tr- 

X 

3 

X 

3 



X 

3 X 

3 



X 3 

X 3' 

t* 

X 3 

X .* 

th 


X 


3 


3 


rH 

X 

X 

3 X 

Id 0 


0 0 

3 

a 


z 

< 

3 


N 

3 

o 

0 


3 0 


3 

3 

0 

3 0 

0 

O 3 

0 

3 

0 

X 

3 

3 

0 3 0 

(d 

3 

3 0 

3 0 

0 0 3 0 

3 0 

3 

3 

3 

o 

3 

o 

0 


-f 

3 

3 

0 3 




0 





0 1 - 



0 

II 



1 - 


o 

h- 



0 

II 

1 — 


0 


II 

h- 


0 


II 

f— 


0 

II 

b- 

0 

II 

1 — 


< 


II 

H 


f- 


0 

z z 

3 

z z 

O 

z 

3 

z 

z 

O 

o 

Z 

z 

O 


Z 

II 

3 Z 

II 

3 

Z 

Z 

O Z 

t* 

o z 

Z 

O 

Z 

& 

O 

Z 

z o z 

rf* 

o 

Z Z 

O Z 


o z z 

O Z 


O 

Z 

3 

Z 


Z 

|| 

II 

3 

z 

Z O 

3 3 

HH 

3 3 

0 

3 

4—4 

3 

3 

0 0 3 

3 0 0 

3 

3 

X 

3 3 

X 

3 

u 

0 3 

X 

0 3 

3 0 

3 X 

0 

3 

3 0 

3 

I 

0 

3 3 

0 Id X 

0 3 3 

0 Ld 

X 

0 

3 X 

3 

o 

3 

3 

hh rr 

3 

3 0 

x r 


cc cr 


X 


X 

X 



X 

X 



X 



X 



X 

X 

X 


X 

X 


X 



X 

X 

X 



X X 

X 


X X 

X 



X 


X 


X 




X 

X 


03 3 0 000000003 30030000GC 000003000000 
B 7 O H K) j nOM03'3H!\!O^/l .? h C O' O H ,\‘ 

O'0d-cfd-^-d-d-d-^-^-^-j^ k nD/)Lr)if) k r) 1 ninnv0'0v0'£)v0v0\0v0v0v0f^h-r- 
CMNCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCUCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCM 


3 

a 


3 

o 


o 

LlJ 


Q 

Z 

< 


X 

Ll. 

Ll 

0 

< 

cr 

»- 

g 

< 

X 


cr 


o 

0 


H 

0 


cc 

N 


O 

LlJ 


I 1 


f— 

3 

CL 

t— 

3 

O 

o 

CO 

rsj 


id 

CD 


O 0 
z cr 
id . 

i/i L 
u 3 
>- co 1 

z :e i 


O CD O O 

lO m3 h- co 







f- 


























z 



0 





< 






< 


o 


o 











r7 











4-H 



X 





3 






z 


CM 


CO 

O 

" 

o o 








O 











3 



3 





0 



0 





XI 

o 

vC 

3 

o 

VC <rH 








4—1 














3 





Z 



O 



z 

• 

CM 

CM 

CM 

h* 

cc 

x a r> 


c 

3 





3 











0 



z 





< 



-1 



o 

z 


vD 


CM 

CM 

CM CM C, 


3 

z 





< 











Ld 



4—4 





X 



3 



4—4 

o 


CM 




XI 


3 

4—4 





3 














O 





! — 



Hh 



t— 

4—4 

X 


X 





4-H 

3 





0 


h* 












3 








3 



< 

1 - 

3 


z 

X X X X 


< 






z 


3 


3 






a 








3 



X 




<d 

0 X 0 

z 

z 

3 3 X 


3 

< 





< 


3 

o 


3 









< 





X 



3 



4—4 

3 

O 

_< 

o 

0 0 

0 0 3 



3 





X 


3 CM 


3 






< 



3 








0 



3 


0 

0 

0 

o 

o 

O C 0 


3 < 





3 














< 











3 



o 


0 

0 

0 0 O 


0 

O 







0 



O 






0 



O 





3 



Z 



O 



0 




0 

r\. 

X 






O 


3 

z 


}— 






0 











o 




0 

Z 


z 




i— o 

< 

3 







< 

3 








z 



3 





3 



4—4 



X 

3 

3 


3 

z 

z 

Z Z 

3 Tv 

CL 

O 





6 


X 

I 


X 




X 





D 





3 



h- 



o 

<d 

I 

7 

X 

3 

3 

3 3 Z 

0 O 







0 


3 

3 


3 




3 


* 








O 



< 



3 

c 

1 - 

3 1- 

I 

X 

X X 3 

CM 


3 

3 









3 




t* 3 


I 



z 





o 



3 




X 


X 


b- 

1 - 

Hhl 

0 


l/) 





< 





z 




4—4 Z 


o 



< 








0 



b- 

3 


1 - 




1 - 

< 

X 

3 







0 



4—4 




+ HH 





3' 

3 




g 



Z 



3 


S 


£ 




3 Z 

u 

X 

O 




3 


z 

t/t 


o 




£ O 


< 



3 

+ 







< 

3 


0 

z 

A 


A 

£ 

£ 

£ £ 

3 3 

T 


3 




> 


4—4 

4—4 


3 



3 

3 


z 



0 

3 




< 

• 


X 



X 

o 

< 

£ 

X 

A 

A 

A A £ 

X 


3 


X 



< 


I 

w 





4—4 

* 












: 

h- 



3 

Hh 

V 

A 

V 

Id 

O 3 3 A 

X b- 

3 

z 



3 O 

X 



z 


< 



X 

X < 


o 



O 





n 




O 


0 

b- 

£ 

0 

£ 

V 

V 

V V 0 

<d 


o 

•—4 






X 

3 

«-H 

3 



3 

Id 3 


z 



i— 

O 

& 



3 



a h- 



< 

II 

V 

II 

£ 

£ 

£ £ V 

3 

0 


+ 

o 


vC 

3 


z 

3 + 

< 




3 < 


* 





X 



Z 


£ 

< 


0 

X 

z 

tfl 

£ 

th 

II 

II 

II II £ 

< 3 


X 

1—4 

< 

3 

3 

3 


< 


H 

O 


O 

Q 

< O 




C 

z 




O 



+ 

u 



u 

4-H 

0 

II 

0 


tfl 

t* t* || 

Z II 

3 

0 

II 

3 

X 



4—4 


A 

w 





Z 


k— 


fO 

o 




r- 

3 

g 


X 

rH 


Lu 

3 


t* 


0 0 

0 0 ^ 

3 

S 

3 

~> 

X 

3 


0 


3 


t 

3 



4—4 

3 


—> 

O 



3 

o 


3 


-b 

X 


II 

O 

X 

U 


0 




0 

0 


3 



z 

3 

3 


4—4 

i— 4 

4—4 


3 

CM 

3 

O _j 

3 

3 


CM 

3 

II 

< 


3 

3 

& 

+ 

3 

4-H 

< 

Id 

O 

3 


3 




4—4 


3 




4—4 

X 

3 

o 

+ 

+ 

0 

7' 



Z 0 

fy 

K 

1 


0 

Z> 3 

3 


3 

o 

* 

o 


3 



4—4 


4-4 

3 

3 

3 3 

3 

Z 


X 



X 


X 


3 

-f. 

3 

o 


O 

* 3 

O 

O 



3 


X 

X 


o 

11 

o 

z 


X 

z 

z 


3 


4—4 

4—4 

HH HH Ll 

Z hh 

3 

Z 

o 



3 

z 

3 



o 

7 

3 

3 

z 

£ qt 

3 

O 

0 

z 

0 



3 

z 

3 


II 


X 


u 

3 


4—4 




4—4 

U 

X 

3 

3 




3 Z 

z 


II 


0 

3 


ll 

0 


II 

3 


X 



3 


o 


z 

O 


X 

X 







X 


X 





X 


3 

3 

* 

Z 

3 

o 

z 

* z 

3 Z 

1—4 

O 

z 

c 



O 

Z 


o 

3 

3 



















X 

HH 

o 

3 

X 

0 

3 

O 3 

X 

3 

0 

0 

3 

3 



0 3 


cC 

o 

CO 


X 

LlJ 


LlJ 

CD 


LU 

cr 


< 

V 


LU 

0 


o 





A 




0 





< 


O 

z 






V 


z 

o 

O 





£ 


< 

3 

z 








3 

< 





z 


z 

0 






o 


o 

3 

X 





3 


3 

0 

3 





3 


3 


' ? 





0 


0 

X 

3 





3 


3 

0 

Z 





0 


j~, 

X 

CD 








< 






0 


0 

3 

3 





3 


0 

0 

"7 





X 


3 


3 


o 





0 

L. 1 

f- 

tA 

O' 



3 


O 

3 

Z 

3 

J- 



3 


X 

X 

o 

o 




0 


3 

3 






Z 




3 

z 

z 



3 


3 

3 

N 

— 3 

3 



>J) 


ISJ 

M 

<-H 

o 3 

X 




o 

3 

3 

3 

~ + 

3 


o 

L' 


3 

3 

< 



t* vO 

0 

o 

< 

< 

3 

X 1/1 

vO OlO 

3 lO 

3 

3 

3 

X o 

ifi 

+ 

3 

0 


3 

3 

3 

0 — 

CM 

7t 


O 


3 

3 

z » 

+ z 

A 

3 


X 

CD 

z 

t* Z 

3 £ 

^ 3 

3 

O O 

3 

Z 

3 

< HH 

II 

O 3 

3 

II 

1- 


0 


II 

Z 

II II 


o 

Z 

O 

z 

4# Z 


0000000000003000000 3 0000000003000000000- 
- 1 '■'* ■''"*■ ^ ~ CO O' O 3 .\‘ f04J!i0: s -:00'O3C\Jf04.r)<0r'X0'33:MK14i/lv0f s -C0 ' 3 
~ “ - ^f^r-i^.^r-r^cccoccxcococoaDcocoo'O'O'O'O'O'a'O'O'O'o 

c\icsjc\jc\jc\jc\jrvjrMOsJC\jc\jc\icsjcvic\jcvjc\ic\jcsjcsjc\jccjc\ic\ic\jc\jc\Jro 


b- 

3 

CL 


II _ IJO_J_ ) |J» =r _ 05 _ |j _ II II 

OCtUOrf»3'iLH0U0Uiljih 

cr cr o _i *—< o cr cr cr 


o 

O 

O 

O 

O 

O 

O 

O 

O 

O 

O 

c 

O 

o 

O O 

O 

o 

o 

O 

o 


O 3 

3 

3 

cr 

3 O 

cr> 

3 

— 

C 

3 

o 

3 

C 

o 

o 

o 

o 

Qi 

O 

O 

o 

O 

o 

O 3 

o 

o o 

O 

o 

3 

o 

O 

o 

O 

O' 

o 

3 

CM 

o 

4- 

D 



O' 

3 

3 

CM 

ro 4 

X 

£ 


X 

:' 

3 

3 C\J 

•o 

4 

il 

vO 

X 

O' 

3 

—4 

CM 

•o 

4 

J! 

vO 


CO 

O' 

3 

3 


K) 

4 

X 

vO 

X 

O' 3 

3 

CM 

(O 

4 

X 

vO 

h- 

co 

CD CO 

co 

CO 

X 

ac 

X 

CO 

X 

O' 

O' O' 

O' O' 

O' 

O' 

O' 

O' 

O' 

O 

3 3 

3 

o 

3 

3 3 

3 

3 

3 

3 

3 

3 

3 

3 

1—4 

3 

3 

3 

*VJ 

''J 

Sj 


M 

•Ml 

CV \J 

CM 

CM <0 

rO 

fO 

fO 

IX 

X 

X 

X 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 3 

3 

3 

3 

3 

3 

CM 

CM CM 

CM 

CM 

CM 

CM CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

2 

2 

2 

2 

CM 

CM 

CM CM CM 

CM 

CM CM 

CM 

CM 

CM 

CM CM 

CM 

CM 


Page 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 


219 



n. o 

t-H 

n k 
_J ro 
o 
0 

Z LU 

t-t I 
\- 
d 
< 


— ct d 
z < z 

LiJ I < 


O 

-J 

LlI 


m 

< 

_i 

1x1 

I 


Lx 

O 


a: 

< 

O CL 
^ ct 
r- Lx 1 ixi 
rO X 

LX 

h- 3 

h- if) CD 
t-t 3 
X X h- 
Ixl 3 
Z 0- 
Lxl (- 
z i 3 

IxJ I— O 
X 

K it O 

z K 

< z 

_J l-t 
X 


ct 

LlJ 


* 

< 

_j 

CD 



Lx' 

o 


X 

d 




• 

ZT 

o 

lx 


in 

Z 

O 

ro 

CD 

i — 

d 

< 


« 

f— 

K 

o 


d 

in 

z 

LU 

ro 

o 

> 

d 

t-H 

z 


!— 

o 

c 

< 

0 

K 

z 


O 

l/) 

Q 

d 


LU 1- <L 
in o cr 
CL h- 


o 

d 

CM 

d 


in 

ro 

d 


CM 

CM 

d 


CM 

d 


o 

CO 


lx 

m 


CL N 

h- 

Z 

o o 

K 

z 

o 


< 

u 

17) 


Q < 

: X _ 
1 U LJ 


LJ 

I d 
f- < 


Z LU 
X X 


d- K) d- H C 
d d C 


O 

fO 


d 


H 

z 


i/) 


d 


d 



h- 

h- 

z 

H-* 

LU 

z 



o 


o 

O 

if) 

if) 

LJ 


X 

►— i 

O' O' 

o 

h* 

o 

CM 

ro 

z 

d 

X 

o 

i — 


ro ro 

CM 

CM 

>0 

in 

X 

t—t 

hh 

LU 

X' 


K 

1 | 

c 


t-H 




Lx 

0 

o 

o 

O Z 


d 


d 



o 


z 

co 

!— 

in cl 



LU 


LU 

LU 

0 

d 

< 


z 

rO Z 

IT M 

o 

d 

O 

d 

ct 

o 

O 

X 

Lx 

t—< 

d t-t 

f-i CM 

m 

o 

in 

O 

o 

CO 

Lx 

z 

o 



z z 

o o ro 

K 

ro 

K 

K 



L‘ 


> 

lx 


7) o x o d 

l/) 

d 

17) 

l/) 

LJ 

Z 


d 

ct 

Z O 


ro m CM - - 

LU 


LU 

LU 


X 

£ 

Z 0 

z 

s 


r— 




K 



d 



CL 





X 

f— 

K 


~z_ 
















Z 






Z 


0 



CD 

II 

< 






*-* 


o 


Ll 1 

17) 

i- 

O 



0 




LU Z 

LU 

Z 





III 








z 






lit 



£ 

K 








Z 

fi 


Ll 




17) 

.— 


CM 





X Ixi 

X LU 





I 








X 






X 


< 

II 

O X 

< 

u. 

1 - 

h- 

z 



0 

o 





< 

d 



V 

h- 




f- 

X 

1 - 

X 


o 


3 

K 


O 

O 

O 



o 

O K 

o 

o 

o 

C2 


CD K 



—» 

1 - z 



o 

t—t 




0 

•— 

i 


o 

Z 


t-H 

K 



IT) CM 

3 

3 



1 - 


1 - 

1 - 

— 


X 



><, 

O' 

CM 



1 - 

X 

h* 

CM 

7. 

O 


:t 


LU 

<—• 


K 

it 


C3 

*r. 




z 


< 

K 

LU 

LO 

lx 

Z 


& 

d — 

i-H 

«—1 






O 

*—t 





rO 

rO 

3- 



o 


m 

X 

X 

K 


K 


> 



*—i 



Z 

i—i 


z 

o 

LU 

t 

Z 0 

3 

X 

►—< 


t-H 



t-H & 




0 


X 


0 











0 









< 

t-H1 

T—1 1- 


tft 

-• 


+ 



J— 

z 

+ 

if) 

fO 

H 


Z 

O 


—' 

Ll Z 

II 

II 

cf 

Z CM rH 

*— 1 

O' 





»-H 
















X 

—■ 

II z 

L/J 

KH C 

o 

K 

«—i 



II 





if 

0 

LL 



w 

A 

A 

0 

\C A 

V 

A 

A 


LU 


Z A 


Z 

Z 

Z 


O' 


Z A 

lii 

z 

z 

Z 


LU A 



ifi 

d 0 

•—i 


z 

17) 

0 


K 

X 

z 

c 

1 - 3 


17) Z 


Lx 


0 

LU K 0 

*—i 

CM 

1 






d 

Z 

nr 

CM 

z 

d 

Z Ct 

z ct 

Z 


«H Ct CM 

Z d 

z ct z 

r 

Z Ct 

7 

Ct CM 

Z 

LJ 

t—* 






II 

z 

X 

< 


II 

x o 

X 

LU Ql 

X 

X 

O 

l/) 

Z LU if) 

z 


f-H 

CM Z 

z 

Z 

z 


O 

rr 

o 

Z 

£t 

o 

d O 

ct o 

d 


z 

o z 

d o 

ct o ct 

o 

Ct o 

01 

CO z 

.r | 



X 

X 

LX 

X 

X 


II 

LU 

H 


<fi 

z z 

z 

X Z 

r— 

0 

K < 


0 < 









K 

z 

r- 


Z K 

z r— 

Z K 

z 



r- 

Z K Z h- Z 

H 

Z K Z 

K 



t-H 

d LU 

LU 

r-H 

LU 

LU 

O 1- 

Z 


d 

0 

z 

U) 

1 - 




II 


II 



II 

II 





17) 

K 

l/) 


K 

l/) 

h- IT) 

K l/) 

f— 

II 


i^ 

hl/)hl/)h 

(7) h- 17) 

K 

in 


X 

lx II 

o d 

It 


d 

It 




X 

o 


X 

0 

X LU 

X 

X 

X 


LX 

X CM 

Lx 

lx 


M Ll 

Ll 

lx 

Ll 

Z 

LU Z 

z 

Z 

Z Z 

Z Z 

Z Z 

Z rH 

z 

Z LL 

z z z z z 

Z 

Z Z Z 

LU Lx 

z 1 

LU 

HlLl 








LU 

LX 


LU 

0 

X d 

LU 

LU 

LU Z 

t—l 

LU Z 

t-H 

t-H 

z 

Z t-H 

t—t 

t-H 

t-H 

0 

£t 

ct 

ct 

t-H 

Ct 

It 

d d 

Ct ct 

Ct Z 

O Ct t-H 

d ct 

ct ct ct 

d 

ct d 

01 

Ct »-t 

ct 1 

it 










d 



d 


d 

d 

d 

d 



cr 




























O 

3 o 

O 3 

O 

C 

3 

o 

3 

3 

3 

3 

3 

3 

3 3 

3 

3 O 

o 

3 

3 

O 

3 

o c 

3 

O 

3 

O 3 

o 

o 

o 

3 


c 

3 

o 

3 


3 3 

3 O 

- 

o 

o 

O O 

o o 

0 0 3 

o 

o o 

3 

CD O 

O 

d 

X) C 

K X 

O' 

3 

«—1 

CM 

o 

d- 

7) 

0 


X O' o 

t-H 

CM O 

cf 

r, 


n 

O' 3 

*—1 

CM 

fO 

cf f) 

vO 

K 

X 

•T\ 

~ 

•H 

CM 

lO 


n 

X K 

X O' 

o 


CM 

O d- 

in x 

K X O' 

o 

«H CM 

rO 

:l- 7) 

X 

X 

X X 

0 0 

v0 K K 

K 


K 

K 


K K X 

X 

X X 

X 

X 

X 

X 

X 

X O' 

O' 

O' 

O' 

O' O' 

O' 

O' 

O' 

O' 

3 

3 

3 

3 

3 

3 

O 3 

3 3 


«—t 

«—r 


H H 

H H rl 

CM 

CM CM 

CM 

CM CM 

CM 

fO fO lO 

lO rO 

fO 

fO 

o 

rO 

rO ro 

fO 

rO 

■O 

rO 

fO rO 

ro 

fO ro rO 

rO 

JO 

rO 

fO 

O fO 

JO 

O 

rO 

rO rO 

JO 

O 

rO 

ro 


■3- 

3- 


cf 



•3- cf 



d- d- 

d - d- 

d- d- d- 

d- 

d- d- 

d- 

:t d- 

d 


o 

il 


LU Ixi 

Ct M 


s 

0 


CL 

< 


Q 

_1 

LU 


X 

2 

if) 


CL 

< 

X 

0 



o 

if) 




o 


X 

z 






K 



t-H 





f-H 









t-H 



1- 

o 




CM 


z 

d 

f-N 





c 



0 

-1 




rO 


c 

O l/) 



o 

O 

z 



Ll 

z 








d 



O' 

K 




17) 

l-H 






1 — 

ct 

o 



r*> 


c 




Lx 




f- 


Ct 

o 

h- 



ro 

ro 

if) 



d 





t—t 


< 

K < 








Z 

CD 




X 


K 

< 

7~* 





z 



_ 

z 




z 


l/) 

z 

t-H 



K 

K 

> 



Z 

17 







t-H 

X 



t— . 

HH O 



< 







o 

X 

CL 



X 

X 

CD 



0 

1- 




Z 

CL 

l— 

ct 

Li_ 



z 

z 

< 



17) 

17) 




z 

< 


z 

h- 







O 


7~* 




X 

X 

0 

I— 






Z 

• 

II 

O 

t-H 




K 

0 

z 


Z 



z 

z 

I 

ct 

Ll 

_J 







l-H 

< 

Ct 



z 

z 

K 

z 


Z 

o 





i— 

r— 


< 



I 

X 




X 

X 

t-H 



£ 

X 

z 

K 


t-H 


K 

K 

Z 

Ll 

Z 

LX 

o 



ru 


1 ‘ 

t-H 

z 

£ 

w 

n. 



O 

D 

z 

if: 

X 

23 

ct 


£ 

z 

O 

0 


z ct 

d 




X 

X 

Z CD 


Z < 

z 



z 


£ 

z < 

z 

- 

£ 

z 


1- 

d Z 

K 

Z X 

< 

A 

K 


Z 


_J X 

< 




z 


Z if) 

X 


0 

_l 

V 

z 

z 

S D 

0 

_i 

£ 

£ 

6 

o 


• OK ~ 

¥ K X < 3 O 


_I <£ O K ~ ~ 


— 



t-H 




Ct 

z 

Z 



0 




Z 


K 

- 



ct 

_l 




o 

< 

z 

K 

“5 





3 






z 

< 




z 

-J 

»-H 

t—t 

—» 

—• 



3 

O 


D 




_ 

t-l 





X 

X K 


tft 

l/) 




X 



< 

z 

7 

z 

K 




z 

1 

II Z 

IT) 

t-H 

Z 

t-H 

«-H 


if) 


z 


z 

+ 

z < 

t-H 




< 

~ 

“0 0 

t-H 


X 

+ 

4- 

K 



< 

X 

-1 

& 

d 0 

z 

t-H 



0 

o 







X 

z 


0 



o 

3 IT) 

t-H 

+ 

£ 

T 

if) 

2! 

X 

X 

z 

X 

fi 

II 

Z 


X 

if) 

w 


II 

1- 


H 

II 

II 



ct z 

z 

t-H 

Z X K 

z 


II 



z 

rf) 

Z X 

X 

II 

* 

t-H 

X X 

O d 

ct 


01 




X 


X 

X 

t-H 

o d z z 

X 

z 

X 

z 

Z 

z 







z 

X 

z z 



Ct 

01 




ct 

Ct 








ct 


d d 

0 

3 

3 C 

o 

o 

O 

O 

o 

o 

o o 

o 

o 

3 

3 

3 

o 

_ 

3 

o 

3 

CM 

o 

d- 7) 

X h- X O' 

3 

m 

CM O 

d- 7) 

X K X 

O' 

o 

t-H 


o 

o 

o 

O 3 

3 

3 

3 

3 

«-H 

f-H 

f-H t-H 

«-H 

f-H 

*—t 

•—t 

*-H 

«-H 

CM 

CM 

Kl 

CM 

ro 

.o 

ro ro 

ro 

to 

ro 

ro 

rO 

rO 

ro fO 

rO 

rO 

rO ro 

ro 

rO 

fO O 

O rO 


X < 
LU 


II lx if) 

3 0 t-t 

X X i 
CL LU LJ i 
Odd 


Z < Z if) u z 

* »■ 1— X w 

Z I— Z t-i d -J> 

— t-n — K *-h 

t# tft “• l/l + 

H l/l H O Z 'it 


o: 

< 

x 

0 


LU 

z 


K II 

II if) 


LU U 
X X 


if) . 
X Z 
w o 






CD 





t-H 





K 





< 





.J 





LO 


Z 



z 


o 



<t 


t-H 



ct 


K 



K 


0 





3 



CD 


Ct 



QD 


K 





LO 





Z 



f— 

Ct O 

t—t 


o 

3 

Z t-H 



o 

CL 

k in 

o 


X 

h- 

0 ro 

X 


ro 


< 

o 



O 

ct 

X 




< H 



K 

C2 

X r-H 

z 


t-H 

21 

0 X 

o 


X 

<1 

z 



Z 01 


it 

z 


< 

_J 

z 

o 

n. 

X 

LJ 

< z 

t-H 

K 

Z 0 

a: 

_l z 

f— 

Z 

z 

<: 

DO X 

< ~ 

>- 

X if) 

_j 

1 K 

Z ifi 


K *-h 



♦-< X d X 

lx - Z I- 

LU Z < : 

O LU J Q 

I CD £ Q 




z 

X A 


CD 


< 


LlJ 



ct 

Z V 


3 

< 

II 

3 


3 

o 

1- 

o z — 


17) O 


— z 

•. 

O 

II 

II 


K 3 


K 

z 

3 Z 

3 

h- 

»-» 

HH 

z 

o - 


K 

> 

- X 



t f) 

if) 

X 

K 3 


X 

< 

3 K 

5 

2! 

3 

z 

K 

O ^ «H 

t-H 3 

z ro 

I 

w 

X H 3 

O 


— 


X X + 

+ 

Z X 


f) — 

4- 4- 

t-t 

Z 

z 

z 

II < X CM 

CM 

ll 

z 

X o 

CM 

h- 


IlxIZtft 
LU h LU LU Z 

ct d d 


LU 
0 

t-H O 

+ 0KZLULU Z< Z f— XKK K 3 3 

— X 01 _J _J CL 0 CM £ CM II II X CM Z 

IIS IUZ Zl/lh : I X LL CM CM LU X 0 XI 

KLUZK X K II II II fT LJ Hi h Z II 01 Z ' 

d UlxLxlUaJSCM tftiooo; rO X O Ct 

iHHirariijiziix xlulx 

d OL 


Z X H I- Z O 
II || X QC LI 
. X eft CM LU X l/) 

• LU X K Z K 3 ■ 
Ct LJ X II 

CC Li X I 
&. 


>00030000000300000000000000 0 0 00 

d‘T)XKCOJ'OHCMOd7)XKaOJ'Or4CMfnd-7)Xr'-SOJ'OH{M r > 


Number 45 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 51 

220 




< 


> 3 O lu Z LJ 

H O U I < CD 

CL _! Z 

Q _J Q O _ 
OZf-liJ J 
Z Ll < _l hh 


o 

CL 

K HH 

3 






Z 


z 



z 

LJ 

*-< Ll 







Ld 


Id 


o 

Z If) H 

CL 

X 

z 






X 


I 



z >- 

O 

LJ K 

•a 






K 


K 


a: 

Ll' 

< « lj 


Z) 

tft 







o 



a: 3 u 

z 

O CL 

a: 






a 

rH 



O _J CL 

o 

K K 

•a 






o 

CO 

o 


Ll' 

O «ID 

►—I 

Z> 

£ 






w 




i 

a: o 

K 

- o 







tft 


tft 



Q- LJ U) 

< 

K 

LJ 





o 

OL 

z 

£L 


Ll_ 

-J 

a: 

H-» O 

_l 





tft o 

X 

Id 

X 



K HH o 

LJ 

X CC 

HH 



o 


< K 

u 

X 

o o 


1 — 

HLI 

Q- 

Ld O 

Ll 


a 

CC 

—» 

w d* 

+ 

K 

d) + 


HH 

Q o 

O 

* CO 



•H 

CO 

O 

Z 

£ 

«a 

CO £ 


□ 

Id K CO 



K 


a. 

3- 

w 

Id Z 

K 

rH ac 

:* K 


Ld 

Z> 

_l 

K 

z 

o 

tft 


tft 

_l LJ 

HH 

V - 

HH 


3 C. LJ 

Id Id Z> 

0. 

w 

cr 

z 

cr 

+ X 

X 

— tft 

Z X 



3D K CL 

CO 

CL CL 

K 

(ft 


Ld 

X 

— K 

LJ 

tft < 

Ld Ld 

Id CL 



o^>-<>-zDiriijitftU(ft tft * o K 
I O h _l K hh O X * K H + H «0 H : O' < Ld 
zzzzsstu o <tft<m<n>o~-- 
+ ~ «H H-CM + Zo 


K H K K I 

z 2 : z z 


a: 0 : a: a: 1 

cl q. o. o. 1 


o •• •■ 

S' 3 tft 
sO < o 


A tft «H A H Z rH UJ5: 

< < < O _J + Ld < £ < O d) hh O ; 

N K H aC 5 || || hODhi 

LLtfMi.OllDllU.U.Urft*OJZOl 

H<MOMQ.a:MMQ: < < o 0 d o 1 


0000000000030000000000000000000 

j'o*-»?yj.Od-/)«0f^aDJ'o»Hc\j/0d-in\0f s 'a}a'o^H.'\jf0^/)0. K “'wa 

v{) *0 >0 vD >D COCCCOCOCOCOCCIOCOCO 













CC 

CC 











o 

*— 





O 






CO 

tft 





NO 







CL 











< 

a 





Cf 







ra 











K 

o 





z 






HH 

CM 





Ld 






Q 

r-: 





X 




o 


Ld 

a* 





K 



<— * 

cf 



tft 


-* 




ra. 


3 

CM 


O 

rH 

ac 




o 

3 


a 

•■o 


K 

< 

» 




V 



tft 




a 

tft 

z 



—» 

tft 


*-» •—1 



Z 

tft — 

a: 

lil 

«-% 


tft 

o 

Ld 

Id O 

Ld 


O CL vO 

a 

X 

tft 

3 


a 

a 

a a 

X 

O 

HH 

- D 

Ld 

K 

CL 

rO 

O Ld 3 

rH Ld 

K 

S' 

K eft CM 

& 


—* 



a 


3 a 


CM 

U 

< ~ 

o 


z 

*H 

z 

rH 


rH rH 

•—i - 

CM 

Ld 

tft 


A 

«h Id 


u 


LJ 

Ld — 

«H A £ 


l/) X < 


Wh + JC . 

K II CL II H 

U Llh II S' O l 

0 hi ac u 0 1 


ll/)Q + ill II O hh £ 

OKI-.: tft I- 2 Q I o || 

IJODIIllkOUJZhIIcA 

• O 0 Q- 5HO0£tDQaC< 


003000000000 30 300000000 zoooooooo 
M)J'OH1MO^^'OM)J'3HC\|iO i^v0K0)S'O^C\J.O4--'v0Ka) 
CMCMCM.OOfO'OrO.OOfO.’O'O-?-.* Z 3 r-o + .* * 1 DDDDDDDDS) 


Page 5S2 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 



























etters 


• L 


EASING MICROSOFT GLITCHES 

Dear DDJ: 

This letter is about a number of problems in interfacing the 
routine to basic as an example for your magazine. 

Microsoft basic with CP/M was ordered from Lifeboat thru 
a local dealer and was finally delivered this month. There were 
a few problems, however. The most bothersome: 

1. The printer was set up for a port that didn’t exist on my 
system. 

2. The ports starting at CFOO were initialized by track 0 
correctly but then clobbered by CP/M in loading, so that 
when any of those ports were used the system would lock 
up. 

3. The OSI machine uses ACIA’s not the Z-80 ports for 10. 
This means that the Altair basic’s IN OUT WAIT will not 
work. 

4. If a CHR$(9) is printed (or LPRINTED) what is actually 
printed is a string of CHR$(32)s. 

Problems one and two were corrected by rewriting the 
system’s I/O routines. (BEOO & BFOO). Since these routines 
were being replaced, another routine was added to solve 




; If A=2 then 

position cursor (CRTOUT prints reg 

BF75 

0E14 

INTEG: MVI 

C,CURSE 


BF7 7 

CD0000 

CALL 

CRTOUT 


BF7A 

4E 

MOV 

C t M 

value of Y 

BF7B 

CD0000 

CALL 

CRTOUT 


BF7E 

23 

1NX 

H 


BF7F 

4E 

MOV 

C r M ; 

value of X 

BF80 

C30080 

JMP 

CRTOUT 




; If A=3 then 

print string 

l to LPT (even CHR$(9)) 

BF83 

EB 

STRING: XCHG 


pointer now in HL 

BF84 

46 

MOV 

B , M 

B*len of string 

BF85 

04 

INR 

B 

If B=0 

BF86 

23 

1NX 

H 


BF87 

5E 

MOV 

E,M 


BF88 

23 

I NX 

H 


BF89 

56 

MOV 

D, M } 

got string address 

BF8A 

EB 

XCHG 


in regs HL 

BF6B 

05 

SLOOP: DCR 

B 

end yet? 

BF8C 

C6 

RZ 



BF8D 

4E 

MOV 

C i M 


BF8E 

23 

1NX 

H 


BF8F 

CD95BF 

CALL 

LPT ; 

print a byte 

BFy2 

C38BBF 

JMP 

SLOOP 




; Routine of 

how LPT could look 

BF95 

E5 

LPT: PUSH 

H 


BF96 

F5 

PUSH 

PSW 


BF97 

2AA5BF 

LHLD 

ADDR ; 

since all the ports are 

BF9A 

7E 

MOV 

A, M 

handled the same 

BF9B 

E602 

AN I 

MASK I ; 

this output is easily 

BF9D 

CA9ABF 

JZ 

LPT+5 ; 

red i rected 

BFA0 

23 

INX 

H 


BFAl 

71 

MOV 

M,C 


BFA2 

FI 

POP 

PSW 


BFA3 

El 

POP 

H 


BFA4 

C9 

RET 



BFA5 

00CF 

ADDR: DB 

00,0CFH 


BFA7 


END 




problems three and four. In Basic ten USR calls are allowed. ‘ c 

When the call is executed, register A contains the type of 2 a defin? £ togam tor USR calls 

parameter passed (2=integer, 3=string, etc.). If A=2 then £ ehbfe* 


HL will point to the number. If A=3 then DE will point 
to the length of the string (same as VARPTR). By passing 
different parameters one USR call can be made to handle 
several routines. The following program will print a string 
to the printer if passed a string. It will input one ASC 
(character) entered on the keyboard if passed a single or 
double precision number, or will position the cursor if passed 
an integer (Y+X*256). I hope these routines may be of 
some use to someone. 

Yours truly, 2305 W. Winona 


SB I 

6k) INPUT"Position cursor 
7u 1NPU1"Posit ion cursor 
80 C-CY + CX*256 
*0 OUSRU(C) 

100 PRINT "Done"; 

110 : 

120 PRINT CHR$(5); 

130 CY « USR0(Z) 

140 CX * USR0(Z) 

150 PRINT "X*"; C\25b 
160 PRINT"Y*"; C MOD 256 
170 : 

180 PRINT "A key? "; 

190 C « USR0(Z) 

200 PRINT "Thank you." 
210 : 

220 LINE INPUT"A string? 
230 S - USR0(S) 

240 END 



L. Barker 


Chicago, Ill. 60625 


; OSI correction available as a USR call in BASIC CP/M 


BF60 


ORG 

0BF60H 



0000 

= 

CRT IN 

EQU 

0000H 

; fill in value 

0000 

* 

CRTOUT 

EQU 

0000H 

; fill in value 

0014 

* 

CURSE 

EQU 

14H 

; position cursor control 

0002 

* 

MASKI 

EQU 

2 

; input port ready status 

BF60 

3D 

START: 

DCR 

A 


BF61 

3D 


DCR 

A 


BF62 

CA75BF 


JZ 

INTEG 

; A=2 

BF65 

3D 


DCR 

A 


BF66 

CA83BF 


JZ 

STRING 

; A-3 

BF69 

CD0000 


CALL 

CRT IN 

; get one character 

BF6C 

6F 


MOV 

L, A 

; and pass it back 

BF6D 

2600 


MV I 

H, 0 

; to basic 

BF6F 

E5 


PUSH 

H 


BF70 

2A0501 


LHLD 

0105H 

; OSI's return integer 

BF7 3 

E3 


XTHL 


; address 

BF74 

C9 


RET 




MAKING A GOOD THING WORK 

Dear DDJ, 

Mark Zeiger’s program in DDJ #41 for changing XEK files 
to CP/M files was very good. Except for the fact that it would 
not work on my XEK files, it really was well written and 
extremely valuable. This was my first exposure to CP/M and 
Mark’s piece cleared up a lot of confusion on my part. My 
Northstar system was bought secondhand with no guarantees 
to the usefulness of the software. Without Mark’s fine article, 
CP/M would still be an unknown quantity to me. Now at least 
I have my feet wet. 


Number 45 
222 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 57 








I think the problem is within my XEK files. It looks like 
XEK treats the first three spaces encountered after the (1) 
length byte; (2) fine number; and (3) dummy character 
(space), as field delimiters. Mark’s program only expanded the 
first space to a tab and all others were left as spaces. The 
enclosed listing of the critical program area shows how I 
adjusted the original program to fix my XEK files. I also 
put in a (;) comment delimiter after the third tab for con¬ 
tinuity. (My XEK treats all data after the third tab as 
comments with or without a field delimiter character). 

Finally, there are at least two other areas of incompatabifi- 
ty. First, in XEK all label references are truncated to five 
characters for comparisons but are left full length in the source 
files. Therefore ‘MACHINE’ in the label field would be evalu¬ 
ated as ‘MACHI’ and ‘MACHINE’ in the operand field will 
reference ‘MACHI’ in the label field. In the CP/M assembler 
more characters are compared and this causes ‘U’nidentified 
errors. 

The second problem has to do with negative referencing. 
Since I use a Z-80 CPU but no Z-80 software, I simulate 
relative jumps with the Z-80 code for the particular relative 
jump followed by a computed offset. 


JRZ 

EQU 

28H 

STAT 

EQU 

03H 

MASK 

* 

EQU 

02H 

* 

TTYOT 

IN 

STAT 


ANI 

MASK 


DB 

JRZ 


DB 

LABEL-$- 


IN 

DATA 



STA 

TAB 


JMP 

NOT A3 

A5TK 

C?t 

* * i 


JNZ 

3 LANK 


STA 

TAB 


JMP 

NOT A3 

BLANK 

CPI 

i • 


JNZ 

NOTAB 


MV I 

A f 9 

; DON' 

T BLOCK 

FURTHER T/ 

1 

NOTAB 

I NX 

a i 

* 




DCR 

B 


CZ 

EE AD EC C 

FILL 

STAX 

D 


INX 

D 


DCR 

C 


CZ 

WRITE REC 


CPI 

09 


JNZ 

PAST 


LDA 

TABCNT | 


DCR 

A 


STA 

TABCNT 


JNZ 

PAST 


MV I 

A, ’ ;' 


STA 

TA3 j 


JMP 

FILL 

PAST 

LDA 

EOLCNT 


DCR 

A 


STA 

EOLCNT 


JNZ 

OLDLINE 


MVI 

A , 0AH 


STAX 

D 


INX 

D 


DCR 

C 

* 

CZ 

WRITS REC 


JMP 

NEWLINE 

EOFMARK 

MVI 

A , 0AH 


STAX 

D 


INX 

D 


DCR 

C 


CZ 

WRITE REC 


MVI 

A, IAN 


STAX 

D 


1 SWITCH ORDER HERE SO 

;OUTBUF CAN BE UPDATED 
;WHEN INSERTING ';' WITHOUT 
;DESTURBING IN3UF 


jilERE IF GIANGING SPACE TO TAB 


»INSERT (;) 
j FLAG 'TAB' 


AFTER THIRD TA3 ON LINE 

TO 3L0CX FURTHER FIXING THIS LINE 



TABCNT D3 


jHOLD MAXIMUM TABS PER LINE 


SAVE TIME 


While these instructions will be assembled by XEK, the 
CP/M will not evaluate expressions like ‘LABEL-$-l’ if the 
result is negative. It seems to do OK with forward references. 

Again, thanks to Mark for his inspiring program. I would 
like to hear from other CP/M on Northstar users who can help 
me get DDT and NRELOC working or just exchange software. 
Except for the APPLE store here in Corvallis, there isn’t much 
micro activity. 

Sincerely, 2860 NW Skyline Drive 

Gene R. Head Corvallis, Oregon 97330 


THESE LINES OF TEXT HAVE BEEN MODIFIED FROM THE 
ORIGINAL TEXT APPEARING IN DDJ #41, WRITTEN BY MARK 
ZIEGER. 


NEWLINE 

MOV 

A,M 


CPI 

01 


JZ 

ECFMARK 


MVI 

A,0 


STA 

TAB 


MVI 

A,3 


STA 

TABCNT 


MOV 

A,M 


SUI 

6 


STA 

EOLCNT 


MOV 

A,B 


SUI 

6 


MOV 

3, A 


INX 



INX 



INX 

H 


INX 

i! 


INX 


* 

INX 

11 


CM 

RE AD REC 


CZ 

READ REC 


CM 

RESTORE 

OLDLINE 

LDA 

TAB 


CPI 

0 


MOV 

A,M 


JNZ 

NOT A3 


CPI 

03JH 


JNZ 

A3TK 


(SET MAXIMUM TADS PER LINE 
,AND SAVE IS TABCNT 


Dear DDJ 

Here is an observation of a serious error in programming 
style that has probably been noted before, but probably not 
as often or as strongly as it should have been. 

First let me say that my programming style is as peculiar 
in many ways as anyone’s and is certainly not beyond criti¬ 
cism; however, I feel that most will agree with me in regard to 
this particular point. 

Here is an example (can you find the problem?): 

10 REM ** THIS PROGRAM IS TO POINT OUT A PROBLEM ** 
20 PRINT “COMPUTERS NEVER MAKE MISTAKES” 

30 LET X = X + 1 
40 IF X = 10 THEN 60 
50 GOTO 10 

60 REM ** LETS STOP PRINTING THIS JUNK ** 

70 END 

Do you see the error? It occurs twice in the fisting. In 
lines 40 and 50 there are branches to remark statements. 
This may seem trivial in a small program like the one above; 
however, many times it is useful to strip out remarks to save 
space in a very large program. If in the above example fine 10 
were deleted, the program would not run until you changed 
fine 50 to ‘GOTO 20’. It is my contention that, if the prog- 
grammer had done that to begin with, there would have been 
no problem. It is particularly easy to make this mistake in 
BASIC since every line number is potentially a label, but I 
have seen examples of this in other languages also. 

Sincerely, 216 Northwest Terr. 

Bruce B. Thomson Silver Spring, Md. 20901 


Page 58 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 45 

223 





Dr. DoBB'S JOURNALof 

COMPUTER 

(Calisthenics ^) rt hodontia 

Running Light Without Over byte 

Number 46 June/July 1980 Volume 5, Issue 6 

A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 

On The Subject Of Networking 


A Survey of Computer Networks 6 

Art Kleiner 

The Personal Computer Network (PCNET) Project: A Progress Report 10 

Dave Caulkins 

MCALL-C: A Communications Protocol for Personal Computers 16 

Tim J.Pugh, Jr. 

On Modems 22 

William Smith 

Random Ruminations on Networks of the Future 40 

Jonathan Sachs 


... and, as always, even more 


225 





BY ART KLEINER 

Box 428 

Sausalito, CA 94965 


As the Information Age im¬ 
pends, it’s beginning to look more 
and more like an interconnected 
stream of computer networks. Most 
networks (except for the Arpanet) 
have been active three years or 
less; yet already they’re having as 
much impact on the people who 
use them as the first automobiles 
did on early drivers. Not all net¬ 
works are connectable to all types 
of terminals, but the differences in 
their design should be noted by 
computer users, who are prominent 
among the first computer network 
memberships and influential in the 
directions these networks will take. 

In this survey, an update of an 
article in the Summer, 1979 CoEvo- 
lution Quarterly (Box 428, Sausa¬ 
lito, CA 94965), I tried to ask the 
political questions: Who owns the 
networks? Who has access to 
them? How are they paid for? How 
is their interaction with their mem¬ 
bers designed? What provisions 
exist for privacy? How do people 
get in touch? This is not an ex¬ 
haustive survey (for example, it 
does not include the most influ¬ 
ential network of all, the Arpanet ), 
but it should give some idea of 
what options are available. The 
two-paragraph descriptions are by 
necessity over-simplified. 

In meeting Dr. Dobb’s deadline, 
it was not possible to fact-check all 
the descriptions below. A more 
comprehensive article on the sub¬ 
ject will appear in the Next Whole 
Earth Catalog, in September 1980. 


K Survey o! 
Computer networks 


QUBE, a two-way cable TV station 
from Columbus, OH; may soon be intro¬ 
duced to Boston and Pittsburgh. Started 
December, 1977. Sponsored by Warner 
Communications Corporation and Amer¬ 
ican Express. Contact: Leo Murray, Vice 
President of Public Affairs, 75 Rocke¬ 
feller Plaza, New York, NY 10019. 

This widely-publicized, two-way cable 
TV station offers normal cable TV, pay 
TV and local channels with some inter¬ 
active programs. On interactive shows, 
viewers push yes/no/multiple choice 
buttons to respond to opinion polls or 
to order products from commercials. 
A central computer monitors each TV 
set every 6-10 seconds, recording 
responses and what channel the set is 
tuned to. The system is used for political 
polls, exam-taking in educational pro¬ 
grams, talent shows where the home 
audience rates the contestants, and 
commercials with built-in market re¬ 
search. Since American Express pur¬ 
chased part of Warner Communications 
last year, there has been increasing 
emphasis on Electronic Funds Transfer 
and shopping at home. 

Warner’s research showed people 
wanted the simplest system possible — 
hence the limited amount of interaction. 
“Mrs. Jones doesn’t want to take the time 
to learn to be a computer expert,” 
spokesman Leo Murray said. QUBE warns 
viewers in advance when their responses 
are recorded, and doesn’t release records 
without subscribers’ consent. 

To connect you need: a TV, a $19.95 
one-time installation charge, and $10.95 
monthly rental. Pay-TV programs average 
$1 -$4 each. 

VIEWDATA is a brand name for a 
type of interactive text service originally 
developed by the British Insac Corpora¬ 
tion for the British Post Office. Like 
Kleenex and Xerox, the brand name has 
come to mean the entire type of product, 
even though there are many competing 
variations by now. 

The basic British Viewdata system 
involves an adapted TV set with a tele¬ 
phone connection and a remote control 
switch box that looks like a pocket calcu¬ 
lator. Viewers press numbers to call for 
pages of travel information, business 
information, retail advertising, or 


constantly updated news. News agencies 
and advertisers pay the British Post Office 
for the opportunity to put their messages 
on the air. A central computer is signalled 
through the viewer’s telephone, and 
responds by finding the appropriate 
Viewdata “page” and flashing it on the 
viewer’s screen. Pages appear in bright 
colors and block letters; each page 
includes a list of 10 other pages that can 
be called up for more information, like a 
cross between a library and a chain letter. 
(Information scientist Jacques Vallee 
called it “a boring maze of branching 
tunnels.”) Sometimes people must go 
through seven or eight pages to find the 
one they want. There is more choice than 
with QUBE, but users are still limited; 
they cannot communicate with each 
other, except through pre-written elec¬ 
tronic “greeting cards.” 

To connect, British viewers need an 
adapted TV ($300-500 more than a 
regular TV, according to one British 
correspondent; $30-50 more, according 
to Insac in New York) plus the price of 
a phone call. Each page carries a charge, 
usually 1 </-4</. 

Several companies are developing 
Viewdata systems in America. General 
Telephone and Electronics owns the 
American rights to the British Viewdata 
system, through Insac Viewdata, Inc. an 
American Insac subsidiary. GTE also 
owns Telenet, a national network for 
transmitting computer-signals cheaply, 
and Sylvania, the television manufac¬ 
turing company. They are expected by 
some observers to combine all three into 
a business-oriented national Viewdata 
system, which may eventually also be 
adapted for home use. 

The Knight -Ridder newspaper chain 
is testing a Viewdata-type system called 
Viewtron in Miami. Interestingly, GTE’s 
major competitor, American Telephone 
and Telegraph, is supplying the hardware 
for this system. Contact: Viewdata 
Corporation of America, One Herald 
Plaza, Miami, FL 33101. 

KSL-TV, Salt Lake City, and KMOX- 
TV, St. Louis, both have had experimen¬ 
tal demonstration systems running for 
two years. In both cases, a public system 
is still pending FCC approval. KSL is 
affiliated with the Mormon church; 
KMOX is owned by the CBS Broadcasting 


Page 6 

226 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 



Network, whose executives are reportedly 
worried that viewers will switch to the 
Viewdata channel during commercials. 
Other Viewdata-type systems are running 
ill France (Antiope) and Canada (Telidon, 
with reportedly a very sophisticated 
graphic “look” and animated pages.) 

PCNET (Personal Computer NET- 
work) is nationwide. Available from 
People’s Computer Company, Box E, 
Menlo Park, CA 94025. 

A committee of volunteers, chaired by 
Dave Caulkins of Los Altos, CA, have 
developed an electronic mail system for 
Commodore PET personal computers 
which operates over telephone lines. Most 
of the work involved developing a 
method of correcting the large number of 
errors caused by garbled phone-line 
transmission. Users can start with PAN 
programs (an illegitimate son of an 
Arpanet mail system called Hermes, 
Caulkins said) to send messages but need 
the full PCNET program (price not 
available at deadline) to transfer files and 
programs without losing characters. Users 
can arrange for their computer to send 
the mail late at night, when they’re asleep 
and the phone rates are lower. 

There is no central switching computer 
in PCNET. “That’s our political deci¬ 
sion,” Caulkins said; decentralized net¬ 
works are harder to control. To protect 
privacy, users are encouraged to develop 
automatic message-encoding programs. 
Future plans include adapting other 
microcomputer brands and sending mes¬ 
sages over short-wave radio. 

PCNET has been recently joined by 
similar programs doing the same for other 
brands of computers. Information Un¬ 
limited, Inc., 793 Vicente Ave., Berkeley, 
CA 94707, has developed a message sys¬ 
tem for Apples which they call Easy 
Mover. Other programs are also being 
developed — all presumably with dif¬ 
ferent protocols, and all unable to send 
messages to any but the same program. 

THE SOURCE is nationwide. Started 
June, 1979. Available from Tele¬ 
computing Corporation of America 
(TCA), 1616 Anderson Road, McLean, 
VA 22101. 

This was the first home-terminal 
consumer information network in 
America, and certainly the most am¬ 
bitiously promoted. People with home 
terminals or personal computers can call 
up specific information, including a 
version of the UPI news wire and a ver¬ 
sion of the bibliographic New York Times 
Information bank. In addition, the 
Source offers electronic mail and bulletin 
boards, programs which analyze statistics 
off the Wall Street stock index, and a 
clientele which is hungry to communicate 
with eachother. 


All this is transmitted over Telenet and 
Tymenet, two national computer-signal 
transmission networks which can be 
dialed locally from most cities, and which 
are much cheaper than long-distance 
telephone calls. The Source intends to 
market its accounts through franchised 
stores called “Telecomputing Centers.” 
It currently has about 4,000 active 
subscribers. 

According to many users, some of the 
Source’s promised features — such as 
airline reservation guides or conferences 
— have been slow to materialize or have 
not lived up to expectations. Slow 
response time and frequent breakdowns 
have reportedly also been perennial 
problems. However, the Source deserves 
credit for bringing the idea of a home- 
based computer network with many more 
options than Viewdata out into the open. 
TCA just signed a contract with a 
national library network (OCLC) to put 
Source terminals in public libraries 
around the country. 

To protect privacy, records are kept 
on the Source of how often each piece 
of information is called up, but not of 
who is calling for what. A directory of 
users is limited to first name, state, and a 
one-line description of interests — which, 
ironically, cuts short the easier con¬ 
nection-making which a fuller direc¬ 
tory would provide. TCA offers a $5,000 
reward to anyone who can break into the 
system’s central account and access other 
people’s files. 

To connect, you need a terminal or 
personal computer and telephone hook¬ 
up, a $100 entry fee (unless you buy 
your terminal from the Source), and 
$2.75 per hour of use. The service is 
limited to off-business hours and 
weekends — during business hours, it’s 
$15/hour. 

MICRONET was started in October, 
1979. Contact: Personal Computing 
Division, CompuServe Incorporated, 
5000 Arlington Centre Blvd., Columbus, 
OH 43220. 

A home-terminal computer network, 
similar to the Source, piggybacking off 
the CompuServe Time-sharing company, 
Micronet is younger than the Source and 
concentrates on business programs, file 
editing, and electronic mail. Except for a 
stock price index, there are no news-wire 
style databases yet; reportedly some are 
planned for introduction later this year. 
Micronet is more conservative in its 
promises than the Source, but much 
quicker in response time. A Micronet 
accounts costs $9 in start-up fees and $5 
for every connect hour, when signed-on 
via CompuServe’s own packet-switching 
network. In some cities signing on via 
Tymenet is necessary, at an extra $2/ 
hour. 


EIES (Electronic Information Ex¬ 
change System) is nationwide, begun 
October, 1976. Originally funded by the 
National Science Foundation; now 
operating as an independent computer¬ 
ized conferencing system. Organized by 
Murray Turoff and Roxanne Hiltz, co¬ 
authors of The Network Nation. Contact: 
Anita Graziano, Computerized Confer¬ 
encing and Communications Center. 
New Jersey Institute of Technology, 
323 High Street, Newark, NJ 07102. 

EIES is a community of about 900 
cross-continental members, divided into 
groups devoted to specific topics, such as 
Technology for the Handicapped or 
General Systems Theory. Many members 
belong to several groups, and members 
are encouraged to communicate with as 
many others as they have time and 
interest for. They collaborate on research, 
conduct several informal news networks, 
introduce themselves to each other via 
keywords that signal common interests, 
and gradually build up on-line libraries 
of relevant information. 

EIES has many members active in 
community information exchange and 
social alternatives; its mix of people from 
corporations, government, non-profit 
groups and the arts is unique among 
computer networks. It’s also the site of 
several specially-designed experimental 
programs for weaving interactive stories 
that respond to answers from the reader; 
for filtering through masses of technical 
information quickly; and for corres¬ 
ponding anonymously or under pen 
names. Most EIES members sign in 
through Telenet. There are about 30 
European members. 

To become a member, you need to 
apply at the address given above. 
Accounts cost $66/month and $3.75/ 
hour. Trial accounts are also available for 
no monthly fee and $5.25/hour. Groups 
can buy cooperative slots (which is true 
of most networks), and can (for about 
$350,000) buy the hardware, software 
and maintenance to create their own 
EIES-like system. 

Some other computer conferencing 
systems, with different mixes of member¬ 
ship and capabilities than EIES: 

• I. P. Sharp, a less expensive system 
based in Toronto, piggy-backed onto the 
Sharp Timesharing network, adapted for 
use by businesspeople and artists. Sharp’s 
conference program is limited to one-line 
comments and can be quite surreal when 
five or more people are involved. 

• Confer, a university-oriented con¬ 
ferencing network with a strong feeling 
of community, based at the University 
of Michigan. 

• Comet, a business conferencing system, 
one of the many networks developed 
out of the Arpanet. Contact: Computer 


Number 46 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 

227 



Corporation of America, 575 Technology 
Square, Cambridge, MA 02139. 

• Planet/Notepad, a relatively expen¬ 
sive but easy to learn business system, 
managed by parapsychology investigator/ 
information scientist Jacques Vallee. 
Planet grew out of Forum, one of the 
first and most influential computerized 
conferencing networks, at Menlo Park’s 
Institute for the Future. For information 
on Planet, contact: Sal Suniga, InfoMedia 
Corporation, 530 Lytton Avenue, Palo 
Alto, CA 94301. 


PLATO. Started in 1969. Nationwide. 
Originally developed at the University of 
Illinois as a computer-aided instruction 
program. Now owned and operated by 
the Control Data Corporation, P. O. 
Box O, Minneapolis, MN 55440. 

Like Viewdata, PLATO produces its 
“lessons” in pages — but unlike View¬ 
data, humans can interact much more 
with each page, since they have a full 
keyboard. Each page asks the user a ques¬ 
tion and produces new pages depending 
on the answer. Pages compose themselves 
on the screen as if the program were twid¬ 
dling a full-color Etch-A-Sketch behind 
the scenes. Users can send messages to 
anyone else on the system, although the 
system does not store the messages. Up 
to five conversations can go on a screen at 
any one time. PLATO is used for business 
training, remedial education, and training 
in prison. 

The public school district in Irvine, 
California is developing a plan to make 
PLATO available through a city-wide 
cable TV system. Current plans call for a 
trial system to be developed sometime 
during 1980. 

The specially-designed PLATO 
plasma-screen terminals cost $5,000 or 
more and connect time to the central 
system is expensive. Most users travel to 
Control Data’s own “Learning Centers” 
in many cities to use the systems. The 
public school district in Irvine, California 
is developing a plan to make PLATO 
available though a city-wide cable TV 
system sometime this year. 

Control Data is also beginning a pair 
of computer networks for shaing infor¬ 
mation between small-farm farmers, 
“urban problem-solvers,” and low- 
income groups. These are being developed 
among small groups of people now, and 
have provoked controversy among some 
appropriate technology and community 
information advocates, who distrust 
CDC’s motives. For information on 
the Urban Technology Exchange, write: 
Linda Jadwin, Director, Urban Tech¬ 
nology Exchange, HQS1 IB, Control Data 
Corporation, Box O, Minneapolis, MN 
55440. For the opposition point of view, 
write to: Gil Friend, Office of Appro¬ 


priate Technology, 1530 10th Street, 
Sacramento, CA 95314. 

PANALOG was started December, 
1977. An informal community of infor¬ 
mation scientists, students, and re¬ 
searchers in technology for the deaf, 
based at General Telephone and Elec¬ 
tronics Labs outside Boston. Contact: 
Ed Housman, GTE Laboratories, 40 
Sylvan Road, Waltham, MA 02154. 

Housman used excess computer time 
on the GTE computer to establish his 
own informal conferencing network. 
Members of the network use it to discuss 
information theory, plan meetings, and 
generally keep up a running rap on any¬ 
thing of interest. Many of its members are 
deaf, using it in part to keep each other 
informed of news involving the deaf 
community. More specifically, though, 
Panalog is notable for its whimsical 
human-ness (users receive three Chinese- 
fortune-cookie-style epigrams when they 
log off). 

Five major American corporations 
are expected to introduce large-scale 
computer network systems for business 
and possibly home use during the next 
few years. They are: 

1. American Telephone and Telegraph, in 

addition to supplying the hardware for 
Knight-Ridder’s Viewdata experiment in 
Miami, AT&T is testing a terminal-in- 
the-home Electronic Information Service 
in Albany, New York. People use 
computer terminals attached to their 
phones to look up directory assistance 
numbers and emergency telephone num¬ 
bers. In addition, there is Advanced 
Communications Services (ACS), a multi¬ 
computer nationwide packet switching 
network first proposed in 1978. ACS as 
first proposed was an elaborate system 
which could accept many different types 
of terminals and computer hook-ups, 
provide electronic mail and conferencing, 
rent computer programs and store data. 
AT&T has withdrawn its proposal, re¬ 
portedly because they hadn’t worked out 
the technical bugs of such a complex sys¬ 
tem yet (and possibly because the regula¬ 
tory climate wasn’t right). There is con¬ 
cern among current packet-switching 
networks and consumer groups that the 
monopoly status and enormous assets of 
AT&T would give the company an unfair 
advantage over the computer network 
competition. 

More than any other large firm, AT&T 
has shown interest in the terminal in the 
home; a recent issue of a Bell employees’ 
magazine was devoted to the subject, 
with a painting of an electronic home of 
the future by Studio 54 designer Ron 
Doud. Reportedly they are concerned 
that involvement of many other 
companies in computer networks would 


lead to involvement of many other 
companies in voice transmission as well. 

2. General Telephone and Electronics is 
developing several concurrent plans for 
office-of-the-future mail and informa¬ 
tion systems, possibly including manu¬ 
facturing terminals through its Sylvania 
subsidiary. GTE owns Telenet, and is 
developing its own electronic mail system 
on that network. It also owns the rights 
to develop the British Viewdata system 
in America. According to a staff member 
in their Viewdata group, “We’re looking 
at Business applications initially; but we 
anticipate that this will evolve at some 
point into a consumer system, depending 
on the availability of information pro¬ 
viders and terminals.” Panalog was also 
developed for GTE, and some of its 
features may be considered for other 
office-of-the-future systems. 

3. Xerox, earlier this year, released plans 
for two complementary computer net¬ 
works: Ethernet , which runs through 
coaxial cables in a single building, is 
already available. XTEN, which would 
use its own satellites to transmit com¬ 
puter signals over radiofrequencies be¬ 
tween Ethernets, is on application before 
the FCC. Like ACS, Xten would permit 
many types of terminal and computer 
connections; Ethernet is marketed in such 
a way that connecting to it may become 
a universal standard. 

4. Satellite Business Systems, part-owned 
by IBM Comsat, and Aetna Life In¬ 
surance, plans a network to transmit 
computer messages and video- 
conferencing between large corporate 
offices over the same satellite. 

5. Exxon is widely rumored to be 
planning some sort of national computer 
network, tied to subsidiaries which 
manufacture fiber-optic transmission 
lines and the laser equipment to send 
messages through them. Exxon owns 
subsidiaries which manufacture the Oyx 
terminal; the Zilog chip; and Qwip, the 
most successfully selling facsimile trans¬ 
mission device. Another Exxon subsidiary 
is developing automatic telephone¬ 
answering computer systems. Reportedly, 
Exxon is also developing a method for 
Qwip to encode and store facsimile trans¬ 
missions digitally, so they could be 
(eventually) tied into computer networks. 

Some interesting smaller-scale com¬ 
puter network proposals (which don’t 
exist yet): 

Datacast. San Francisco, beginning 
August, 1980. Formerly known as 
Digicast. Proposed by Wireless Digital, 
Inc., a new company managed by Jim 
C. Warren, Jr., who organizes the annual 


Page 8 

228 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 



West Coast Computer Faires. Contact: 
Wireless Digital, 345 Swett Road, Wood- 
side, CA 94062. 

Like Teletext, Datacast will transmit 
words and pictures over broadcast waves 
in a steady stream. Using Sub carrier 
Authorization channels, which are unused 
FM frequencies linked to existing radio 
stations, Datacast will be a steady stream 
of wire service news, financial data, real 
estate listings, classified ads, weather and 
library resources. To receive it, users will 
need a modified personal computer with 
a radio receiver ($400 or less above the 
cost of the computer). As in Teletext, the 
computer will pull out only those items 
which it has been programmed to catch. 
Until it gets going, Datacast will be 
covered in its own newsletter, available 
from Wireless Digital for $5 /year. 

Xanadu. Nationwide, beginning some¬ 
time this year. Proposed by Project 
Xanadu. Contact: Theodor Nelson, Box 
128, Swarthmore, PA 19081. 

Nelson, who published the milestone 
book Computer Lib /Dream Machines in 
1972, described there his plan for a com¬ 
puter network system in which people 
would edit alternate versions of text, 
jump back and forth between the 
versions, and make royalties based on 
how many people would call for their 
writing. His current plans call for such a 
system to begin running by the end of 


this year, possibly through locally 
franchised “Information Centers.” 
Xanadu will be used for conferencing, 
writing, editing and reading. Rather than 
a single index to everything on the sys¬ 
tem, users will be encouraged to create 
their own indexes to what interests them 
and publish them for others. 

Nelson said they are looking at hourly 
costs of $2 (300 baud) and $5 (1200 
baud). Xanadu may operate its own trans¬ 
mission hardware instead of relying on 
Telenet or Tymenet; or the Xanadu sys¬ 
tems may only operate locally. 

The Community Memory Project, San 
Francisco, is beginning sometime this 
year. Sponsored by the Community 
Memory Project. Contact: Sandy 
Emerson, 916 Parker Street, Berkeley, 
CA 94710. 

Convinced that computer networks 
should be decentralized, open to 
everyone and service-oriented, Com¬ 
munity Memory put inter-connected 
terminals in Berkeley public places 
between 1973 and 1975. People used the 
system as an electronic bulletin board for 
news, messages, classified ads and poetry. 
Others used the terminals to pull out 
information with the appropriate key¬ 
words, or to add comments to existing 
messages. A new similar system will be 
established in a Bay Area neighborhood. 


Up to 20 terminals will be placed in 
community centers and neighborhood 
gathering places. All information in the 
system will be entered by the people 
who use it, and no one will connect to 
Community Memory through private 
terminals. In the meantime, some of the 
text editing and file-arranging programs 
which will compose the Community 
Memory system are being offered for sale 
separately. 

OCLC/Home Delivery of Library 
Services is starting mid-1980 in 
Columbus, OH at first; then possibly 
nationwide. Contact: Philip Schreiber, 
OCLC Inc., 1125 Kinnear Road, 
Columbus, OH 43212. 

OCLC used to be the Ohio College 
Library Center. Their new home system 
will use a keypad like QUBE’s (but smaller 
and less expensive), an adapted TV, and 
the telephone lines. Columbus residents 
will use OCLC’s system to bank at home 
and to call up pages of an on-line 
encyclopedia. OCLC is also planning to 
put Source terminals in libraries nation¬ 
wide. 

AIM is an EIES-like conferencing sys¬ 
tem, with an emphasis on developing 
a community computer system for 
alternative communities. Contact: Steve 
Heitmann, Rt. 2, Box 502A, Portland, 
OR 97231. 



Number 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

229 












THE PERSDnflL CdiTlPUTER nETWDRR 

[PCflET] PROJECT: 


A PROGRESS REPORT 


BY DAVE CAULKINS 
PCNET Project 
1263 El Camino Real, Box E 
Menlo Park, CA 94025 

INTRODUCTION 

This article describes the PCNET 
project, its goals, a brief history of ac¬ 
tivity, PCNET status today, and PCNET’s 
future plans. 

GOALS 

The goal of the PCNET project is to 
provide a reliable, error free and low- 
cost means of transferring files, programs 
or messages among personal computers 
(PCs) via the dial-up telephone system 
or other media. To achieve this goal in 
a reasonable way the PCNET Project 
adopted a series of system design objec¬ 
tives: 

1. PCNET software will be hardware- 
and operating-system independent; any 
PCNET-equipped computer will be able 
to communicate with any other PCNET- 
equipped computer. 

2. PCNET will be adaptable to as broad 
a range of existing hardware and software 
systems as possible. 

3. PCNET will be a distributed system; 
any two computers running PCNET 
software will be able to communicate 
with no requirement for additional 
centralized resources. However, this will 
not preclude time-sharing systems and 
other centralized services from running 
PCNET ‘front ends’ in order to communi¬ 
cate with PCNET equipped small com¬ 
puters. 

4. PCNET will be capable of unattended 
operation; any two PCNET systems will 
be able to initiate a telephone connection, 
transfer information and terminate the 
connection without the presence of an 
operator at either end. This will allow 
PCNET systems to take advantage of the 
low telephone rates available from 
11 PM to 8 AM. 

5. No personal computer user will require 
more than a single telephone line to 
participate in PCNET. 

6. PCNET will be layered; i.e., PCNET 
software will be divided into distinct 
functional layers. Communication be¬ 
tween layers will be sparse and well 
defined. Any layer can be modified or 
even replaced with minimum effect on 


the others. This kind of design should 
make PCNET readily adaptable to chang¬ 
ing opportunities in hardware and media. 
Modems are going to be capable of higher 
speeds, and communication by other 
media such as radio (see discussion of 
Packet Radio below) will become pos¬ 
sible. Layering allows relatively easy 
accommodation to these technological 
advances. 

PCNET History 

The PCNET Project (then called the 
PCNET Committee) was started at the 
first West Coast Computer Faire in 
April of 1977. PCNET was and is a non¬ 
profit organization of volunteers; all 
PCNET developed software is placed 
in the public domain. PCNET is now part 
of People’s Computer Company. The 
first year of PCNET activity produced a 
protocol design (a protocol is a set of 
conventions for computer-to-computer 
telecommunication) and some experi¬ 
mental software mechanizing protocol 
operation. This software was demonstra¬ 
ted at the second Faire in March of 1978; 
an 8080 based system in Santa Clara, 
CA sent a file to a PET at the Faire in 
San Jose, CA with both machines run¬ 
ning PCNET software. Noise was delib¬ 
erately introduced on the phone line to 
damage some blocks of data; the two 
machines successfully detected the bad 
blocks and retransmitted good ones. 

In 1979 the TNW Corporation and 
PCNET developed PAN, a small electro¬ 
nic mail system. This sytem lacks the 
power of the full PCNET protocol, 
but is quite adequate for handling English 
text messages and allows people with 
limited telecommunications experience 
to get a feel for what telecommunication 
is all about. The first version of PAN 
runs in the Commodore PET and TNW488 
modem; a program tape and instruction 
manual are available from P.C.C. for $12. 
We’re working on a version for the Apple 
II and Micromodem II, and intend to 
do one for the TRS-80. See Appendices 
B and C for more information about PAN. 


PCNET STATUS 

PCNET Design Description. This sec¬ 
tion presents a brief description of 
PCNET design. Each PCNET installation 
is called a Node;it consists of a computer, 
a modem, and the PCNET software. 
The software will activate one of two 
capability levels: Simple, for machines 
of small size or limited resources, and 
Advanced, for more powerful machines. 
A 48K Apple II with a Micromodem II 
is an example of a machine which could 
become an Advanced node. In keeping 
with PCNET design objectives all nodes 
will be able to communicate in Simple 
mode, but two nodes able to switch to 
Advanced mode will be able to do more 
and do it faster. Node-to-node communi¬ 
cation always starts in Simple mode, 
but switches to Advanced mode as soon 
as possible if both nodes can handle it. 

Figure 1 shows a diagram of the 
PCNET layers as they are implemented 
in hardware and software in a PCNET 
node. The node that initiates a call 
(dials the phone) is called the originate 
node; the node that accepts a call (an¬ 
swers the phone) is called the answer 
node. Information starts at the top 
(server process) layer of the originate 
node, works its way down through the 
layers and across the phone line to the 
answer node. There it goes back up 
through the answer node layers to the 
server processes. At the top (server) 
layer in both nodes area the programs 
actually carrying out user functions— 
for example a File Transfer Program 
(FTP), an electronic mail program 
(MAILER), etc. PCNET can communi¬ 
cate data to and from several simulta¬ 
neously active server programs. 

Let’s follow the sequence of events 
in detail, assuming that both FPT and 
MAILER are active, and that the phone 
connection to the answer node system 
has already been established. Starting 
at the top (server) layer in the originate 
node: each server process passes a stream 
of data to the Directing layer; MAILER 
is sending an electronic mail message, 


Page 10 

230 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 



and FTP is sending an object program 
to be executed later in the answer node 
computer. 

Directing Layer. In this layer the two 
streams of data are broken up into 
Directed Blocks; each such block has a 
header with the address of the server 
process in the answer node to which it’s 
to be delivered, and a data section con¬ 
taining a piece of actual data. The Direc¬ 
ted Blocks are then passed to the Valida¬ 
ting Layer. 

Validating Layer. Here the Directed 
Blocks have additional header informa¬ 
tion added, and an error detecting code 
appended to the end of each block. 
The resulting Validated Blocks are 
passed to the Translating Layer. 

Translating Layer. In this layer the 
Validated Blocks undergo a translating 
process; they are converted into Radix- 
41 format if this is a Simple node, or 
into transparent binary if this is an 
Advanced node. 

Radix-41: Radix-41 is a 2 byte to a 
3 character packing scheme invented by 
Mike Wilber; the conversion from binary 
to Radix-41 guarantees that no control 
characters appear in the transmitted 
data which might cause undesired actions 
by some operating systems. Thus use of 
Radix-41 guarantees that PCNET will 
run without interference under any op¬ 
erating system known to us. Either 
Radix-41 or transparent binary can 
handle data in binary, ASCII or any 
other form, but transparent binary 
supports higher transmission speeds. 

Framing Layer. Here the Translated 
Blocks have delimiting characters added, 
resulting in Framed Blocks. 

Hardware Layer. This layer consists of 
the modem and any other hardware 
required to interface to the dial-up 
telephone system. Modems suitable for 
PCNET use are under full software con¬ 
trol; a detailed discussion of modems 
may be found in Appendix A. In the 
modem the bytes making up the Framed 
Blocks are translated into serial bits, 
each of which is then converted into 
one of two audio tones for transmission 
over the phone line. 

Now let’s follow the information as it 
goes through the same layers in the op¬ 
posite direction in the answer node. 

Hardware Layer. The answer node modem 
converts the sequence of audio tones 
into a serial bit stream, and this is turned 
into a sequence of Framed Blocks. 

Framing Layer. Here the framing char¬ 
acters are used to identify the block 


starting points; they are then discarded 
resulting in Translated Blocks. 

Translating Layer. In this layer the 
blocks are translated into binary; from 
Radix-41 if the nodes are operating in 
Simple mode, or from transparent binary 
if they are in Advanced mode. 

Validating Layer. The error detecting 
codes in each block are evaluated; if the 
block is error-free an acknowledgement 
block is created and sent to the ori¬ 
ginating node, indicating to it that the 
current block has been successfully 
received and that the next block may be 
transmitted. The error detecting code and 
Validated Block header material are 
stripped from the block, and the re¬ 
sulting Directed Block is passed up to the 
next layer. 

Directing Layer. The header of the block 
is examined to see whether it is intended 
for the FTP or MAILER process in the 
answer node; all remaining header ma¬ 
terial is stripped off and the data is passed 
to the indicated process. 

PRESENT PCNET ACTIVITIES 

A small group of PCNET people is 
presently (April, 1980) working in¬ 
tensively to develop 1 to 4 complete 
implementations of the PCNET protocol 
running in several different computer/ 
modem pairs. The resulting software 
will be in the public domain; it will be 
distributed to anyone at modest cost and 
will probably be published here in DDJ. 
This software is also intended to serve as 
‘model’ software in a PCNET im¬ 
plementation workshop to be held 
later in the year. We hope this work¬ 
shop will produce many additional im¬ 
plementations covering the majority of 
computer/modem pairs in use today. 
All this software will support real but 
sparse Server level processes such as 
file transfer and electronic mail. 

A volunteer organization like PCNET 
is not well suited to creating and main¬ 
taining software products. It’s our hope 
that individuals and software companies 
will use PCNET software as the basis 
for products which will utilize PCNET 
protocols as a telecommunication stan¬ 
dard. 

FUTURE PLANS 

Although the dial telephone network 
is easily accessed, it is far from ideal 
as a PCNET medium, since it is op¬ 
timized for voice and not data. Phone 
system bandwidth is limited and costs 
are high and going higher. We believe that 


radio offers both lower cost and higher 
bandwidth. US Government research has 
shown that many PCNET type users can 
effectively share a single radio frequency 
allocation using a technique called packet 
radio. The Canadian Government has 
wisely assigned radio spectrum space 
(220-225 MHz) for Canadian radio a- 
mateurs to experiment with packet 
radio. We’d very much like to start 
similar experiments in this country. 
Canadian experience indicates that the 
entire radio transceiver and interface 
could be built for about $500, a price 
which would decline with any kind of 
production volume. Some reports by 
CARF (Canadian Amateur Radio Fed¬ 
eration) on packet radio work in Canada 
are reproduced in Appendix D. 

The PCNET project would like to see 
packet radio administered under licensing 
much more similar to CB radio than 
to amateur radio. We think packet radio 
equipment can be designed to prevent 
abusive behavior by ill-informed or mali¬ 
cious users. 

APPENDIX A 

PCNET Modems 

All telephone based data communication 
systems require modems to function. The 
features required for a PCNET modem are as 
follows: 

Hardware Features 

-Receive sensitivity of at least -40dBm; 

-45 to -50 dBm preferred 

— 10 pole receive filter; 6 pole transmit filter 

— 300 baud operation 

Features Under Software Control 

— Answer/originate mode select 
— Switch hook control; pulse dialing 
—Carrier detection 
-Incoming ring signal detection 

Desirable But Not Necessary Features 

-FCC Part 68 registration, permitting direct 
connection to the phone line without an 
otherwise legally required Data Access 
Arrangement 

-Telephone signalling tone discrimination, 
allowing software to detect DIAL TONE, 
BUSY, CALLED PARTY RING, etc. 
-Software selectable baud rate 
-Power up on incoming ring detect. 

The PCNET Project has found a 
number of modems that are suitable for 
PCNET use. A list of them is given below: 

TYPE — SI 00 Compatible 

The MM —103, from Potomac Micro-Magic, 
Inc., First Lincolnia Bldg, Suite Bl, 4810 
Beauregard St., Alexandria, VA 22312. 
Costs $359.95; is FCC Part 68 certified. 

The Micromodem-100, from D.C. Hayes 


Number 46 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

231 




Associates, Inc., 16 Perimeter Park Dr., Suite 
101, PO Box 9884, Atlanta, GA 30319. 
Costs $350.00; is FCC Part 68 certified. 

The 88-MODEM, from International Data 
Systems, Inc., 400 N. Washington St., Suite 
200, FaUsChurch, VA 22046. Costs $395.00 

TYPE — Apple Compatible 

The Micromodem II, from D. C. Hayes (see 
address above). Costs $389.00; is FCC Part 
68 certified 

TYPE — PET Compatible 

The TNW488, from The TNW Corpora¬ 
tion, 5924 Quiet Slope Drive, San Diego, 
CA 92120. Costs $320.00 

APPENDIX B 
PAN SOFTWARE 

Just recently, the PCNET Project an¬ 
nounced the availability of computer mail 
support software for use on personal com¬ 
puters. The software is called PAN, named for 
the illegitimate son of Hermes, the messenger 
of the Gods in Greek Mythology. The PAN 
software, in fact, was inspired by a sophisti¬ 
cated mail system called HERMES which was 
developed by Bolt, Beranek and Newman, 
Inc., for the DEC System 10 and System 20 
computers. 


PAN is a completely self-contained com¬ 
puter system. Any two PAN systems can 
exchange messages over an ordinary voice 
telephone line. PAN allows entry, review and 
automatic transmission of messages at times 
selected by the user. When a message is sent 
to a PAN it automatically answers the phone, 
receives and stores the message, and hangs up 
the phone to wait for the next incoming or 
outgoing message. Similarly when PAN has a 
message to be sent it automatically picks up 
the phone, dials the number of the recipient 
PAN, verifies that carrier is present and that 
PAN is active, transmits the message, and hangs 
up the phone to wait for the next transaction. 
Message exchange is possible between any 
two PAN systems regardless of the type of 
computer or modem used. Either or both PANs 
can record both incoming and outgoing mes¬ 
sages on tape or disk. 

PAN is the result of a collaboration between 
The Personal Computer NETwork (PCNET) 
Project of PCC and TNW Corporation. PAN is 
similar to Community Bulletin Board Systems 
(CBBS) in general functioning and command 
structure. It is different in that PAN is a dis¬ 
tributed system; there is no single phone 
number and set of equipment through which 
all messages must pass. 

The PAN system has communications ad¬ 
vantages over Jjoth traditional mail and the 
telephone, and cost advantages over existing, 
expensive electronic mail systems. 

Advantages of PAN over traditional mail; 


• Immediacy of delivery (or if preferred, 
“time tag” delivery) 

• A signal from the receiving computer 
allows the sending computer to mark 
the message “sent.” 

Advantages of PAN over telephone communi¬ 
cation: 

• PAN can record all received and trans¬ 
mitted messages for future reference 

• The PAN user need not be present to 
transmit or receive information 

• The PAN system has a “keep trying” 
feature which will wait until the line 
is clear to deliver the message. 

Cost Advantages over existing electronic mail 
systems: 

• Low entry cost 

• PAN uses the dial-up telephone network 

• Telephone charges can be quite low 

• PAN software is available for a cost of 
$12, including manual 

• PAN runs on a personal computer. 

The present PAN system is best for letter 
(English language) communications. PAN is 
designed so that all existing computer terminals 
now in use in major universities and corpora¬ 
tions can access PAN systems to read and write 
messages. Terminal-to-PAN communication is 
primitive due to the limited capacities of 
existing terminals. 

The PCNET Project plans continued de¬ 
velopments following this initial version of 
PAN. Some of these are detailed here: 

• Improvements in the error management 
capabilities of PAN. At present the error 
rate of PAN messages is about 1 error for 
every 5 minutes of message transmission. 
This error rate is not adequate for computer 
programs or financial data. An error rate of 
1 error for every two weeks of message 
transmission appears to be attainable. 

• A file transfer capability will be sup¬ 
plied. This will allow a complete pro¬ 
gram to be sent from one personal com¬ 
puter to another over the telephone. 
Because of the low error rate the receiver of 
the program can be confident that the 
program will run successfully. This file 
transfer capability will allow ‘bootstrap’ 
loading of the PCNET program itself over 
the phone. To do this, a very short program 
is loaded by hand into the computer. This 
short program then manages the transfer of 
the much longer PCNET program from a 
remote computer via the phone line. By this 
process the PCNET programs can migrate 
from computer to computer very easily. 

• The PCNET Project hopes to experiment 
with other than the telephone system as 
the communication link between PCNET 
computers. One possibility is radio which 
has the potential of markedly increasing 
the amount of data that can be transferred 
while decreasing the cost. 

PAN Commands 

E — Enter a message. The phone num¬ 
ber of the PAN for which the 
message is intended must be in the 


Page 12 

232 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 




first line of the message. After 
message entry the user can select 
a mode assignment for the message. 

I — Immediate; send this message now. 

D — Deferred; hold this message for 
transmission later. The user is 
prompted for the time of trans¬ 
mission. 

N — Make no mode assignment for this 
message. A mode can be assigned 
later as described below. 

Q — Query; hold this message for sub¬ 
sequent retrieval by a non-PAN 
modem equipped computer or 
terminal. 

M - Mode assignment. Assign a new 
mode to the message whose number 
is given by the user. 

R - Retrieve a message. The message 
whose number is given by the user 
is displayed. 

S — Summarize messages. The numbers, 
modes and initial portions of all 
messages in the buffer are displayed. 

K — Kill (erase) the message whose 
number is given by the user. 

U — Unload PAN, restore operating 
system pointers and write an end- 
of-file on the message record tape 
or disk. 

? -- List the PAN commands. 


Modem equipped terminals or com¬ 
puters can send a message to a PAN 
system by calling the PAN and sending a 
special control character before the mes¬ 
sage text. A second control character 
after the text causes PAN to store the 
message and hang up the phone. 

PAN has been implemented for the 
Commodore PET and TNW488 modem; 
we are working on a version for the 
Apple II and Hayes Micromodem II. 
We plan versions for the TRS-80, S-100 
systems, etc. 

To receive the current PAN package 
(a cassette tape of the PET 
version of PAN and a user’s manual) 
sign and send the enclosed PAN license 
agreement with a check for $12 to: 
PCNET Project, People’s Computer Com¬ 
pany, 1263 El Camino Real, Box E, 
Menlo Park, CA 94025. Please also 
include the size of your PET’s 
memory — 8K, 16K, etc. 

We’re distributing PAN under a li¬ 
cense agreement for a number of reasons: 

• We want to be sure that all versions of PAN 
will be able to talk to one another. 

• We want to provide a central organization 
for the roster of PAN users, and for the 
distribution of new PAN versions. 

• We want to protect the rights of TNW Cor¬ 
poration, our associate in the PAN de¬ 
velopment program. 


APPENDIX C 
PAN Lower Level Protocol 

1. The originating PAN dials the number of 
the answering PAN. 

2. When the answering PAN detects ring, it 
goes off the hook and sends carrier. 

3. When the originating PAN detects carrier 
it sends carrier. 

4. When the answering PAN detects carrier 
it sends the string “@@@ANN” where ANN 
consists of a single alpha character followed 
by two numerics. This string is the version 
number of the answering PAN; as of 6 Feb 
80 it is P09. 

5. When the originating PAN receives one or 

characters it sends 5 CTRL-S characters. 

6. When the answering PAN receives one or 
more CTRL-S characters it prepares to accept 
subsequent received characters as a PAN 
message. If no CTRL-S characters are received 
the answering PAN times out and goes on hook. 

7. The originating PAN sends the message 
text. The first line of this text (between the 
first character and the first carriage return) 
contains the phone number of the originating 
PAN in the form (AAA)NNN-NNNN. By 
convention this first line also contains the 
sender’s initials and the originate PAN local 
time of transmission in 24 hour format; HHMM 
SS where HH ranges from 00 to 23. 

8. The originating PAN sends 4 CTRL-R 
characters to signal end of message; it then 
goes on hook. 

9. When the answering PAN receives one or 
more CTRL-R characters it goes on hook 
and places the received character string in the 
message buffer. If the answering PAN loses 
carrier at any time during message reception it 
goes on hook. 


APPENDIX D 
Packet Radio in Montreal 

This report about packet radio was pre¬ 
pared by Canadian Amateur Radio Federation, 
Inc. To be put on their mailing list, which 
means you will receive their next four Packet 
Radio Newsletters, send $5 to Art Blick at 
CARF, P.O. Box 356, Kingston, Ontario 
K7L 4W2. The money is to defray the costs 
of reproduction. 

Since the Montreal group was the first 
into packet it is not unusual that this group 
is the furthest advanced in this technology. 
A system has been fully operational since 
August of 1979, and has been continually up¬ 
dated since then. There are currently six 
stations on the net, with more working on 
modems and computers right now. 

The net operates on 223.5 MHZ cur¬ 
rently, but a move to 222.3 is expected as 
soon as all of the stations have their crystals. 
Audio frequency shift keying is used, at 2400 
bits per second. The mark tone is 2400 HZ 
and space is 4400 HZ. The modem is based 
on the Exar 2206. 2211 chip set, with a credit 
to Ted Balesta VE3CAF who first suggested 
the design. Having experimented with the 
design for almost a year now, it is capable of 
error-free transmission with S/N ratios of 
15 DB or so. Its perfection is due to the efforts 
of Jacques Orsali VE2EHP who “massaged” 
the design to its present performance levels. 


The radio is typically the Midland 13-509, 
running ten watts. It was chosen on the virtue 
of simplicity and price. The modificiations to 
it are simple and can be done in about thirty 
minutes or so. The interface to the radio was 
deliberately kept as simple as possible in 
anticipation of future users who may be either 
unwilling or unable to make extensive mods 
to the radio. Since just recently, Ted VE3CAF 
has joined the Montreal team, and we expect 
that he will make substantial improvements to 
the interface. 

The local net is being used for man-to¬ 
man communications mostly, but lately the em¬ 
phasis has switched to machine-to-machine 
transfers of programs, text files and the like. 
One user is currently writing a multi-user 
real time war game which will be implemented 
on the net soon. One of the unresolved ques¬ 
tions is what major use the net will be put to 
once fully implemented. Since this will depend 
on the character of the users, it will stay a 
question for some time yet. 

The network includes a store and forward 
repeater as part of the system, and this repeater 
is currently functioning. It was demonstrated 
at the RSO convention in the fall of 1979. 
It receives packets which are flagged as packets 
for repeating, and rebroadcasts them a few 
miliseconds later. It serves the same purpose 
as a conventional 2 meter job, i.e., it extends 
the range of a station using it. Since there are 
no cavities (it is a simplex device) it does not 
suffer from the usual problems of desense, 
and split antennas. Naturally, it is very ef¬ 
ficient and as we say in the business, “it talks 
far.” 

The repeater operates on the same fre¬ 
quency as the rest of the net and only re¬ 
peats pacs which are flagged to it. In this way 
we find two stations often using the repeater 
while two others who are close enough use 
simplex, all on the same frequency. In addition 
to its conventional roll, Digptr as it is called, 
offers other services to the users. By sending 
a pac to it (as opposed to through it) users 
can get a “Broadcast Message” which provides 
important information of immediate interest, 
system shutdowns, protocol changes and the 
like. The message can be changed remotely by 
the system operators, and is password pro¬ 
tected. Users can also use the Digptr to check 
out their system. Using the Test facility, a 
packet sent to Digptr, will be transmitted back 
to the station the same way it was received, 
that is, with or without errors. By accessing the 
status file of the repeater, users can see the 
number of pacs, and acks which have gone 
through Digptr, as well as those which were 
“direct” and bypassed it. System operators 
can use this function for statistics on usage, 
and throughput. 

The latest and perhaps most exciting de¬ 
velopment is that we now have a single board 
computer/terminal working. It is based on the 
Motorola Chroma II kit, sometimes called 
the TV BUG. This low cost ($300 or so) de¬ 
vice will implement the full packet protocol 
in PROM, and requires only a keyboard, a 
TV set and a compatible modem to run. This 
means that the cost of a complete packet set¬ 
up is reduced by a factor of about ten. We 
figure about $500 including the radio would 
be the maximum cost for someone who had 
nothing to start with. For those people who 
have micro computers already, TV bug will 
(continued on page 58) 
Page 13 

233 


Number 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



MCALL-C: A Communications Protocol 

for Personal Computers 


BY TIM J. PUGH, JR. 

Micro-Call Services 
9655-M Homestead Court 
Laurel, MD 20810 

In the protocol description which follows, I will identify 
alternative approaches that were considered in arriving at the 
present protocol. But before getting into the protocol itself 
I would like to try to clear up a misunderstanding that may 
exist concerning telecommunications protocols. The type of 
protocol which I am describing has no bearing on the informa¬ 
tion content of the data. The protocol acts simply as an en¬ 
velope or container of data. The data is inserted into the 
envelope at the originating (transmitting) end and auto¬ 
matically removed at the receiving end. Thus, by the time the 
data is placed on disk, it looks exactly the same as it did on 
the disk of the originator. 

Perhaps the first question to answer is “why have a proto¬ 
col?” The principal reason for having one is to insure, as far 
as possible, that no data is lost or garbled in the transmission. 
One can, and I often do, transmit and/or receive data files 
with a large Time Sharing Computer (TSC). These TSCs 
are typically very uncooperative beasts which output the 
data to you in “their own good time,” usually as fast as it 
can be sent. They are not concerned about whether you had 
noise on the line or whether you had time to write the last 
record to disk. That’s your problem. Thus, if you have a 
system which pays rapt attention to the incoming data and if 
the weather is good and you have a high quality modem, then 
you have an excellent chance of receiving error-free data. 

However, one cannot depend on all the above stated 
conditions being met, especially when two personal computers 
are involved. Such a transfer will frequently be “long dis¬ 
tance.” Each additional TELCO switching center involved in 
the “call” reduces the signal-to-noise ratio and often there is 
line “echo” distortion present. Thus, reliable data transfer 
becomes questionable without an intervening mechanism. An 
appropriate communications protocol supplies this mecha¬ 
nism. 

Serial Versus Blocked Data Format 

The simplest way to transfer a file is the way it is done with 
a TSC. The file is simply transferred serially to completion. 
It is assumed the receiving file has already been created 
and that the TSC is capable of recording the data at the 
maximum BAUD rate; e.g., 300 BAUD. Such an approach 
can also be used for transfers between two Personal Com¬ 
puters (PCs) provided the operation is properly coordinated 


Copyright© 1980 by Tim J. Pugh, Jr. 
Page 16 

234 


and synchronized. However, it is preferable to have the two 
computers do the necessary synchronization and coordination 
since it is then both more convenient for the users and less 
error prone. We have thus posited a protocol whereby the file 
is automatically opened at the Transmitting (TX) end and 
created at the receiving (RX) end and might look something 
like this: 

—@SOH < Cfilename> <Ctyp> 

<— (SACK 

—> <file data> 

The directed arrows indicate the direction of data transfer 
where “—>” indicates data from the TX to the RX. The 
signifies ASCII and thus @SOH indicates the ASCII 
Start Of Header control character. Similarly, “@ACK” signi¬ 
fies ASCII ACKnowledge. Assuming that the originating 
(TX) operator has previously specified the name of the file 
to be transferred; i.e., <filename><type> and further 
assuming that communication has been established between 
the two parties, then the transfer is initiated by the TX end 
issuing an @SOH followed by the name of the file. Since an 
indeterminate amount of time is required for the RX system 
to create the corresponding file, and ACKnowledgement is re¬ 
quired before the data transfer can begin. Why an indetermi¬ 
nate amount of time to open a file? Partly because there is 
such a variety of floppy disks and controllers capable of run¬ 
ning under CP/M (both 8” and 5 &”). Since a “handshake” 
character, @ACK, was required to signify “file created OK”; 
why not include the option of sending @NAK (Negative Ac- 
Knowledge) to signify some problem in opening the file? 
Let’s further assume that if @NAK is received by the TX 
end, the “@SOH <filename><typ>” will be repeated. 

Since we have provided for retransmission (reTX) of the 
Header Record, the next question is: how can we discontinue 
the retransmission, assuming the problem persists over several 
reTXs? This introduces a third control character, @CAN 
(ASCII CANcell). Thus our “handshake” in response to the 
Header Record can take one of three forms. This situation is 
handled nicely by the BACKUS-NAUR notation which fol¬ 
lows: 

<ack. form> : : =@ACK I @NAK I @CAN 

which states that the acknowledge form is defined equal to 
either @ACK or <®NAK or @CAN. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 





We next look at the <file data>. The most conventional 
method for “recording” received data is to first buffer it in 
memory and subsequently write it to disk. This allows the RX 
system to handle high BAUD rates, e.g., 1200 BAUD, without 
data loss. However, if large files are transferred, buffer over¬ 
flow might result. Thus, it is desirable to allow the buffer to 
be “dumped” to disk at appropriate times. A simple solution 
to this problem is to break the <file data> into small blocks 
followed by an <ack. formX Thus, if the data is broken into 
equal blocks of 128 characters the protocol would look some¬ 
thing like this: 

—> @SOH <filename> <typ> 

<— @ACK 
—> <data.blk> 

<— @ACK 

—> <data.blk> 

<— @ACK 

— > <Cdata.blk> 

<— (SACK 

The @ACK following each <data.blk> tells the TX system 
that the buffer write operation is complete and the next 
block can be sent. The above considerations argue strongly 
for a BLOCKED rather than a SERIAL data format for our 
protocol. 

Data Integrity Considerations 

The blocked protocol specified thus far provides for error 
recovery (reTX) in the event the <filename><typ> was 
garbled; e.g., noise caused a given character to be converted 
to a characger which is not legal when specifying file names. 
It also provided time for data blocks to be transferred from 
memory to disk. However, no provision has been made to in¬ 
sure that data integrity is maintained. 

The most commonly-employed technique for handling this 
problem is to use either a Cyclic Redundancy Check (CRC) 
or a Checksum. The CRC usually employs a polynomial 
equation for its realization. The term checksum, as used 
here, simply means a sum of all the characters in a given 
data block. Since each character in the ASCII set can be 
represented by seven data bits, this simply means the accumu¬ 
lated total obtained by adding each character in turn, to the 
previous partial sum. I have chosen the checksum because of 
its simplicity and ease of implementation. 

In implementing the checksum, two choices must be 
made: (1) The block size over which the checksum is to be 
taken; (2) The number of bits to be allocated to the checksum. 
The most convenient block size appears to be that associated 
with one physical record on disk; i.e., a disk sector of 128 
bytes. Having chosen the first parameter we find that the 
largest value the checksum could take on occurs if the ASCII 
rubout character (@DEL = 07FH) is repreated 128 times. 
Since 07FH is equivalent to 127 decimal, the worst case 
checksum would be: 

SUM = 128 * 127 = 16256 

This value falls between 2 A 15 and 2 A 16. Thus, a 16 bit 
checksum would insure a unique sum for each unique data 
block. I am using the term “unique” rather loosely here. 
Two data blocks consisting of the same characters but in 
different order are not considered unique, by this definition. 


At least one popular “serial I/O” card employs a UART 
whose output is fixed at 7 data bits. The Cromemco TU-ART 
employs the Texas Instruments TMS5501 device to support 
serial I/O. The serial output of this device is fixed at 7 data 
bits with a parity bit of zero. Thus, while it would be most 
efficient to transfer the 16 bit checksum as two eight-bit 
characters, this approach would exclude systems employing 
the TU-ART card to drive an acoustic coupler. For this 
reason, an ASCII HEX encoding of the checksum was em¬ 
ployed. This results in the 16 bit value being broken into 
for “nibbles” of 4 bits each. The ASCII representation of 
each nibble ranges from ASCII 0 through 9 and ASCII A 
through F. There remains the question of ordering the output 
value; i.e., what sequence should be used in transferring the 
nibbles. I somewhat arbitrarily chose the most significant 
nibble first and least significant nibble last. 

We now nave a protocol where each data block, including 
the header block, has a checksum associated with it. As each 
character is transferred, both the TX and RX systems accumu¬ 
late individual checksums. The TX system transfers its final 
value to the RX, who tests it for equality with its own value. 
If the values agree, an @ACK is returned, otherwise a @NAK 
is returned and the data block is retransmitted. How many 
times should reTX be allowed to occur on the same data 
block before cancelling (@CAN) the transfer? I have somewhat 
arbitrarily chosen the value of 5. Remember, it takes quite a 
bit of time to repeat a data block 5 times. Five repeats plus 
the original at 300 BAUD requires approximately: 

retry time = 6 * (128 + 4) /30 Sec. = 26.4 Sec. 

Also remember we are not dealing with “crud” on a disk 
(which uses 10 retries) but with noise on the line. If the line 
noise, or perhaps some system problem, causes a reTX in ex¬ 
cess of 5 times on the same data block, brother, you have a 
problem! Note further that many more than 5 reTXs are 
allowed provided no more than 5 occur on a given data block. 

While we seem to have solved the data integrity question on 
a data block basis, we still need some way of assuring ourselves 
that each and every block was received properly and that 
some reTXed block didn’t get recorded twice by mistake. One 
approach is to include a block or frame count as part of the 
block transfer. Since the files transferred might be quite 
large, a 16 bit block count might be needed. Given the 7 data 
bit limit mentioned above, this would require an additional 
4 characters per block. I chose a different approach which 
does not add to the size of the data block. I have found that 
if a cummulative total of reTXs is kept by both TX and RX 
systems, then the equality of these values virtually assures 
the transfer was error free. Thus, the TX system sends his retry 
count to RX system as a part of the End of TeXt (@ETX) 
record. This record immediately follows the last <data.blk> 
record. If the counts agree, the RX system sends @ACK. 
Else, a @NAK is sent. Both systems then display on their 
respective consoles that the transfer was either successful 
or unsuccessful along with the total number of reTXs. 

We now have a protocol that looks something like the 
following: 

—> @SOH FILENAMETYP SUM 

<— @ACK 

—> AAAAAAAAAAAAAAAA SUM 

<— @ACK 

—> BBBBBBBBBBBBBBBB SUM 

—> JJJJJJJJJJJJJJJJ SUM 


Number 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

235 



<— @NAK 
—> JJJJJJJJJJJJJJJJ 
<— @ACK 

—> KKKKKKKKKKKKKKKK 
<— @ACK 


(Retransmission Request) 

SUM 

SUM 


—> ZZZZZZZZZZZZZZZZ SUM 

<— @ACK 
—> @ETX CNT 
<— @ACK 

The “SUM” associated with each data block represents the 
four ASCII HEX characters associated with the checksum. The 
“CNT” at the end represents a single character value inter¬ 
preted as a binary retransmission count value. Thus, it repre¬ 
sents the count modulo 128 since the number of data bits in 
the protocol is set to 7 data bits. 

Variable Block Size and Data Parity Check 

The above protocol is about as far as we can go if limited to 
7 data bits and no parity. However, since most UARTS/ 
USARTS provide for both software control of the number of 
data bits (5 thru 8) and additional control over parity selection 
(even or odd) coupled with parity enable/disable, valuable 
additions can be made to the protocol. 

Let’s first consider variable block size. If we limit the block 
size to one sector (128 characters) then we must access and 
write the disk every 4 seconds (approx.) at 300 BAUD. The 
read/write head on most drives unloads within this interval. 
Thus, the head is being loaded each time a write operation is 
performed. This takes on the order of 36 Msec or about one 
character time at 300 BAUD (33.3 Msec per character). In 
addition, the proper sector must be found — assuming the 
head is already positioned at the appropriate track. Since it 
takes 166.6 Msec for one rotation of the disk, the average 
“latency” is one half that value; i.e., 83.3 Msec. Thus, each 
time we write the disk costs us, on average, 


retransmission request due to parity error, two additions to 
our protocol are needed. First, we must add a resync (@SYN) 
request to our <ack. form>. In response to the receipt of s.n 
@SYN from the RX device, the TX device will discontinue 
the block transfer and begin a retransmission of the same 
block. Second, to assure proper synchronization, each data 
block should begin with a Separator (@RS) for this task. 
Thus, if the RX device detects an @RS following his trans¬ 
mission of an @SYN, he knows the block retransmission 
request has been received by the TX device and that this is 
the beginning of that block. 

Finally, it is desirable to be able to identify a block with 
more or less characters than specified by the block count. 
This can be done by inserting a special character between the 
end of data and the beginning of the checksum. I have se¬ 
lected the ASCII Unit Separator (@US) for this task. If there 
is such a disagreement, a @SYN is immediately sent by the 
RX to the TX, causing a retransmission. This completes the 
protocol specification and leaves us with a typical data block 
that looks something like, 

—> @RS N XXXXXXXXXXXXXXXXXXXXX @USSUM 

<— @ACK 

where N denotes the block count and, as before, SUM denotes 
the checksum. 

I have given this protocol the name “MCALL-C”, which 
stands for Micro proto “CALL”-Clear. The clear means that 
the data is not encoded, as is the case for the PCNET proto¬ 
col. In PCNET protocol, the data is encoded in a radix 41 
code rather than pure ASCII. This encoding allows binary 
information to be transferred while using only 41 “printable” 
characters to encode the data. 

The complete MCALL—C definition both in BACKUS- 
NAUR form and in a more graphic form (section (3) ) is 
shown in Table 1. The definition is from the point of view 
of the originator or (TX) system. 


write time = 83.3 + 35 Msec = 118.3 Msec. 

This is approximately 4 character times at 300 BAUD and 
16 character times at 1200 BAUD. The worst case time would 
be approximately 211.6 Msec or approximately 6 character 
times at 300BAUD (includes 10 Msec track stepping time). 
These times apply to the Stugart 800 drive. The times should 
be fairly representative of all floppy disk drives. 

Given the above statistics, it seems desirable to increase 
the block size and thereby reduce the number of times a disk 
write operation is performed. In arriving at an optimum block 
size (if one exists) we must consider the impact of increased 
block size on both buffer memory size and time lost in retrans¬ 
mitting a larger data block. I have no firm number in mind 
but since CP/M allocates disk space in 8 sector blocks, a value 
of 1024 = 8 * 128 seems a good starting point. This calls 
for a 16 bit block size value which can be sent as two 8 bit 
bytes interpreted as binary values rather than ASCII char¬ 
acters. To be consistent with the checksum ordering the most 
significant byte is transmitted first. 

The next protocol enhancement to be introduced provides 
for a parity error test. If a data parity error is found, there is 
no need to continue the block transfer. Instead, the block 
should be immediately retransmitted. This further facilitates 
the introduction of larger block sizes. To accommodate the 


<1> DATA TRANSMITTED (BXXX SIGNIFIES AN ASCII CONTROL CHAR) 

<FILE> <F.HDR> <F.TEX> 

<F.HDR> :■ BSOH <HEADER> (PUS <CHKSUM> 

<HEAOER> * <8 CHAR FILENAME> <3 CHAR FILETYPE> 

<CHKSUM> - <16 BIT CHECKSUM ENCODED IN ASCII HEX 
MS-NIB8LE FIRST, LS-NIBBLE LAST) 

<F. TEX> « <TEXT) (PETX <ERRTTL> 

<TEXT> - <BLOCK> I <BLOCK> <TEXT> 

<BLOCK> = (PRS <CHRCNT> <STRING> (PUS <CHKSUM> 

<CHRCNT> = <NUMBER (LESS ONE) OF CHARACTERS IN <STRING» 
<STRING> :■ <PRINTABLE ASCII CHAR STRING OF FILE DATA) 
<ERRTTL) * <TOTAL ERROR COUNT MOO 128) 

(2) DATA RECEIVED (HANOSHAKING PROTOCOL) 

<ACK. FORM) = <BACK) I «PNAK) I <(PSVN) I «PCAN> 

<(PACK> = (PACK (SUCESSFUL TRANSFER OF DATA) 

«?NAK) = BNAK (RETRANSMISSION REQUEST) 

<(?SYN) - (PSYN (RESVNC REQUEST) 

<(?CAN) = BCAN (ABORT TRANSMISSION) 

<HDR.ACK): = <F.HDR) <ACK.FORM) 

<BLK.ACK) = <BLOCK) <ACK.FORM) 

CEOF.ACK) - (PETX <ERRTTL> <ACK. FORM) (FILE CLOSED ACK) 

(3) SAMPLE FILE TRANSMISSION 

—> BSOH FILENAMETYP (PUS SUM 

<— BACK 

—> (PRS N AAAAA. . . AAAAA (PUS SUM 

<— (PACK 

—> (PRS N BBBB8. . . BBBBB BUS SUM 

<— BACK 


—> 

(PRS N VVVVV. . 

.VVVVV 

BUS 

SUM 


<— 

BNAK 




(RETRANSMISSION REQ) 

—> 

(PRS N VVVVV. . 

. VWW 

BUS 

SUM 


<-- 

(PACK 





--) 

(PRS N YYYYY. . 

.YYYYY 

BUS 

SUM 


<— 

(PACK 





—) 

(PRS N ZZZ2Z. . 

.ZZZZZ 

BUS 

SUM 


<— 

(PACK 





—> 

(PETX M 




(END OF FILE) 

<— 

(PACK 






(HEADER BLOCK) 
(FIRST DATA BLOCK) 
(SECOND DATA BLOCK) 


Page 18 

236 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 










Having specified the protocol, we must now resolve the 
problem presented by the existance of UARTS whose number 
of data bits is limited to seven and whose operation does not 
support parity generation and testing. The best approach 
might be to have two similar but different protocols. One to 
accommodate the TMS5501 and another to take advantage 
of the 8 data bits plus parity. Let’s call the 7 bit version 
MCALL-C and the 8 bit version, MCALL-BC. The “B” 
related to the Big data block size. The two protocols are 
identical except in the way the block size and the checksum 
are represented and the use of parity testing in one but not 
the other. By limiting the differences to these three para¬ 
meters, both protocols can be accommodated by the same 
program. A “flag” could be set in response to operator input 
to specify which processing path was selected. 

For MCALL-C we define the block size and the checksum 
as follows: 

<CHARCNT> : : = <NUMBER (LESS ONE) OF CHARACTERS 
IN <STRING>IN THE RANGE 0 TO 127> 

<CHKSUM> : : = <16 BIT CHECKSUM ENCODED IN ASCII 
HEX WITH MS-NIBBLE FIRST> 

For MCALL-BC we define these two parameters as follows: 

<CHARCNT> : : = OJUMBER (LESS ONE) OF CHARACTERS 
IN <STRING> IN THE RANGE 0 TO 
65535 with MS-BYTE FIRST> 

<tHKSUM> : : = <16 BIT CHECKSUM WITH MS-BYTE 
FIRST> 

As to the effectiveness of the protocol, I have implemented 
the MCALL-C protocol as part of a program I have written 
called “MCALL”. The program fixes the UART data format 
at 7 data bits with even parity, although no parity test is 
currently performed. This protocol has been tested on a 
vaiety of I/O cars for the S-100 BUS and includes the Cro- 
memco TU-ART. I find the protocol very effective in file 
transfers and have never had an unsuccessful transfer under 
normal circumstances. By normal I mean under both good and 
foul weather conditions with total reTX counts ranging 
up to 10 or more per message. I generally get error-free 
performance even when I tap on the telephone handset with a 
pencil to introduce noise. Occasionally, however, using the 
“bang approach” I have caused the system to “bomb” or 
record the same block twice. However, the operator is alerted 
to the latter case via an “unsuccessful file transfer” message 
at the end. This is where the comparison of reTX counts 
pays off. 

The current version of MCALL (VI.6) supports only 
MCALL-C. I hope to add MCALL-BC in the future, along 
with other protocols and program enhancements. Further 
information relating to MCALL can be obtained by con¬ 
tacting the author whose address is given at the beginning of 
tliis article. 


UPDATE NOTICE 

February 22,1980 

The following changes to MCALL VI.5 will remove a po¬ 
tential problem which exists when sending a file to a remote 
TSC at 300 BAUD. When a TSC becomes “loaded” and its 


response time deteriorates, it is possible to lose some of the 
file data being sent. It is usually the case that, while a TSC 
may not be capable of receiving continuous data at 300 BAUD, 
it is capable of handling this rate for the duration of a single 
line. The proposed change to the file TX routine causes the 
transfer to pause at the end of each line and await acknow¬ 
ledgement in the form of a line-feed. Further, the remote 
device is allowed to follow this @LF with additional characters 
(e.g., a prompt character) before transmission of the next 
line commences. 

The proposed change results in a new version number, 
MCALL VI.6. The following directions should be followed in 
order to implement the change: 

1. Change the second line of the source file to reflect the new 
version number, VI.6. Search for the unique string “MSG1:” 
and change the second line of that message to reflect the 
new version number. 

2. Either perform a negative search or revert to the start of 
the source file and search for the unique string “KONSW:”. 
On the next line, insert the following storage declaration: 

IDLCNT: DS 2 ;IDLE LINE COUNTER 

3. Search for the unique string “TF3:” and then advance 5 
lines. At that point, replace the statement “CALL SHOW” 
with the following: 

MOV C, A 

BIOSS CONOUT ;CRT <- CHAR 

This will cause the CRT to display only the printable 
characters during a TX file operation, rather than converting 
non-printing control characters to their printing equivalent. 
While this change has nothing to do with the stated problem, 
it seems a desirable change. 

4. Search for the unique string “TFEOL:” and advance 6 
lines. Kill this and the next 5 lines; i.e., the LDA, ORA, JNZ, 
MVI, CALL, and JMP instructions. Now, advance to the end 
of the subroutine and kill the last instruction; i.e., the “JMP 
TXBYTE” instruction. In place of this last instruction, the 
following instructions should be appended to the subroutine: 







AN I 

07FH 



CPI 

OLF 



JNZ 

TF4 

;LINE ACKNOWLEDGED 7 

TF4B 

LX I 

H, 8 

i YES 


SHLD 

IDLCNT 

,IOLCNT <- 0 

,--WAIT FOR 

LINE TO GO 

IDLE 

TF5. 

LHLD 

IDLCNT 



I NX 

H 



SHLD 

IDLCNT 

;♦+IDLCNT 


MOV 

A/ H 



AN I 

03H 

> TEST ONLY 10 LS8S OF COUNT 


ORA 

L 



JZ 

TXBYTE 

iIS LINE IDLE? 


CALL 

MSTAT 

j MAYBE NOT 


AN 1 ' 

RDA 



JZ 

TF5A 

i RX DATA AVAILABLE? 


IN 

RXDATA 

J YES 


AN I 

07FH 



MOV 

C, A 



BIOS* 

CONOUT 

>CRT <- CHAR 


LDA 

•CHCNT 



I NR 

A 



STA 

CHCNT 

.++CHCNT 


JMP 

TF4B 

; RESET IDLE COUNT AND WAIT AGAIN 

TF5A 

BIOS* 

CONSTS 



JZ 

TF5 

,CONSOLE DATA AVAILABLE 


JMP 

TFEND 

J YES, TERMINATE FILE TX 


Number 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 

237 



That’s it. Sorry this change was not included in the VI.5 
update but an earlier attempt to resolve this problem in 
assembly language failed. It was not until I recently re-coded 
the program in the language “C” that I was able to resolve 
it. It’s fairly trivial, once you see the solution. Oh well, that’s 
the way it goes. 

For those of you who want the update but would prefer 
to receive it on disk, I will apply the same “deal” as before. 
Return the old disk and receive an update for $5. Otherwise, 
send $10. and I will ship you the update on a new disk. 
As far as I know, this is the last of the significant changes 
that the program requires. However, I will keep you informed 
of any “bells & whistles” that may be added in the future. 

UPDATE NOTICE 

April 8,1980 

This update is principally aimed at the “ESC F” function. 
This update will change the version number from VI.6 to 
VI.7. In VI.6, the filename and filetype were specified on 
separate lines and lower case characters were not converted to 
upper case, as required by CP/M (sorry ‘bout that). Also, it 
was not possible to specify a file as residing on other than the 
“logged in” disk. This update corrects these problems. 

The first thing that must be changed is the version number 
appearing on the first “page” of the source. It also appears 
following the unique string “MSG1:”. Next, search for the 
unique string “MSG20:” and replace this message with the 
following message: 

MSG20: DB CR, LF, ’ENTER <FILENAME> .<TYP>-DISK 
SPEC (e.g. B:) ’ 

DB ’OPTIONAL’, CR, LF, LF, ’$’ 


. —KKUUfcS>S> <-r 1 Lfc-WintI rrc/ 

PRINT* MSG20, * - REQUEST <FILENAME> & <FILETYPE> FROM OPERATOR 
MVI C,ROCBUF 

LX I 0, C BUFF 

CALL FDOS ; GET <IFILENAME>. <TYP> 

;—PROCESS OPTIMAL DISK SPECIFICATION 



LOA 

CBTXT+1 



CPI 

» : * 



JN2 

FILES 

> OISK SPECIFIED? 


LDA 

CBTXT 

; YES 


AN I 

3 



STA 

FCBON 

; FCBON <- DISK_SELECT 


LDA 

CBCNT 



OCR 

A 



OCR 

A 

;CBCNT = CBCNT - 2 


LX I 

H,CBTXT+2 


JMP 

FILE4 


, —MOVE 

<FILENAME> * <TVPE> TO FCB 

FILE3 

LOA 

CBCNT 

;A.REG <- CHAR CNT 


LX I 

H.CBTXT 

, H, L.REG <- SOURCE ADDR 

FILE4: 

LX I 

D, FCBFN 

;D- E.REG <- DEST_ADOR 


CPI 

13 



JC 

FILES 

, CHAR CNT > 12? 


MV I 

A, 12 

; YES 

FILES 

CALL 

MOVCAPS 

;FCB O FILE NAME, TVP 


CALL 

CRLF 



RET 



; *♦ ******************************************************************* 

, « 

MOVCAPS 

— Move 

a block of characters from source to destinatio 

l 


and 

convert to upper case <CAPS). Also, screen 

* 


out 

*. * if found. 


/ 

A.REG = count 

i 


H, L. 

*EG = source_address 

> 


D. E. 

REG = dest_address 

; —— ******************************************************************* 

MOVCAPS 

MOV 

B, A 



ORA 

A 


MOVC1 

R2 


>MOVE COMPLETED? 


MOV 

A, M 

; NO, GET A CHAR 


CPI 

• 



JN2 

MOVC 2 

, CHAR = ». »? 


I NX 

H 

i YES 


LX I 

0. FCBFT 

,0, E.REG <- FCBFT 


DCR 

B 



JMP 

MOVC 1 

GET THE NEXT ONE 

MOVC 2 

CPI 

061H 



JC 

M0VC3 

,LOWER CASE CHAR? 


AN I 

0SFH 

, YES, CONVERT TO UPPER CASE 

M0VC3: 

STAX 

0 

.MOVE TO DESTINATION 


I NX 

H 



I NX 

0 



OCR 

B 



JMP 

MOVC 1 



Enclosed is a two page listing of the new subroutines 
required to implement the change. These two routines replace 
the single previous routine named “FILE.” Thus, it will be 
necessary to search for the unique string “FILE:” and replace 
the existing routine with the two attached routines. Note that 
the old and new FILE routines are identical through the three 
lines following the line labeled “FILE2: ”. 

One last minor change fills the final sector of a “recorded” 
disk file with 01 AH. This assures that no “garbage” is present 
in the last record of a recorded file. Only one line of code 
need be changed. To do so, search for the unique string 
“BB2D3:”. Advance to the next line and change the symbolic 
jump address from “BB2D5” to “BB2D4”. That’s it. Simply 
change the ’5’ to a ’4’ and reassemble. Enjoy! 


; * + ********************* ****** ********************** *** *************** 


> * * FILE — File Control Block setup 

i Provide for operator selection of a new file by 

i prompting him for his selecti-on and then set up 

; the associated F.C.B. 

i 

;— ******************************************************************* 


FILE: 

MV I 

B, 33 



MV I 

A, 0 



LX I 

H, FCB 


; — 2ER0 

FILL 

THE ENTIRE 

FCB 

FI LEI 

MOV 

M, A 



I NX 

H 



DCR 

B 



JN2 

FI LEI 

; FCB 2ER0ED? 

.—BLANK FILL 

<FILENAME> 

& <FILETVPE> 


MV I 

B, 11 

; YES 


MV I 

A, • * 



LX I 

H, FCBFN 


FILE2 

MOV 

M, A 



I NX 

H 



DCR 

B 



JN2 

FILE2 

. BLANK FILL COMPLETE? 



Page 20 

238 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 





THE ELECTRIC PHONE 


A Directory of 144 Computerized 
Bulletin Board Systems 


BOOK 



A computerized bulletin board works 
just like an ordinary bulletin board 
system except that instead of paper and 
thumbtacks it uses a terminal, a computer, 
and the dial-up telephone network. 
It’s a place to leave messages for every¬ 
one or for some particular person who, 
you know, browses the bulletin board 
occasionally. 

The list below was developed from 
several sources including the Peripheral 
People in Mercer Island, Washington 
and the People’s Message System in San¬ 
tee, California. It is being maintained 
by PCC’s PCNET project, our effort to 


bring computers and telecommunications 
into the hands of everyone. While this is 
the most complete listing we have as of 
this writing, we would appreciate addi¬ 
tions and corrections. Send them to 
PCNET, PCC, P.O. Box E, Menlo Park, 
CA 94025 or leave them on the PCNET/ 
PCC Bulletin Board System for Dave 
Caulkins, (415) 948-1474. 

All the bulletin board systems listed 
here can be accessed by telephone using 
a 300-baud ASCII terminal and a Bell 
103 modem. Most use carriage-return as 
a speed recognition character, after which 
they are self-teaching. All are free to 


anyone who calls, unlike the Arpanet, 
which is restricted, and The Source and 
MicroNet which cost money. The list 
has been sorted by area code; consult 
your local telephone directory for geo¬ 
graphical correspondence. 

We are compiling a mailing list of people 
interested in computers and telecom¬ 
munication. If you would like to be 
on it, send us a note at the address 
above. If you are interested in PAN, 
PCNET’s computer mail system for the 
PET, send us a stamped, self-addressed 
envelope and we’ll send you back 
information. 


1 

(201 ) 

457-0893 

( 213 ) 

795-3788 

( 314 ) 

838-7784 

( 604 ) 

687-2640 

( 714 ) 

— 

730-1206 

m 

jal 

( 201 ) 

835-7228 

( 213 ) 

799-1632 

( 316 ) 

746-2078 

( 607 ) 

754-5571 

( 714 ) 

739-0711 

'Jffaro, 

(201 ) 

874-6833 

( 213 ) 

799-6514 

( 319 ) 

353-6528 

( 609 ) 

983-5970 

( 714 ) 

751-1422 

§m 


<201 ) 

891-7441 

( 213 ) 

826-0325 

( 319 ) 

557-9618 

( 612 ) 

929-8966 

( 714 ) 

772-8868 

pfj 


( 201 ) 

968-1074 

( 213 ) 

828-3400 

( 404 ) 

394-4220 

( 614 ) 

272-2759 

( 714 ) 

898-1984 



( 202 ) 

337-4694 

( 213 ) 

843-5390 

( 404 ) 

733-3461 

( 614 ) 

649-7097 

( 714 ) 

962-7979 

\m 

ijp 

( 205 ) 

945-1489 

( 214 ) 

288-4859 

( 404 ) 

790-8614 

( 615 ) 

254-9193 

( 801 ) 

753-6800 

{SB 

( 206 ) 

244-5438 

( 214 ) 

634-2668 

( 404 ) 

939-1520 

( 617 ) 

354-4682 

( 803 ) 

270-5372 

}(m\ 


( 206 ) 

482-5134 

( 214 ) 

634-2775 

( 404 ) 

939-8429 

( 617 ) 

431-1699 

( 803 ) 

270-5392 

P 


( 206 ) 

524-0203 

( 214 ) 

641-8759 

( 404 ) 

953-0723 

( 617 ) 

649-7097 

( 803 ) 

279-5392 



( 206 ) 

723-3282 

( 216 ) 

745-7855 

( 405 ) 

528-8009 

( 617 ) 

864-3819 

( 803 ) 

771-0922 

yl 

n 

( 206 ) 

937-0444 

( 305 ) 

566-0805 

( 408 ) 

241-1956 

( 617 ) 

897-0346 

( 805 ) 

484-9904 

w 

( 209 ) 

638-6392 

( 305 ) 

689-3234 

( 408 ) 

263-0248 

( 617 ) 

963-8310 

( 813 ) 

223-7688 


n 

( 212 ) 

448-6576 

( 305 ) 

772-4444 

( 415 ) 

348-2139 

( 702 ) 

873-9491 

( 816 ) 

861-7040 

( 213 ) 

276-4276 

( 305 ) 

821-7401 

( 415 ) 

348-2396 

( 703 ) 

281-2125 

( 816 ) 

931-3135 


( 213 ) 

316-5706 

( 305 ) 

989-9647 

( 415 ) 

493-7691 

( 703 ) 

734-1387 

( 817 ) 

855-3916 

ps 

Pficii 

( 213 ) 

329-3715 

( 312 ) 

255-6489 

( 415 ) 

661-0705 

( 703 ) 

750-0930 

( 817 ) 

855-3918 

HP 


( 213 ) 

340-0135 

( 312 ) 

269-8083 

( 415 ) 

792-8406 

( 703 ) 

893-9474 

( 817 ) 

923-0009 

M 


( 213 ) 

349-5728 

( 312 ) 

337-6631 

( 415 ) 

948-1474 

( 703 ) 

978-7561 

( 901 ) 

276-8196 

m 

( 213 ) 

360-6332 

( 312 ) 

420-7995 

( 417 ) 

862-7852 

( 713 ) 

693-8080 

( 901 ) 

362-2222 



( 213 ) 

394-1505 

( 312 ) 

528-7141 

( 451 ) 

948-1474 

( 713 ) 

977-7019 

( 901 ) 

761-4743 

wk 

18 

( 213 ) 

395-1592 

( 312 ) 

622-9609 

( 502 ) 

245-8288 

( 714 ) 

449-5689 

( 904 ) 

243-1257 

ill 


( 213 ) 

396-3905 

( 312 ) 

767-0202 

( 503 ) 

646-5510 

( 714 ) 

463-0461 

( 904 ) 

243-8565 


wj/m 

( 213 ) 

424-3506 

( 312 ) 

964-7768 

( 512 ) 

657-0779 

( 714 ) 

526-3687 

( 913 ) 

764-1520 



( 213 ) 

428-4718 

( 313 ) 

288-0335 

( 513 ) 

874-2283 

( 714 ) 

537-7913 

( 913 ) 

782-5115 

fm 


( 213 ) 

( 213 ) 

459-3177 

566-8035 

( 313 ) 

( 313 ) 

465-9531 

477-4471 

( 516 ) 

( 602 ) 

938-9043 

866-0258 

( 714 ) 

( 714 ) 

565-0961 

571-5550 

( 915 ) 

584-5393 

ft 


jgfe 



|j|j| 

( 213 ) 

657-8803 

( 313 ) 

484-0732 

( 602 ) 

886-0258 

( 714 ) 

582-9557 


111 

( 213 ) 

675-8803 

( 313 ) 

569-2063 

( 602 ) 

955-1436 

( 714 ) 

582-9957 



Mil 

(jp| 

( 213 ) 

787-4004 



( 602 ) 

957-4428 





ml 

fm 










__ 

m 


Page 21 

239 


Number 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 















ON modems 


BY WILLIAM SMITH 

2325 >2 Howe Street 
Berkeley, CA 94705 
Micronet ID: 70110,243 
Source No: TCD650 

Like all new areas that emerge in this 
world of microcomputers, the area of 
phone line connection is fraught with 
unclear terminology and generalities. I 
spent much energy sorting things out 
in order to set myself up ‘on line’ and 
would like to share some of what 
I have learned with you. To begin, some 
terms must be defined: 

MODEM a general term that can refer 
to any of several different aspects of the 
physical device which couples a computer 
to the phone lines. 

ACOUSTIC COUPLER a specific type 
of modem that makes an acoustic connec¬ 
tion between the computer and the 
phone lines by setting the phone hand¬ 
set into a cradle which is connected to 
the computer. 

DIRECT COUPLER another specific 
type of modem that makes a direct 
connection between the computer and 
the phone lines; everything stays in the 
form of electric signals; there are no 
intermediary acoustic stages. 
MODULATOR/DEMODULATOR the 
circuitry responsible for encoding and 
decoding information represented by 
logic states (i.e., high and low) to and 
from information represented by vibra¬ 
tion rates (i.e., high frequency and low 
frequency). 

FREQUENCY SHIFT KEYED (FSK) 

jargon for the frequency coding tech¬ 
nique typically used in modems (and 
many cassette interfaces); a sine wave is 
the carrier of the binary information and 
the data is stored by shifting the fre¬ 
quency to one value for a high and to 
another value for a low. 

BANDWIDTH a continuous region or 
band of frequencies defined by the differ¬ 
ence between two specific frequencies 
which denote its upper and lower limit, 
e.g., the bandwidth of FM radio is ap¬ 
proximately 20 Mhz, from 88 Mhz to 
108Mhz. 


A data communcations link-up is a 
two way connection. Both parties can 
send and receive information. This is 
facilitated by dividing the phone line’s 
available bandwidth into two separate 
bands or channels. Each one of these 
corresponds to one of the two different 
directions in which data is being sent. 
There is a 450 hz band in the IK region 
and another 450 hz band in the 2K 
region. Within each of these 450 hz 
regions we need to distinguish to separ¬ 
ate frequencies, corresponding to the 
two logic states that must be represented. 
The logic states are coded in FSK mode. 
Thus each state requires only a few 
hertz bandwidth. The separation between 
the logic one frequency and the logic 
zero frequency in both the upper and 
lower regions is 200 hz. Refer to the 
table for a graphic representation of all 
this information. The exact figures for 
the upper and lower bands representing 
the two communication directions may 
vary between manufacturers according to 
filter design but the four logic levels are 
precisely defined industry standards. 
This is necessary if machine independent 
communication is going to take place. 

If one of the two communication chan¬ 
nels, say the upper one, were reserved 
for the send direction of communication, 
and the other were reserved for the re¬ 
ceive direction, then consider the pro¬ 
blems that would ensue. Both parties 
would be sending their messages on 
the send channel and expecting to hear 
from the other on the receive channel 
where there would be silence! Clearly 
there has to be a more definitive agree¬ 
ment about who is the sender and who is 
the receiver. 


The solution lies in defining a new 
term: Mode. When two parties are in 
communication, the one that placed the 
call is considered to be in Originate Mode 
and the other is in Receive Mode. In 
Originate Mode the upper communication 
region is your receive band and the lower 
region is your transmit band. In Answer 
Mode the two are reversed. Thus if A 
calls B then A is in Originate Mode and 
will transmit on the lower region, while 
B will be in Answer Mode and therefore 
receiving A’s transmission on the lower 
band. On the upper band B will be trans¬ 
mitting and A will be receiving. 

The major difference between an acous¬ 
tic coupler and a direct coupler computer 
phone link up is the element of personal 
presence. In the acoustic coupled situa¬ 
tion someone must be there to physically 
dial the phone and set the handset on the 
coupler; or, in the Answer Mode, wait 
till the phone rings and then make the 
physical connection. With the direct 
coupler the computer remains plugged 
directly into the phone lines and, via a 
combination of software and hardware, 
is responsible for all functions including 
answering a ringing phone, dialing num¬ 
bers, dealing with broken connections, 
checking for data errors and just about 
as many other technical details that the 
programmer wants to get involved in. 

The direct coupled situation also 
tends to suffer less from loss of data 
problems due to the fact that it does 
not have any intermediary acoustic 
stages. Furthermore, with a direct 
coupled arrangement, a microcomputer 
owner is able to access his/her machine 
from any remote location; e.g., your 
computer is at the office and you have a 



Page 22 

240 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 




relatively inexpensive terminal at home 
giving you the full power of your com¬ 
puter at home. Acoustic couplers cost 
about $150 while the direct couplers 
seem to hover around the $400 mark. 

In the final analysis, I chose the direct 
coupled equipment because I have a 
vision of starting a small local network 
for sharing resources and ideas in the 
Berkeley, California area. I feel that it 
is the responsibility of the people who 
own computers now to break into the 
new territory of Networks and thus pre¬ 
vent the concept from becoming solely 
connected with major nationwide com¬ 
panies. Local computer networks could 
revolutionize just about every aspect 
of our lives, giving people in communi¬ 
ties a true and present sense of being in 
touch with one another. 

Any persons mterested in pursuing 
this topic should get in touch either by 
phone, mail or Micronet Bulletin Board. 
•••••••••••••••••••••••••A* 



Let me leave you with a final question, 

! readers; if anyone knows the answer, 
please get in touch with me: How can 
data be traveling in two directions at the 
same time on one line, and how does the 
phone company send our voices two 
ways at the same time without having 
separate bands, since our voices use 
| up the whole band? — WS 

(•••••••••••••••••••••••••a* 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

241 




ADDING ARRAYS TO FORTH 


BY RALPH DEANE 

Box 27 

Little Fort, B.C., Canada VOE 2C0 


In some versions of FORTH (notably FIGFORTH) there 
are no functions which can be used to define multidimen- 
sioned arrays. Other versions (those based on the Caltech 
manual) provide only a primitive array defining function. The 
power of FORTH is such, however, that these array-defining 
functions can be added with relative ease. This extendability 
of the compiler to add new classes of functions (in this case 
arrays) is shared by few other languages and is one of the 
strengths of FORTH. Functions to define one, two, three, and 
four dimensioned arrays will be presented here. Careful study 
of the program will show the underlying principles, which can 
also be applied to arrays with five or more dimensions. 

In FORTH there are two different methods of defining 
functions whose purpose will be to define arrays. One way 
is to use ;CODE while the other is to use (BUILDS DOES). 
;CODE produces the fastest runtime speed when generating 
addresses of array elements but is also processor-dependent 
due to its use of assembler language. While (BUILDS DOES) 
may be slower than ;CODE, all parts of the definition are in 
high level FORTH, which makes it processor-independent 
and allows the functions produced to be transportable. This is 
the main reason that (BUILD DOES) will be used in the 
function definitions. All true implementations of FORTH 
should have these functions available. If your version does not, 
find out why from the distributor. Programma International’s 
FORTH does not have these functions and is, in any case, 
not a true implementation of FORTH, as defined by the 
FORTH interest group. 

The defining functions are organized such that the func¬ 
tions they produce will return the absolute address of the 
desired array element. The indices of the element must be 
placed on the stack before executing the function. All indices 
have a lower value of 1. No error checking is provided to test 
for indices out of bounds. 

In order to understand how the defining functions work, 
a knowledge of how (BUILDS DOES) works is required. 
An explanation of this is beyond the scope of this article and 
should be covered in your FORTH manual. Each of the four 
defining functions works in the same way. 

The defining function can be broken down into two parts, 
compile time and runtime. The compile time portion is execu¬ 
ted when an array is created. It consists of the code from 
(BUILDS to DOES). It gets the size of each dimension, stores 
them in the dictionary and then reserves the required words 
for the array storage area. Figure 1 shows the order in which 
the dimension sizes are stored for each array type. The amount 
of space reserved is equal to the product of all the dimension 
sizes. 


Dimension 1 is X 
Dimension 2 is Y 
Dimension 3 is Z 
Dimension 4 is W 

1 Dimension Arrays 

first parameter field - X 

2 Dimension Arrays 

first parameter field — 
second X 

3 Dimension Arrays 

first parameter field - 
second 
third 

4 Dimension Arrays 

first parameter field — 
second 
third 
fourth 

Figure 1 . 


The runtime is executed whenever the address of an array 
element is required. It expects the address of the first para¬ 
meter field to be on the top of the stack, with the indices 
underneath it. The index of the highest dimension is closest 
to the top. The formulas used to compute the element addres¬ 
ses are outlined in Figure 2. 


FPF is the address of the first parameter field. X, Y, 

Z, W are the dimensions of the array. I, J, K, Lare the 
indices of the element. 

1 Dimension Arrays 

I * 2 + FPF 

2 Dimension Arrays 

((((I—1)*Y) + J + 1)*2) + FPF 

3 Dimension Arrays 

(((( I - 1) * Y) +J + 1) * 2) + (X * Y * (K - 1)) +2 + FPF 

4 Dimension Arrays 

((((I - 1) * Y) + J + 1) * 2) + (X * Y *Z * (L— I)) + 4 + FPF 
Figure 2. 



Number 46 

242 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 













EXAMPLES 

1 Dimensioned Arrays 

50 1ARRAY PUT - define an array of length 50 called PUT 
to get the address of’PUT [ 11 ] execute 11 PUT 

2 Dimensioned Arrays 



ROM BYTE - FINDER FOR 
THE APPLE II 


BY STEPHEN E. BACH 

Route 2, Box 50A-1 
Scottsville, VA 24590 


5 7 2ARRAY NAME — define a 5 X 7 array called NAME 
to get the address of NAME [3,4] execute 3 4 NAME 

3 Dimensioned Arrays 

5 6 7 3ARRAY DIM — define a 5 X 6 X 7 array called 
DIM to get the address of DIM [1,5,2] execute 15 2 DIM 

4 Dimensioned Arrays 

2 3 4 5 4ARRAY NAX - define a 2X3X4X5 array 

called NAX 

to get the address of NAX[ 1, 3, 2, 4] execute 1 3 2 4 NAX 

The version of FORTH used to develop these functions is 
called 6502 FORTH. There are a few differences in function 
names between it and FIGFORTH. These are: 

6502 FORTH FIGFORTH 

I 

SAVE >R 

UNSAVE R> 

For more information on 6502 FORTH for the KIM-1 
and the Sym contact Eric Rehnke, #61 — 540 Ranch view 
Circle, Anaheim Hills, CA 92807. 


0 < SCR #01 ) 

1 i 1 ARRAY <BUILDS DUP # 0 DO 0 * LOOP DOES> 

2 < RUNTIME ROUTINE ) SWAP 2 * ♦ I 

3 i MAT ROT 1 - SWAP DUP • ROT * ROT ♦ 1 ♦ 2 • ♦ l 

A * 2ARRAY <BUILDS OVER OVER ' ' • 0 DO 0 ' LOOP DOES> 

5 < RUNTIME ROUTINE ) MAT t 

6 I 2MAT DUP DUP t SAVE 2 ♦ • SAVE SAVE ROT ROT UN SAVE MAT 

7 SWAP 1 - UNSAVE * UNSAVE • 2 • ♦ 2 ♦ 1 

13 t 3ARRAY < BUILDS SAVE OVER OVER # # UN SAVE DUP # * * 

M DO 0 ' LOOP DOES> 

10 ( RUNTIME ROUTINE ) 2MAT I 

11 l 3MAT SWAP SAVE DUP SAVE 2MAT 2 ♦ INSAVE DUP t SWAP DUP 

12 2 ♦ • SWAP 4 ♦ • * * IN SAVE 1 - * 2 * ♦ t 

13 * 4ARRAY <BUILDS SAVE SAVE OVER OVER # # UN SAVE DUP ' 

14 UNSAVE DUP ' • * • 0 DO 0 ' LOOP DOES> 

115 ( RUNTIME ROUTINE ) 3MAT I 


In the Sept/Nov 1977 issue of KIM User Notes, Hal 
Gordon, long-time friend of DDJ, noted that the 6502 BIT 
instruction can be used to non-destructively test the accumu¬ 
lator for any possible bit combination. The BIT instruction 
performs a logical AND on the byte in the accumulator and 
a mask byte. The mask byte must be addressable because the 
BIT instruction has no immediate addressing mode. Hal then 
presented a table of addresses in the KIM’s ROM at which 
there were specified hex values in the range $00-FF; the 
KIM’s ROM contained 175 of them. 

The enclosed routine for the APPLE II will find such 
values in the Apple’s Integer Basic/Monitor ROM beginning 
at $E000. The Apple’s ROM contains all 256 values. The 
program stops after the screen has filled with addresses and 
their corresponding values to allow you to copy them if you, 
like the, do not have a printer. Pressing any key will start the 
program on its way again. 

Credit should also go to Lee Moyer, who helped. 



ROM BYTE-FINDER 
FOR 


APPLE 

11 





0800 

A9 

00 


LDA 

#00 

Initialize registers to zero: 

0802 

85 

00 


iSTA 

00 

Byte-to-be-found 

0804 

85 

01 


ST A 

01 

Addresses-prlnted counter 

0806 

85 

FE 


STA 

FE 

Low byte of ROM's beginning address 

0808 

A9 

£0 


LDA 

#E0 

high byte of ROM's beginning address 

080A 

85 

FF 


STA 

FF 


080C 

A0 

00 


LDY 

#00 


080E 

B1 

FE 


LDA 

IFE).Y 

Load byte from ROM 

0810 

C5 

00 


CMP 

00 

Is It the one we're looking for ? 

0812 

DO 

28 


BNE 

083C 

If not go to examine next byte 

0814 

20 

DA 

FD 

JSR 

FDD A 

Print byte found 

0817 

A9 

A0 


LDA 

#A0 

Print space 

0819 

20 

ED 

FD 

JSR 

FDED 


081C 

98 



TYA 


Move low order byte of ROM address 

081D 

AA 



TAX 


to X register for printing 

081E 

A5 

FF 


LDA 

FF 

Load hi order byte of ROM address 

0820 

20 

41 

F9 

JSR 

F941 

Print address of byte found 

0823 

20 

48 

F9 

JSR 

F948 

Print 3 spaces 

0826 

E6 

01 


INC 

01 

Bump addresses-prlnted counter 

0828 

A5 

01 


LDA 

01 

Test for full screen 

082A 

C9 

5C 


CMP 

#5C 

Full screen Is 92 addresses 

082C 

F0 

05 


BEQ 

0833 

If full go wait for key to be pressed 

082E 

E6 

00 


INC 

00 

Bump byte-to-be-found-reglster 

0830 

DO 

D6 


BNE 

0808 

If more bytes to find go do It 

0832 

60 



RTS 


That's all; return to monitor 

0833 

20 

35 

FD 

JSR 

FD35 

Go watch keyboard for key-down 

0836 

A9 

00 


LDA 

#00 

Reset addresses-prlnted counter 

0838 

85 

01 


STA 

01 

083A 

F0 

F2 


BEQ 

082E 

Go to resume search for next byte 

083C 

C8 



INY 


Bump Index to examine next ROM byte 

083D 

F0 

02 


BEQ 

0841 

If page boundary bump hi addr of ROM 

083F 

DO 

CD 


BNE 

080E 

Go to examine next ROM byte 

0841 

F.6 

FF 


INC 

FF 

Bump hi byte of ROM addr 

0843 

DO 

C9 


BNE 

080E 

Go to examine next ROM byte 


0800 

A9 

00 

85 

00 

85 

01 

85 

FE 

A9 

E0 

85 

FF 

A0 

00 

B1 

PE 

0810 

C5 

00 

DO 

28 

20 

DA 

FD A9 

A0 

20 

ED 

FD 98 

AA 

A5 

FF 

0820 

20 

41 

F9 

20 

48 

F9 

E6 

01 

A5 

01 

C9 

5C 

F0 

05 

E6 

00 

0830 

DO 

W 

60 

20 

35 

FD 

A9 

00 

85 

01 

F0 

F2 

C8 

F0 

02 

DO 

0840 

CD 

E6 

FF 

DO 

C9 













Checksum = 42 704 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

243 






BY DONALD E. KNUTH 

Computer Science Department 
Stanford University 
Stanford, California 94305 

Herewith a portion of Donald Knuth’s collected errata for 
The Art of Computer Programming. Future issues of DDJ 
will contain more collected errata. — SR 


This report lists all corrections and changes of Volumes 1 
and 3 of The Art of Computer Programming , as of January 5, 
1979. This updates the previous list in report CS551, May 
1976. The second edition of Volume 2 has been delayed 
two years due to the fact that it was completely revised 
and put in the TEX typesetting language; since publication 
of this new edition is not far off, no changes to Volume 2 
are listed here. 


throughout the book(s) 


The present report was prepared with a typesetting system 
that is now obsolete; please do not wince at the typography. 
All changes and corrections henceforth will be noted in TEX 
form on file ERRATA. TEX [ART, DEK] at SU-AI. 

In spite of inflation, the rewards to error-detectors are 
still $2 for “new” mistakes in the second edition, $1 in the 
first edition. 

Please do not endanger the author’s morale by asking him 
about Volume 4. Thank you for your understanding. 

The preparation of this report was supported in pajt by 
National Science Foundation grant MCS-77-23728, by 
Office of Naval Research contract N00014-76-C-0330, and 
by IBM Corporation. 


2128178 2 


when the text of these books is on a computer I will try to be consistent in hyphenating 
compound adjectives like doubly-linked lists and storage-allocation algorithms, etc. ... but 
until then, such lapses are not to be considered errors 


line 11 

Leibnitz Leibniz 


line -7 


5127178 2 


11129/77 4 


the theorem that the theorem 



line 16 

11129/77 5 

3,... 

3. 



line 3, under the big pi 

11112176 6 

n, 

n 



Number 46 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Page 27 

244 



ll/iil1 displayed formula in exercise 32 


2/25/75 7 


Page 28 


n/ c ■''V+ n/c 


QJx 1*2 add a footnote (see p. v for style) 


4119177 8 


line 3 after (1): book. •'‘V* book.'*' 

footnote for bottom of page: In fact, permutations are so important, Vaughan Pratt has 
suggested calling them "perms." As soon as Pratt’s convention is established, textbooks of 
computer science will be somewhat shorter (and perhaps less expensive). 


lines -4, -5(twice), -7, -15, -16 11112176 9 

••• ... 

lines 3, 10, 11, 12, 21 11112/76 10 

••• •'V* . .. 

£L,£HI exercise 21 line 1 7/31/76 11 

Faa Faa 

line 13 2/25/75 12 

manner ''"V* matter 


line 6 after Table 1 5/25/76 13 

Szu-yuen Szu-yuan 

change in Eq. ( 17) 11/12/76 14 

-r r and r 'V -r 

Eq. (18) 7/31/76 15 

n > 0. •'V* n. 

line after (19) 11/12/76 16 

-r r 

caption to Table 2, replace third line by: 9/21/76 17 

see D. E. Barton, F. N. David, and M. Merrington, Biomotrika 47 (1960), 439-445; 60 
(1963), 169-176. 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 46 

245 



£,^2 line -4 


11115178 18 


Number 46 

246 


n n(k-l) ^ ^»i-l)(fc-l) 

lines 8,9,10 6/25/76 19 

Kepler, ... life. A* Johann Kepler, 1611, who was musing about the numbers he saw 
around him [J. Kepler, The Six-Cornered Snowflake (Oxford: Clarendon Press, 1966), p. 
21 ], 

£„0§ line -7 11/29/77 20 

use same style script F in this line as in line -6 (six places) 

£JE new generalized Eq. (29) 8/25/76 21 

(*/(•*-1))" - 1 - (1/(|.-1))[“_ 1 > 4 (1/(i.-1)(«-2))["_2> 2 - • • • - l m B k M i k /kl (29) 
(convert this to usual format for displayed equations) 

update to previous correction number 25 11/12/76 22 

to appear, A^» 75-77, 

£,$£ replace lines 1-3 by the following new copy 8/25/76 25 

The coefficients which appear in the last formula are called "generalised Bernoulli 

numbers"; Section 1.2.11.2 examines them further in the important special case n ■ 1. For 
small k, we have Bj^^/kl * (-D^tJJ.fc] (n-/c-1 )!/(n-1)!, but when k > n this formula breaks 
down since it reduces to 0 times oo. An analogous situation holds for the power series 
(a/lnO+z)) rt , where the coefficient of e k for k < n is {”_^}(n-fe-l)!/(n-l)l. 

£,^2 line -8 7/51/76 24 

Faa A^* Faa 

£caption, line 2 7/51/76 25 

2.11 A/* 2.10 

£,£0§ line 3 7/51/76 26 

Faa A^ Faa 


£,££0 three lines after (12) 6/25/76 27 

*m ^ l« m l 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 



£,£££ line 8 


11115178 28 


Page 30 


mately 2 mately (-l)^ + ^^2 


line -6 

Analysis ■'V* A crude analysis 


HjHIKs) line -6 and Eq. (22) 

n n- l/2 n n 

Q&QV line 5 

three •'“V* two 


£L„Hfi£3 exercise 5 
n n_ l/2 n n 

UdiSS line 2 

is loaded. 'V* are loaded. 


line 1 

The contents A portion of the contents 


line 7 


is ■"‘V* are 


11129/77 29 


11/29/77 80 


11/29/77 81 


11/29/77 82 


1/16/77 88 


1/16/77 84 


1/16/77 85 


line-19 11/15/78 86 

Overflow may occur as in ADD. * / 'v* Same as ADD but with -V in place of V. 

lines-18 through-13 11/15/78 87 

move this paragraph in front of the SUB definition on the preceding two lines 

line-12 4/19/77 88 

flUL requires ■'N/ 4 HUL, NUfl, CHAR each require 

QJ&WV box 05 4/19/77 89 

1 V 10 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 46 

247 



lines -10,-9,-8 


4119177 40 


CON 'V* CON (4 times) 

£,,£22 line 16 11129/77 41 

facilate • / V* facilitate 

stylistic corrections 6/14/77 42 

line 2: i.e. ■N' 4 e.g. 

line 3: (X ^ (Here X 

line 5: sun. ■'"V* sun; 

line 10: (E • / Ss* (This number E 

line 22: the year that the year 

lines 19-21 6/14/77 45 

An illustration...See also the book See, for example, the book 


Q'SZffl line-11 6/14/77 44 

F - 7 F - 9 

line -9 6/25/76 45 

about 1946 **V* during 1946 and 1947 

£,213^ line -10 12/19/76 46 

down an item •'V* an item down 
up the stack •'‘V* the stack up 


insert new paragraph after line 4 4/19/77 47 

Further study of Algorithm C has been made by D. S. Wise and D. C. Watson, BIT 16 
(1976), 442-450. 


line 4 9/21/76 48 

we exercise 30 describes a somewhat more natural alternative, and we 

new exercise 9/21/76 49 

30. [17] Suppose that queues are represented as in (12), but with an empty queue 
represented by F * A and R undefined. What insertion and deletion procedures should 
replace (14) and (17)? 

Number 46 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 9402S 

248 


Page 31 



JOSSES exercise 9 line 4 

girls A* women 


5/ 2/77 


50 


line 8 4119/77 51 


otherwise. A^* otherwise, making the latter node the right son of NODE (Q). 


new quote to insert just before Section 2.3.2 1/16/77 5 2 

Binary or dichotomous systems, although regulated by a principle, 
are among the most artiTicial arrangements that have ever been 
invented. 

—WILLIAM SWAINSON, A Treatise on the Geography and ClassiTication of 
Animals, Sec. 250 <1835) 


line 13 6/25/76 55 

In all A^» Furthermore TYPE (U) is set appropriately, depending on *. In all 


line 2 


12/19/76 54 


there is a man now living having A* somebody now living has 

line -1 

with ■''V* than 

line -2 

as A/* informally as 

line 11 

-types A* -tuples 


5/27/78 55 

1/16/77 56 


5/27/78 57 


QtWis) line 18 11/15/78 58 

Polya A/* Polya 


step A2 lines 2-4 2/28/78 5 9 

unmarked, mark it, and if A/* unmarked: mark it and, if (twice) 


lines 14-15 9/21/76 60 

[See the ... 372.] A/* An elaborate system which does this, and which also includes a 
mechanism for postponing operations on reference counts in order to achieve further 
efficiency, has been described by L P. Deutsch and D. G. Bobrow in CACM 19 (1976), 
522-526. 

Page 32 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

249 



line 17 77/29/77 61 

see A/-* see N. E. Wiseman and J. 0. Hiles, Comp. J. 10 (1968), 338-343, 


Number 46 

250 


line 18 6125176 62 

For these reasons the A* A contrary example appears in exercise 7; the point i6 that 
neither method clearly dominates the other, hence the simple 


line 11 1/16177 65 

each with a random lifetime, A* each equally likely to be the next one deleted. 


tjsm new paragraph after line 6 1/16177 64 

Our assumption that each deletion applies to a random reserved block will be valid if 
the lifetime of a block is an exponentially-distributed random variable. On the other hand, 
if all blocks have roughly the same lifetime, this assumption is false; John E. Shore has 
pointed out that type A blocks tend to be "older" than type C blocks when allocations and 
deletions tend to have a somewhat first-in-first-out character, since a scqucnco of adjacent 
reserved blocks tends to be in order from youngest to oldest and since the most recently 
allocated block is almost never type A. This tends to produce a smaller number of 
available blocks, giving even better performance than the fifty-percent rule would predict. 
[Cf. C/3 CM 20 (1977), 812-820.J 


line -9 11/15/78 65 

areas A/* areas of the same size 

line 7 1/16/77 66 

. A/-* ; John E. Shore, C/1 CM 18 (1976), 433-440. 

yet another addition after line 7 2/28/78 67 

. V ; Norman R. Nielsen, CACM 20 (1977), 864-873. 

exercise 28 4/19/77 68 

line 2: 5; for A/* 5. For 

line 4: ” A^* The execution time is 2u.” 

line 8 6/25/76 69 

V-l.] A^* V-l; and see especially also the work of Konrad Zuse, llcrichte der 
Gesellschaft fur Math, und Datenv. 63 (Bonn, 1972), written in 1945. Zuse was the first 
to develop nontrivial algorithms that worked with lists of dynamically varying lengths.] 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 



line -7 


12119/76 70 


is divisible is not divisible 




6/25/76 7/ 


lines -15 thru -13: The A-l ... code; **v* The machine language for several early 
computers used a three-address code to represent the computation of arithmetic 
expressions; 

lines -11 and -10: the A-l compiler language •'V* an extended three-address code 


2L # %£(9 line 2 3/ 2/77 72 

The latter Weizenbaum’s 


several changes 12119/76 73 

line 1: . • / \r+ , 

line 4: older other 

new paragraph to be inserted after line 4: 

A related model of computation was proposed by A. N. Kolmogorov as early as 1952. 
His machine essentially operates on graphs C, having a specially designated starting vertex 
Vq. The action at each step depends only on the subgraph G 'consisting of all vertices at 

distance < n from vq in G, replacing G' in G by another graph G" w f(G'\ where G' 
includes vq and the vertices v at distance exactly n from hq, and possibly other vertices; 

the remainder of graph G is left unaltered, its components arc attached to the vertices v at 
distance n as before. Here n is a fixed number specified in advance for any particular 
algorithm, but it can be arbitrarily large. A symbol from a finite alphabet is attached to 
each vertex, and restrictions are made so that no two vertices with the same symbol can be 
adjacent to a common vertex. (See A. N. Kolmogorov, Uspckhi Mat. Nauk 8,4 (1953), 175- 
176; Kolmogorov and UspenskiT, Uspckhi Mat. Nauk 13,4 (1958), 3-28, f\mar. Math. Soc. 
Translations, scries 2, 29 (1963), 217-245.) Such graph machines can easily simulate the 
linking automata defined above, taking one graph step per linking step; conversely, linking 
automata can simulate graph machines, taking at most a bounded number of steps per 
graph step when n and the alphabet size are fixed. The linking model is, of course, quite 
close to the operations available to programmers on real machines, while the graph model is 
not. 


exercise 44 line 2 11/12/76 74 

x k * yi -V* Xj+y k 

line 8 1/16/77 75 

(to appear) 'V* 13 (1975), 251-261. 

QJUfSS line 1 7/31/76 76 

Faa Faa 


Page 34 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

251 



4119/77 77 


UJQtiff new answer, continued 

For example, F.q. (6) holds for all complex k and n, except in certain cases when n is a 
negative integer; Eqs. (7), (9), (20) are never false, although they may occasionally take 
indeterminate form6 such as 0 co or oo+oo. We can even extend the binomial theorem (13) 
and Vandermondo’s convolution (21), obtaining 2 k ( *° + k * (l + *) r and 

2 c , formulas which hold for all complex r, a, *, o, b whenever 

the series converge, provided that complex powers are properly defined. [See L. Ramshaw, 
Inf. Proc. Let tar i 6 (1977), 223-226.] 


new answer 11112/76 78 

42. l/(r+l)B(fc+l,r-k+l), if this is defined according to exercise 41(b). In general it appears 
best to define (£) ■ 0 when k is a negative integer, otherwise (fc) m lim 4 _, r 
r(s+l)/r(fc+l)r(s-k+l), since this preserves most of the important identities. 



line 9 

11/13/78 79 

Polya A* 

Polya 



exercise 7 

11/13/78 80 


(It is "Glaisher’6 constant” 1.2824271...) To A* To 

This formula ... n=4. A* (The constant /\ is "Glaisher’s constant” 1.2824271..., which R. 
W. Cosper has proved equal to (2ire7 f_ f (2)/f(2))l/12 ) 

21,SEE exercise 5 11/29/77 81 

line 1; 2n-l A* 2n+l 

line 2: has ... dx. A* changes sign at r ■ n - O(Vn), so R m 0(f Q n \f"[x)dx) ■ 0(|/'(r)|) + 
0(|/'(n)|) - 0(/(n)/Vn). 

£„EE2 exercise 17(b) line 6 5/ 2/77 82 

J2NN A^» J2P 

H„EE2 exercise 19 4/19/77 83 

24 A* 42 
l+l)u A* 10+10)u 

exercise 25 4/19/77 84 

lines 11-12: operations” A* operations,” jumps on register even or odd, and binary shifts 
last line: M. A* M, and others could set register«-rA, register«-rX. 

Number 46 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park. CA 94025 

252 


Page 35 



km® 


6/14177 S5 


line 1: 6 A/-» 5 (also make this change in previous correction no. Ill) 

line 6: 3434 A^* 3495 and 6 A* 5 

line 7: 3495 A^» 3496 and 5 **V* 4 

line 9: 3506 A^» 3505 and 6 A/* 5 

line 10: 16 A* 14 


changes to answer 14 


6114177 86 


line 1: uses as much due in part to J. Petolino uses a lot of 

line 2: as possible, in in 

line 9: INCX 1 A* 


line 10: G A»* GMINUS1 
lines -17 to end of page, replace by: 

INCA 61 
STA CPLUS60 
MUL =3//4+l*= 

STA XPLUS57(1:2) 
CPLUS60 ENTA * 

MUL =8//25+l= 
GHINUS1 ENT2 * 

ENT1 1,2 
INC2 1,1 
1NC2 0,2 
1NC2 0,1 
INC2 0,2 
INC2 773,1 


rA - Z + 24 
E5. 

rll ■ G 


rI2 - 11C + 773 


XPLUS57 INCA-*, 2 


rA - 11C+Z-K+20+24 30 (> 0) 


more changes to answer 14 


6114/77 87 


delete the bottom line and replace lines 1-31 by: 

SRAX 5 

D1V =30- rX m E 

DECX 24 

JXN 4F 

DECX 1 

JXP 2F 

JXN 3F 

DEC1 11 

J1NP 2F 

3H I NCX 1 


2H DECX 29 E6. 

4H STX 20111NUSN (0:2) 

LDA Y E4. 

MUL -1//4+1- 
ADD Y 

SUB XPLUS57(1:2) rA ■ D-47 

20111 NUSN ENN1 * 

INCA 67,1 E7. 

SRAX 5 rX m D * N 

DIV =7- 
SLAX 5 

DECA -4,1 rA-31-N 

JAN IF E8. 


DECA 31 
CHAR 

LDA MARCH 
JMP 2F 

1H CHAR 

LDA APRIL 


Page 36 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

253 



new answer 


6114177 88 


15. The first such year is A.D. 10317, although the error almoit leads to failure in A.D. 
10108+19* for 0 < * < 10. 

2I„S2!>§ still more changes to answer 14 6114177 89 


replace lines 1-6 by: 

BEGIN ENTX 1950 

ENTG 1950-2000 
jnP EASTER 
1NCG 1 
ENTX 2000,5 
JGNP EASTER+1 


"driver” 
routine, 
uses the 
above 

subroutine. 


£.££*2 line 18 11129/77 90 

time. time. (It would be faster to calculate r f| (l/m) directly when m is small, and 

then to apply the suggested procedure.) 


£,£££ bottom line 11/29/77 91 

Bcrk’ly A** Berkeley 

£,£££i lines -4,-3 4/19/77 92 

3)+7 •'V* 7.5)+16 

£„££^ exercise 12 lines 7-10 5/27/78 93 


delete "Thus, ...(b).” 


£,£££ line 5 5/27/78 94 

19-27. A^ 19-27; E. G. Cate and D. W. Twigg, ACM Tram. Math. Software 3 (1977), 
104-110. 


new answer 9/21/76 95 

30. To insert, set P <= AVAIL, 1NF0(P) <- Y, LINK(P) «- A, if F ■ A then F <- P 
else LINK (R) «- P, and R «- P. To delete, do (9) with F replacing T. 


exercise 18 3/ 2/77 96 

denotes, ... arc included. A*** denotes "exclusive or.” Other invertible operations, such as 
addition or subtraction modulo the pointer field size, could also be used. It is convenient 
to include 


Number 46 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 

254 


Page 37 



exercise 2 


SI 2177 97 


Page 38 


line 2: next ... list point next, so the links in the list must point 

line 3: So ... the Deletion at both ends therefore implies that the 

line 4: ways. A/-* ways. On the other hand, exercise 2.2.4-18 shows that two links can be 

represented in a single link field; in this way general deque operations are possible. 


J0>»SSI3 exercise 9 step G4 S/ 2177 98 

desired girls, A^» young ladies desired, 


line -6 5/27178 99 

"pedigrees”, A^» "pedigrees,” 


exercise 12 line 5 9121/76 100 

oo. • / \* oo. Here c{i,j) means c(/,i) if j < ». 

answer 5 1/ 5/79 101 

There is ... exist. “V* When n>l, the number of series-parallel networks with n edges is 
2e n [see P. A. MacMahon, Proc. London Math. Soc. 22 (1891), 330-339]. 


fourth line before exercise 33 5/27/78 102 

minimal. minimal. [This argument in the case of binary trees was apparently first 

discovered by C. S. Peirce in an unpublished manuscript; see his New Elements of 
Mathematics 4 (The Hague: Mouton, 1976), 303-304.] 

QJi&Q updates to previous change number 150 9/21/76 10S 

to appear, A^» 491-500, 

(see also the important new contribution by H. G. Baker, Jr., C/1CM 21 (1978), 280-294, for 
which 1 will probably want to revise Section 2.3.5 entirely!) 


update to previous change number 151 11/29/77 104 

Clark’s list-copying algorithm appeared in CACM 21 (1978), 351-357, and Robson’s in 
CACM 20 (1977), 431-433 

last line of answer 6 1/16/77 105 

list. ' / \* list. For an alternative improvement to Algorithm A, see exercise 6.2.3-30. 


exercise 8 6/25/76 106 

line 1: also set R A* also set 11 «- oo, R 
line 3: If R ■ A or M A* If pj 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 46 

255 



QJ21 exercise 26 line 3 


2128178 107 


two. A/* two, with blocks in decreasing order of sise. 

P > fl A* P > M - 2*. 

£1,(1(1121 program line number 12 

i A* j. 

new answer 

31. See David L. Russell, SIAM J. Computing 6 (1977), 607-621. 


H„(£illIS addition to previous change 153 

.] A»* ; Lars-Erik Thorelli, BIT 16 (1976), 426-441. 

21„l£lM exercise 41, numerator in value of a[5] 

19559 A* 18535 


delete A-l compiler, 458. 


Aardenne-... 

Taniana A/* Tatyana 


AMAf A* AMM 


turn 

Baker, Henry Civens, Jr., 594. 


add p487 to entry for Binomial theorem, generalizations of 


Bobrow entry 

add p420 


4119/77 108 


2128178 109 


4119/77 110 


6114/77 111 


6/25/76 112 


11/29/77 US 


12/19/76 114 


5/27/78 115 


4/19/77 116 


9/21/76 117 


To be continued in future issues. 


Number 46 

256 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 



Random Ruminations 


On Networks 
Of The Future 

BY JONATHAN SACHS 

The Orthocode Corporation 
6713 Richmond Avenue 
Richmond View, CA 94805 

We asked Jonathan Sachs to speculate 
theoretically about networks and the 
future .... 

Popular Use of Networks: What It Will 
Take 

In the past, computers have been attractive 
only to those oddballs who were interested 
in computer hardware or software. Networking 
can make them attractive to everyone who 
needs to deal with information by making them 
potential tools for processing information 
about the world at large. This promises to be 
the first development that makes computers 
directly useful to a large proportion of man¬ 
kind. 

There has been a great deal of speculation 
(and some research) on this question of how 
computers will affect the quality of life. Sce¬ 
narios run the gamut from a plugged-in society 
where everyone is in touch with everything, 
to a totally dehumanized society where people 
interact with machines to the exclusion of one 
another. For a thorough and responsible 
(but highly readable) study of the issues, see 
The Network Nation by Hiltz and Turoff 
(Addision-Wesley Publishing Company). 

Networks must be not only useful, but 
usable by the public, or they will win little 
acceptance. What do I mean by “the public?” 
I mean: a substantial proportion of everyone 
who lives in the part of the world we’re con¬ 
sidering. Here are some important character¬ 
istics of the public a successful network must 
serve: 

• It includes large numbers of people with 
different technical orientations: toward com¬ 
puter programming, law, sculpture, animal 
husbandry, etc.; 

• It includes large numbers of peole who have 
no technical orientation at all; 

• Its members would demand widely varying 
types and amounts of information from a net¬ 
work; 

• Most of its members would have little or 
no motivation to learn to use a network, 
except for whatever immediate benefits they 
could anticipate before they started. 

To serve this audience, a network must be 
usable (at least on an elementary level) by 
non-technical people of average intelligence, 
with very little training. 



But a successful network must also be 
able to accommodate experienced users with 
sophisticated demands. Is this requirement for 
power and versatility at odds with the equally 
important need for ease of use? Not necessarily. 

We could design a powerful system that 
could be “packaged” in a variety of simple 
ways for relatively specialized uses. One can 
imagine network customers ordering options 
from a network service representative, just as 
telephone subscribers order different kinds of 
service from the phone company. Users willing 
and able to do so could build their own service 
packages. 

The early packaged offerings of such a ser¬ 
vice would probably be digital analogs of news¬ 
papers, telephones, and other things the public 
is already comfortable with. 

Less conventional uses would follow in time. 
For example, one can imagine a “therapy group” 
network conference in which every member 
but the leader was guaranteed to remain anony¬ 
mous, or an “information brokerage” that acts 
like a combination of publicity agency and 
clipping service, putting generators and con¬ 
sumers of information in touch with each 
other. 

A single system accommodating both be¬ 
ginners and old hands would have a built-in 
mechanism for introducing innovation to the 
mainstream of use. It is the simple fact that 
there would be no sharp dividing line between 
an experimental use and a publicly available 
one. When an advanced user developed an 
application that was genuinely useful to the 
public, the public would begin to use it. At 
some point the operators of the network would 
see fit to offer that application as an official 
service. Thus the network-using public would 
serve as both a laboratory for developing new 
applications and a lobby for adopting successful 
ones. 

A Trap for Designers 

There’s a saying that the generals who plan 
military strategy are always guilty of refighting 
the last war. Perhaps network designers are 
guilty of a similar error: designing networks 
for the future that can be built from com¬ 
ponents available today. 

It is difficult to design a system with com¬ 
ponents that do not yet exist, but it is pointless 
to design an eminently buildable system that 
turns out to be unsuccessful because it is not 
suited to the needs of its users. If our goal is 


to design a network that will be acceptable to 
the general public, we must determine (1) 
what capabilities such a net will have to have, 
and (2) what present-day technology, if any, 
can provide them at an economic cost. If no 
suitable technology is at hand we may change 
or compromise our goals, but we wll get no¬ 
where by trying to fit the system’s require¬ 
ments to the technology that is available. 

To take a simple example, consider terminal 
display versus hard copy. Most of the net¬ 
work-like systems so far available to the public 
(chiefly television-based systems like England’s 
Prestel) use display only. The display was 
already available in the prospective user’s TV 
set, while a hard copy printer would have to 
be added at extra cost. But is display output 
sufficient? Probably not. Unlike a television 
set, a computer network is used primarily to 
process information. And information, once 
processed, must often be preserved in acces¬ 
sible form. 

Why can’t information be stored electro¬ 
nically and displayed at need? Because electro¬ 
nically-stored information is not accessible 
in the same sense that hard copy is. There are 
countless things one can do to hard copy but 
can’t do to a display; for example, one can: 

• Fold it, tear it, or staple it to things. 

• Mark it with a felt-tip marker. 

• Scribble notes on it. 

• Work with it while sitting in an easy chair. 

• Take it along to the park. 

• Place it next to several like objects in order 
to compare, collate, or cross-reference them. 

• Place it on a part of a desk where one will 
unconsciously reach for it when one needs 
it. 

• Cherish it as a memento. 

This is not to say that video displays are 
not useful; only that hard copy has some func¬ 
tions that displays cannot usurp, and that 
therefore a general-purpose information system 
that offers no hard copy will have a hard time 
gaining acceptance. 

For another example, take image quality. 
Today’s standard of quality seems to be the 
dot-matrix printer. Is that good enough for a 
public network? 

Consider what kinds of information the 
network will convey. Initially, at least, the 
greatest volume of use will be in fairly predict¬ 
able replacements for older media. 

Newspaper material? Newspapers contain 
many pictures-not only for their information 
value, but because most readers want the paper 
to be an easy read, and are unwilling to di¬ 
gest solid blocks of text. Some parts of the 
paper (comics, movie ads) are inconceivable 
without pictures. Television, the only other 
comparable medium, is all pictures. (Radio is 
an unfair comparison; it has sound, and the 
computer nework does not have that yet, 
either.) 

How about instructional material and re¬ 
ference material? Both tend to use a lot of 
graphics at all levels of difficulty (in some 
strata the graphics are called “equations”). 

For computerized conferences or telecom¬ 
muting (working from one’s home through a 
computer) the requirements are a little more 
complex. In some situations words would be 
sufficient, as they are in telephone conversa¬ 
tions, and the need for graphics would not 
come up. But when graphics were necessary, 


Page 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

257 




there would be the added difficulty of giving 
each user a way to input pictures as well as 
output them. There would probably have to 
be several ways to input pictures: through 
keyboard commands, fingerpainting on a screen, 
digitizing existing line or continuous-tone 
images, etc. 

So it appears that a generally useful public 
network would have to offer both line draw¬ 
ing and halftone graphics, at least approaching 
the quality of newspaper pictures, and pre¬ 
ferably somewhat better. Could a dot matrix 
printer produce a satisfactory result? Maybe, 
but that criterion would disqualify most of 
the printers made today! If it is recognized as 
necessary, a different kind of hardware must 
be designed. 

A long list of other questions could be asked 
along the same lines. What sort of input de- 
vice(s) will users want? How fast will transmis¬ 
sion have to be? Will color output be necessary/ 
desirable? What about color input? 

Some Wild and Crazy Possibilities 

While we’re on the topic of capabilities, 
what options could we add to a public network 
to make it more useful, interesting, or what¬ 
ever else? 

Another way to ask the question is: what 
limitations on the forms networked informa¬ 
tion can take have we unconsciously accepted, 
and what could we do if those limitations 
were removed? 

Suppose we didn’t content ourselves with 
moderately good black-and-white dot images, 
but went for high resolution color. The things 
the network could convey would now expand 
to include aesthetically meaningful repro¬ 
ductions of artwork. The network might even 
become a medium for creating original art. 
And there are other things the network could 
then accommodate, such as medical literature 
and maps. 

Graphics may be viewed as a liberation from 
the restrictions of text. But it may also be 
viewed as a restriction itself. Computers can 
analyze and generate sound. Why shouldn’t 
a network do so? 

A possibility: computerized catalogs of 
sound recordings. A user finds a recording he 
wants through an index; then the computer 
plays it through the network. Such a system 
could be used to catalog sounds that were too 
short to deal with readily in a conventional 
recording library, e.g., individual bird calls. 

Another possibility: a data base of digitized 
music. Audiophiles could search and mani¬ 
pulate this data base directly, just as library 
researchers could search and manipulate a data 
base of text. 

Another possibility: co-ordinated telecon¬ 
ferences (or classrooms, or dramatic perform¬ 
ances) which make simultaneous use of audio, 
video, and computerized text/graphics. For 
example engineers could discuss a design using 
audio to communicate by speech, while using 
computer graphics to develp the design, and 
video to examine samples or the data. 

The most significant developments in net¬ 
working are impossible to predict. They will 
be products of genius, and so will be incon¬ 
ceivable until they start to happen! 



Number 46 

258 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 41 

































Displaying Two Columns 
with North Star t K .r DS ° N 


O.K. HUDSON 

334 Oney Drive 

San Antonio, Texas 78209 


OE 12 
CD FB 19 
C3 14 26 
C3 03 1A 
OE OF 
CD 04 27 


OD 

C2 FB 19 
C9 


3A 1C 1A 
FE 00 
CA 13 1A 
3E 00 
32 1C 1A 
C3 F9 19 
CD OC 27 
3E OF 
32 1C 1A 
C9 


SYMBOL TABLE 


BLANK 19FB 
ORG 19EE 


************************************************* 
* * 

♦ DOUBLE COLUMN FILE LISTING * 

* * 

* SEE DDJ #39,43 *41,44 #42,44 * 

* * 
************************************************* 


♦THIS PROGRAM REQUIRES PATCHES TO THE DOS AND AN 
♦EXTRA SUBROUTINE IN RAM TO CAUSE THE DIRECTORY 
♦LISTING TO BE PRINTED IN TWO COLUMNS. 

♦THE EXTRA SUBROUTINE IS LOCATED AT 19EE BECAUSE 
♦MY DOS PERSONALIZATION AREA IS FULL. 

♦ 

♦IN ORDER TO GET CORRECT ADDRESSES ON FILES WHERE 
♦THEY ARE NOT NORMALLY SPECIFED, ONE MUST DO A 

♦ ’TY 'WHATEVER' 1 ADDRESS - THEN REPEAT WITH 
♦THE PROPER FILE TYPE — THE ADDRESS WILL 

♦BE REMEMBERED BY THE DISK FILE. 

♦ 

♦THIS SOURCE WILL ALSO HANDLE THE OLD DOS IF THE 
♦FOLLOWING EQUATES ARE SUBSTITUTED: 

* DOS EQU 25EEH 

* D0S2 EQU 2709H 

* LFCR EQU 270FH 

* 

♦SYSTEM EQUATES FOR N^ DOS V.4 

ORG EQU 19EEH 

DOS EQU 2614H 

D0S2 EQU 2704H 

LFCR EQU 270CH 

♦ 

♦IN ADDITION THE FOLLOWING PATCHES MUST BE MADE 

♦ WITHIN THE DOS ITSELF I 

♦ 2601 FE OA 


2603 D2 EE 19 
2611 CD F6 19 


♦FOR THE OLD DOS (0.3 ?>, 

♦ 25DB FE OA 

♦ 25DD CA EE 19 

♦ 25EB CD F6 19 

♦ 

MVI C,12H 
CALL BLANK 
JMP DOS 
JMP PSUB 
REN MVI C,OFH 
BLANK CALL D0S2 
♦ 

♦ 

DCR C 
JNZ BLANK 
RET 

♦ 


THE DOS PATCHES ARE: 


I have enjoyed the contributions from 
your other readers, and feel that now the 
time is ripe for me to reciprocate. At¬ 
tached please find an 8080 Assembly 
listing for making a North Star Disk 
display its catalogue in two columns. 
Several other contributors have addressed 
this prolbem with varying degrees of 
success. This program is different in 
that it tries to make clear the required 
changes for the ‘latest’ DOS (which I 
think is V.4) and the old DOS (which 
may be V.3). Both kinds are around— 
in addition to some others too. 

This program differs in one other im¬ 
portant aspect: the other programs re¬ 
lied on the terminal generating a carriage 
return. This does not happen when a 
printer is used. This program will generate 
a carriage return after 80 spaces. 

Keep up the good work. If you don’t 
want to publish this, you may trash it. 
I don’t believe in copyrights—and who 
cares anyway. We mostly do this for fun 
and if we also make a buck now and then 
— fine. 


♦THIS IS THE SPACE ALLOWED FOR AN ENTRY 

♦THIS SUBROUTINE IS ALREADY IN THE DOS 

♦GET ANOTHER ENTRY 

♦DOS RE-ENTRY POINT 

♦THIS IS THE SPACE BETWEEN COLUMNS 

♦ THIS IS THE ACTUAL SOURCE OF I HE BLANKS 

WITHIN THE DOS - IF YOU WANT SOME 

OTHER CHARACTER YOU MAY PATCH IT IN ! 
♦COUNT THE BLANKS REMAINING TO BE SENT 
♦FINISHED ?? 


♦SUBROUTINE TO PROVIDE LINE FEED AND CARRIAGE RETURN 

♦ 


PSUB LDA ST0R1 
CPI 0 
JZ DSUB 
MV I A, 0 
STA STOR1 
JMP REN 
DSUB CALL LFCR 
MVI A,OFH 
STA ST0R1 
RET 

♦ 

♦ 

♦STORAGE TABLE 
ST0R1 DW 0 


♦SAVE THE ACCUMULATOR VALUE 
♦WAS IT A 0 ?? 

♦IF IT WAS THEN LINE FEED AND CARR RET 

♦MAKE SURE IT IS A 0 NEXT TIME 

♦BY PUTTING IT IN STORAGE 

♦GO PRINT THE NEXT ENTRY 

♦THESE ARE ALSO IN THE DOS - USE 'EM 

♦MAKE SURE WE DON'T DO THIS TWICE IN A ROW 

♦BY FILLING STORAGE WITH A PROPER FLAG 


♦THIS IS WHERE WE KEEP THE FLAGS 


DOS 2614 
PSUB 1A03 


D0S2 2704 
REN 19F9 


DSUB 1A13 
ST0R1 1A1C 



Page 42 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 46 

259 









A Versatile Memory Dump 


BY HAL KNIPPENBERG 

2514 Blueberry Drive 
Augusta, GA 30906 

Dear DDJ: 

I am often asked how to develop memory 
dump programs. The main complaint is that 
most memory dump programs are too special¬ 
ized-they work only in one mode. For in¬ 
stance, they will dump Hex when you want 
Decimal. Or they will dump Octal when you 
want Hex. 

The program I have developed in answer to 
these questions is a generalized MEMORY 
DUMP program written in BASIC. It uses two 
base conversion subroutines and can work in 
four different modes. In addition, it prints 
an ASCII dump as well. 

I wrote the program in Digital Group’s 
MAXI-BASIC. If being used with another 


Iff 


BASIC which uses LEFT, RIGHT, and MID 
string functions, change the following: 


LINE 500 AND 655 . .Change the A$(l,l) to LEFT $(A$,1) 

LINE 725 .Change A$(I,1) to MIDS(A$,I,1) 

LINE 915.Change H$(l,3) to LEFT$(H$,3) and 

change H$(4) to RIGHT $(H$,3) 

LINE 565 .Many BASICS use the command 

PEEK instead of EXAM 


I have used many REMARK statements to 
help show the structure of the program, but 
you do not need to type in any of the REM 
lines for the program to work properly. 


Two other lines might cause trouble, lines 
240 and 510. MAXI-BASIC does not have a 
quick way to clear the monitor, so I use a 
machine language subroutine. TRS-80 users 
can use CLS to do the same thing. If your 
BASIC does not have a cleax-screen function, 
GOSUB to the following BASIC subroutine: 

FOR I = 1 to 16 
PRINT 
NEXT I 
RETURN 

This will also clear the screen, although it 
takes a moment longer. 


DiA©Ln®in®incDUia 
-P-©COCOcn®® — — O 
oinminuiLntncouxjoa 


DistCDin®in®inc 

!> ® — — CM CM CO CO ■« 
-r-f-f-t-r-r-f-c 


Disi<sist®Lr<®Ln®i/)a 

iM/uoior-f-oscommc 
- r- p- r- c- r- c- r- r- r- o 


n®in®Ln®Ln®ui<2 
0 CO 00 CO CO CO CO CO TO Ci 


LSt®isiCDUi®inS>b 
COCOCO®® — — CMC 

cooo®m<r»cn<7><7>c 


t ® in® in ® u 

LO CO 0 
J CM CM CM CM CM 0 


-c-cococnco®® — — 

MCMCMCMCMCMCOCOCOCO 


®Ln®LTl®U 1 ®lJ 

(MCMCOCO*--*-U1Lj 
CO CO CO CO CO CO < 0 C 


Dvn®in®tSi®Ln®isi®i/i®Lni3 
- C- CO CO CO CO ® ® — — CM CM CO CO 1 
')COCOCOCOCO*-TM-*-*-M-M-'*-'1 


ocomco ® © - - 


Number 46 

260 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 


















BY EDWARD L. ELIZONDO 

6 Cypress Court 
E. Windsor, N.J. 08520 

I was delighted to find in your Janu¬ 
ary issue not one, but two contributed 
programs to convert Processor Tech¬ 
nology assembler format files to a format 
compatible with the CP/M assembler. 
I am presently running a 48K CP/M 
system, using CUTER in ROM at C000 
hex to drive a Processor Technology 
VDM. My weekend project started with 
the idea of converting the CUTER source 
file (generously distributed by Processor 
Tech on the CUTER/BASIC5 cassette) 
to CP/M format, make a few alterations, 
and reassemble it at F000 hex. 

Unfortunately, neither published pro¬ 
gram quite met my requirements. Hollis 
Frampton’s CPCON is limited to pro¬ 
grams smah enough to fit in memory 
and requires downloading to tape, while 
Mark Zeiger’s CHANGE did not correctly 
copy with commented lines, ASC pseudo¬ 
ops and other ALS-8 peculiarities such 
as dummy period operands. 


Since frustration is the spur of creat¬ 
ivity, I took it upon myself to generate 
yet a third conversion program, herein 
submitted to you. 

ALS8CPM successfuhy converts the 
bulk of ah ALS-8 statements to a form 
digestible by the CP/M ASM. Using 
ALS8CPM, the CUTER source files 
(total size = 58K) were converted with 
only seven residual errors flagged by 
ASM on reassembly. The program is 
fairly straightforward and fully com¬ 
mented, so it can easily be modified if 
desired. 

A few comments about the program: 
I chose not to convert negative numbers 
used in immediate operands (MVI A, 
— 1) for fear of creating subtle errors in 
programs using negative signs in arith¬ 
metic expressions. Not processed by 
ALS8CPM are the infrequent ALS-8 
pseudo-ops COM, NST and LST, the 
INTEL pseudo-op TITL, and program 
use of ASM reserved words such as 
SET, IF and ENDIF. Also not handled 
are PSW and SP equate statements used 
to add these register names to the ALS-8 
symbol table ( an unforgiveable commis¬ 


sion on the part of the late Processor 
Tech). Residual errors after conversion 
involving any of the preceding can 
quickly be located by a trial reassembly 
and corrected by editing. 

I intend to submit this program to 
the CP/M User’s Group and to the Pro¬ 
cessor Technology User’s Society (PRO¬ 
TEUS). Incidentally, even though I have 
never owned a SOL, I must publicly 
compliment Stan Sokolov and the latter 
group for three years of publishing an 
excellent newsletter and attempting to 
protect the member’s investment in time 
and money by providing a wealth of 
information, reviews, valuable user feed¬ 
back on various commercial products, 
tutorials on such diverse subjects as 
PASCAL and CP/M, and much inside 
information on what really was hap¬ 
pening at Processor Tech. 

For any impatient souls out there who 
don’t feel like typing up ALS8CPM, 
I will provide the source code on an 8 
inch standard CP/M format diskette for 
$10 to cover the cost of the diskette, 
mailer and shipping charges, until the user 
group distributions are available. 


ALS8CPM .ASH 

PROGRAM FOR CONVERTING PROCESSOR TECHNOLOGY 
ALS-8/SPKG-1 ASSEMBLER FILES TO CP/M FORMAT 

(C) COPYRIGHT 1980 

ED ELIZONDO 6 CYPRESS CT EAST WINDSOR NJ 08520 
ALL RIGHTS RESERVED 

THIS PROGRAM MAY BE USED FREELY BY COMPUTER 
HOBBYISTS FOR NON-COMMERCIAL APPLICATIONS. 

IT MAY NOT BE USED FOR COMMERCIAL APPLICATIONS 
OR SOLD WITHOUT WRITTEN PERMISSION OF THE 
AUTHOR. 

REV 1.6 31 JAN 1980 


NOTE: This program processes assembly language files 
prepared for the Processor Technology ALS-8 or Software 
Package No 1 assemblers to a format compatible with 
the CP/M ASM assembler. It requires the presence of 
CUTER/SOLOS or some other means of loading the ALS-8 
source file onto memory so that it can be saved by CP/M. 

It does not require the presence of anything other than 
CP/M during the remaining operations. 

The translation process operates in accordance with 
the following algorithms: 

Each line is converted independently. The line byte count 
and line number fields are deleted from the source lines 
and each line is terminated with a CR/LF sequence. 

A semicolon is placed ahead of all comment lines (for 
compatibility with MAC) and ahead of all comment fields. 
Leading spaces are deleted from comment fields only. 

Comment lines and the remainder of comment fields are 
passed unchanged, except for deletion of any exclamation 
mar ks. 

Periods used as dimmy operands for formatting purposes 
are removed, as well as any leading spaces appearing in 
instructions and operand fields. Operands enclosed in 
single quotes are passed unchanged. 


a 


ASC pseudo-operators are changed to DB and the corresponding 
delimiters changed to single quotes. 

The *>' pseud o- operator is converted to an 'AND 0FFH' post 
operator and the '<’ is similarly converted to a 'SHR 8'. 

Instruction, operand and comment fields are tabbed 
and colons are added to labels to "pretty" the output. 

The program utilizes slightly modified versions of the 
CP/M User's Croup LI0S.ASM disk 1/0 routines (CPMUG 1.19) 

TO USE: 1) load your ALS-8 format program into RAM at 100H 
(If using SOLOS/CUTER, note the first two digits 
of program size returned by the load message. 
Convert to decimal and add 1 to obtain the 
number nn required in step 3). 

2) boot up CP/M 

3) type SAVE nn NAME). EXT (where nn is number of 
pages of program size in decimal) 

H) run the conversion program by typing: 

ALS8CPM NAME 1. EXT NAME2. ASM 
where NAME2.ASM is the desired name of the CP/M 
compatible output file (note spaces between 
the above name fields) 

5) edit the resulting ASM file to add the appropriate 
0RG statem ent. 

6) assemble to locate any residual unique errors. 



BDOS 

ADDRESSES: 


BDOS: 

E0U 

0005 

;BDOS ENTRY POINT 

SOURCE: 

E0U 

5CH 

;S0URCE FILE FCB 

TBUF : 

E0U 

0080H 

;TRANSFER BUFFER 


BDOS 

FUNCTION CODES: 


PRINT: 

E0U 

9 


OPEN: 

E0U 

15 


CLOSE: 

E0U 

16 


MAKE : 

E0U 

22 


READ: 

E0U 

20 


WRITE: 

E0U 

21 


DELETE: 

LQU 

19 



Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park CA 94025 


Number 46 













ASCII 

CODES: 


SPACE: 

EQU 

20H 


QUOTE: 

EQU 

27H 


TAB: 

EQU 

09H 


CR: 

EQU 

ODH 


LF : 

EQU 

OAH 


. • 

MAIN 

PROGRAM » 


; 

ORG 

100H 



LXI 

DAD 

H, 0 

SP 

;GET OLD STACK POINTER 


SHLD 

OLDSTK 

;SAVE IT FOR EXIT 


LXI 

SP,NEW STK 

;SET UP NEW STACK 


LXI 

D.MSSGO 

;SAY HELLO 


CALL 

MESSAGE 



CALL 

GETNAMES 

;GET FILE NAMES FROM COMMAND 


CALL 

OPE NFILES 

;0PEN F ILES FOR ACCESS 


LXI 

D,MSSG8 

;WE’RE DOING FINE 


CALL 

MESSAGE 



CALL 

PROCESS 

;PROCESS LINE BY LINE 


CALL 

W EOF 

;F ILL LAST INCOMPLETE PAGE 

ABEND: 

CALL 

CLOSEFILE 

;CLOSE FILES 


LXI 

D,MSSG9 

;WE’RE FINISHED 


CALL 

MESSAGE 


FIN: 

LHLD 

SPHL 

OLDSTK 

;RESTORE OLD STACK POINTER 


RET 


•.RETURN TO CP/M 


o 


GETNAMES 

SUBROUTINE TO CHECK & GET FILE NAMES 


GETNAMES: 

LDA 

CPI 

JZ 

LDA 

CPI 

JZ 


SOURCE+1 

SPACE 

ERROR6 

SOUR CE+1 7 

SPACE 

ERROR7 


FIRST CHAR OF SOURCE NAME 
EMPTY? 

YES, ERROR 

FIRST CHAR OF DEST NAME 
EMPTY? 

YES, ERROR 


MOVE DEST FCB TO SAFE PLACE 


LXI 
LXI 
M VI 
CALL 


D, SOURCE + 16 
H,DEST 
B , 16 
MOVE 


INITIALIZE FCB 'S 
XR A A 

STA SOURCE+32 

STA DEST+32 

RET 


START OF TEMP DEST FCB 
WORKING DEST FCB 
NUMBER OF FCB CHARACTERS 
MOVE NAME 


GET A 0 

ZERO SOURCE NR FIELD 
ZERO DEST NR FIELD 


0 P 

E N F ILES 

• 

SUBROUTINE 

TO OPEN FILES FOR 

ACCESS • 

)PENF ILES: 



M VI 

C,OPEN 

;GET OPEN FUNCTIOI 

LXI 

D,SOURCE 


CALL 

B DOS 

;OPEN SOURCE FILE 

CPI 

OFFH 

;OPEN ERROR? 

JZ 

ERROR 1 

;YES, ABORT 

M VI 

C,DELETE 

;DELETE FUNCTION 

LXI 

D,DEST 


CALL 

B DOS 

;DELETE EXISTING I 

M VI 

C.MAKE 

;MAKE FUNCTION 

LXI 

D,DEST 


CALL 

B DOS 

•.CREATE NEW DEST 1 

CPI 

OFFH 

;MAKE ERROR? 

JZ 

ERROR 3 

; YE S, ABORT 

M VI 

C .OPEN 

;OPEN FUNCTION 

LXI 

D, DEST 


CALL 

B DOS 

;OPEN DEST FILE 

RET 



P R 

0 C E S S 

* 

ROUTINE TO 

PROCESS EACH LINE 

• 


PROCESS: 


XR A 

A 

;CLEAR STRING FUG 

STA 

FLAG 


CALL 

GETBYT 

;GET LINE CHAR COUNT 

CPI 

1 

;END OF FILE? 

JZ 

EOFMARK 

;YES, PROCESS IT 

DC R 

A 

•.UPDATE CHAR LINE COUNT 

STA 

EOLC NT 

;SAVE IT 

M VI 

B ,5 

;F IELD COUNT 


o 


LNUM: 

PUSH 

B 

MOVE PAST LINE NUMBER FIELD 


CALL 

GETBYT 

READ A BYTE 


POP 

B 



CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

PR EMEND 

PREMATURE END OF LINE 


DC R 

B 

DECREMENT FIELD COUNT 


JNZ 

LNUM 

UNTIL DONE 

LABEL: 

CALL 

GETBYT 

PROCESS LABEL FIELD 


CPI 

• • i 

COMMENT LINE? 


JZ 

COMLINE 

YES, PROCESS IT 


CPI 

SPACE 

MISSING LABEL? 


JZ 

INSTR 

THEN PROCESS INST 

LA BEL 1: 

CALL 

OUTBYT 

OUTPUT LABEL CHAR 


CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

EOLINE 

IF END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CPI 

SPACE 

END OF ALS-8 LABEL? 


JZ 

LABEL2 

YES, EXIT LOOP 


C PI 

': ' 

END OF INTEL LABEL? 


JNZ 

LA BEL 1 

NO, KEEP GOING 

UBEL2: 

M VI 

A ,' : • 

YES, OUTPUT A COLON 


CALL 

OUTBYT 

AND DROP THRU 

INSTR: 

M VI 

A , TAB 

PROCESS INSTR FIELD 


CALL 

OUTBYT 

TAB TO NEXT COLUMN 


CALL 

DELSP 

DELETE LEADING SPACES 


JC 

EOLINE 

IF END OF LINE 

■ 

CHECK FOR ASC PSEUDO-OP 



CPI 

'A ' 

POSSIBLE ASC PSEUDO OP? 


JNZ 

INSTR2 

NO WAY 


CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

EOLINE 

IF END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CPI 

'S ' 

ASC PSEUDO OP? 


JNZ 

REC0V2 

NO, RECOVER LAST TWO BYTES 


CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

EOLINE 

IF END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CPI 

•c • 

ASC PSEUDO OP? 


JNZ 

REC0V3 

NO, RECOVER LAST 3 BYTES 

* 

CONVERT 

ASC PSEUDO OP TO 

DB 


LXI 

D, DBOP 

OUTPUT A 'DB' 


CALL 

PUTSTRING 



M VI 

A , TAB 

END OF INSTR FIELD 


CALL 

OUTBYT 

TAB TO NEXT COLUMN 

* 

HANDLE 

ASC OPERAND AND CONVERT DELIMITERS 


CALL 

DELSP 

DELETE EXTRA SPACES 


JC 

EOLINE 

IF END OF LINE 


STA 

DELIM 

SAVE THE ASC DELIMITER 


M VI 

A,QUOTE 

GET CPM DELIMITER 

ASC 2: 

CALL 

OUTBYT 

OUTPUT IT 


CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

EOLINE 

IF END OF LINE 


LDA 

DELIM 

GET DELIMITER 


MOV 

B , A 

INTO B 


PUSH 

B 

SAVE B 


CALL 

GETBYT 

GET NEXT BYTE 


POP 

B 

RESTORE B 


CMP 

B 

DELIMITER? 


JNZ 

ASC 2 

NO, KEEP GOING 


M VI 

A,QUOTE 

YES, GET CPM DELIMITER 


CALL 

OUTBYT 

OUTPUT IT 


JMP 

COMMENT 

REMAINDER MUST BE COMMENT 


RECOVER 

LAST TWO BYTES (NOT ASC PSEUDO OP) 

REC0V2: 

STA 

TEMP2 

SAVE LAST BYTE 


M VI 

A , ' A ' 

F IRST BYTE WAS AN ’A * 


CALL 

OUTBYT 

OUTPUT IT 


LDA 

TEM P2 

GET LAST BYTE 


JMP 

INSTR2 

CONTINUE NORMALLY 


RECOVER 

LAST 3 BYTES (NOT ASC PSEUDO OP) 

REC0V3: 

STA 

TEMP2 

SAVE LAST BYTE 


LXI 

D,ASOP 

WE KNOW LAST 2 BYTES WERE 'AS 


CALL 

PUTSTRING 

SO OUTPUT THEM 


LDA 

TEM P2 

GET LAST BYTE 

; 

HANDLE 

REMAINDER OF INSTRUCTION FIELD 

INSTR2: 

CALL 

PASS 

OUTPUT REST OF FIELD 


JC 

EOLINE 

;IF END OF LINE 

OPERAND 

M VI 

A, TAB 

PROCESS OPERAND FIELD 


CALL 

OUTBYT 

TAB TO NEXT COLUMN 


CALL 

DELSP 

DELETE LEADING SPACES 


JC 

EOLINE 

IF END OF LINE 

| 

CHECK FOR ’<• SPECIAL OPERATOR 

OPE R 1: 

CPI 

'<• 

LEFT BYTE MASK? 


JNZ 

0PER3 

NO WAY 


CALL 

COUNT 

DECREMENT END OF LINE COUNT 


JZ 

EOLINE 

IF END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CALL 

PASS 

OUTPUT REST OF FIELD 


JC 

EOLINE 

IF PREMATURE END OF LINE 


LXI 

D, LB YT E 

OUTPUT A SHIFT RIGHT EXPR 


CALL 

PUTSTRING 



JMP 

COMMENT 

REMAINDER MUST BE COMMENT 


CHECK FOR •>• SPECIAL OPERATOR 

0PER2: 

CPI 


RIGHT BYTE MASK? 


JNZ 

OPE R 3 

NO WAY 


Number 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 


262 



























CALL 

COUNT 

{DECREMENT LINE COUNT 


JZ 

EOLINE 

;IF END OF LINE 


CALL 

GETBYT 

;GET NEXT BYTE 


CALL 

PASS 

{OUTPUT REST OF FIELD 


JC 

EOLINE 

;IF END OF LINE 


LXI 

D, RBYTE 

;THEN A MASK RIGHT EXP 


CALL 

PUTSTRING 



JMP 

COMMENT 

{REMAINDER MUST BE COMMENT 

J 

HANDLE 

REMAINDER OF OPERAND 

OPE R 3: 

CPI 

QUOTE 

IS IT A QUOTE? 


CZ 

TOGGLE 

YES, TOGGLE STRING FLAG 


CPI 

• .» 

IS IT A PERIOD? 


JZ 

STRING 

YES, CHECK IF PART OF STRING 


CPI 

SPACE 

IS IT A SPACE? 


JNZ 

OPERK 

NO, PROCESS IT 

STRING: 

STA 

TEMP 

SAVE BYTE 


LDA 

FUG 

IS CHAR WITHIN STRING? 


ORA 

A 



JZ 

COMMENT 

;N0, END OF OPERAND FIELD 


LDA 

TEMP 

;YES, GET BACK BYTE 

0PER4: 

CALL 

OUTBYT 

{OUTPUT BYTE 


CALL 

COUNT 

{DECREMENT LINE COUNT 


JZ 

EOLINE 

;IF END OF LINE 


CALL 

GETBYT 

{GET NEXT BYTE 

; 

JMP 

0PER3 

{KEEP GOING 

COMLINE 



PROCESS COMMENT LINE 


M VI 

A , • ; * 

GET A SEMICOLON 


JMP 

CLOOP 

OUTPUT IT 4 REST OF LINE 

COMMENT 



PROCESS COMMENT FIELD 


M VI 

A , TAB 



CALL 

OUTBYT 

TAB TO NEXT COLUMN 


M VI 

A ,' ; • 

GET A SEMICOLON 


CALL 

OUTBYT 

OUTPUT IT 


CALL 

DELSP 

DELETE LEADING SPACES 


JC 

EOLINE 

IF END OF LINE 


CPI 

• ! * 

EXCLAMATION MARK? 


JZ 

CL00P2 

YES, DELETE IT 

CLOOP: 

CALL 

OUTBYT 

NO, OUTPUT IT 

CL00P2: 

CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

EOLINE 

IF END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CPI 

• !’ 

EXCLAMATION MARK? 


JZ 

CL00P2 

YES, DELETE IT 


JMP 

CLOOP 

KEEP GOING 

PREMEND 



PREMATURE END OF LINE 


M VI 

A , CR 

OUTPUT A CARRIAGE RET 


CALL 

OUTBYT 


EOLINE: 

MVI 

A, LF 

NORMAL END OF LINE 


CALL 

OUTBYT 

OUTPUT A LINE FEED 


JMP 

PROCESS 

PROCESS NEXT LINE 

EOFMARK 





MVI 

A, • Z ’-40H 

GET A C PM EOF MARK 


CALL 

OUTBYT 

OUTPUT IT 


RET 


EXIT PROCESS 

TOGGLE: 

PUSH 

PSW 

FUG SET IF STRING IN QUOTES 


LDA 

FUG 

TOGGLE FLAG 


CMA 




STA 

FUG 

THAT’S ALL 


POP 

PSW 



RET 



* 

DELETE 

EXTRA SPACES 


DELSP: 

CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

DELSP2 

IF PREMATURE END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CPI 

SPACE 

SPACE? 


JZ 

DELSP 

YES, DELETE IT 


ORA 

A 

RESET CARRY FUG 


RET 


RETURN WITH BYTE 

DELSP2: 

STC 


SET CARRY FUG FOR EOL 


RET 


RETURN WITH FLAG SET 


OUTPUT 

BYTES UNTIL END OF 

FIELD 

PASS: 

CALL 

OUTBYT 

OUTPUT BYTE 


CALL 

COUNT 

DECREMENT LINE COUNT 


JZ 

PASS 2 

IF PREMATURE END OF LINE 


CALL 

GETBYT 

GET NEXT BYTE 


CPI 

SPACE 

END OF FIELD? 


JNZ 

PASS 

NO, KEEP GOING 


ORA 

A 

RESET CARRY FUG 


RET 


RETURN WITH SPACE 

PASS 2: 

STC 


SET CARRY FLAG FOR EOL 


RET 


RETURN WITH FLAG SET 

COUNT: 

LDA 

EOLC NT 

DECREMENT END OF LINE COUNT 


DC R 

A 



STA 

EOLC NT 

THAT’S ALL 


RET 




PUTSTRING • 

ROUTINE TO OUTPUT A STRING TO DISC » 


PUTSTRING: 

LDAX D ;GET A BYTE 

CPI ’$ ’ ;TERMINATOR? 


P 


RZ 


PUSH 

D 

CALL 

OUTBYT 

POP 

D 

INX 

D 

JMP 

PUTSTRING 


CANNED STRINGS: • 


ASOP: 

DB 

•ASS’ 


DBOP: 

DB 

'DBS' 


RBYTE: 

DB 

' AND 

OFFHS 

LBYTE: 

DB 

’ SHR 

8$’ 


YES, RETURN 
SAVE D&E 
NO, OUTPUT BYTE 
RESTORE DAE 
BUMP POINTER 
KEEP GOING 


STRING TO RECOVER AS STRING 
STRING TO REPLACE ASC OP 
STRING TO REPLACE ">" OP 
STRING TO REPLACE ’’<" OP 


0 U T B Y T 

ROUTINE TO OUTPUT A BYTE 
INPUT: A =B YT E 


OUTBYT: STA 

TEMP 

SAVE BYTE 

OUT 1: LXI 

H , OB UF ♦I 28 


XCHG 


.BUFFER END A DDR IN DE 

LHLD 

OUT PT 

{CURRENT A DDR IN HL 

CALL 

C PHL 

{TEST FOR END OF BUFFER 

JZ 

OUT 2 

YES, WRITE 

LDA 

TEMP 


MOV 

M , A 

STORE DATA BYTE IN BUFFER 

INX 

H 

BUMP BUFFER POINTER 

SHLD 

OUT PT 

SAVE BUFFER POINTER 

ORA 

A 


RET 


EXIT 

OUT 2: LXI 

D, OB UF 

POINT TO OUTPUT BUFFER 

LXI 

H , TB UF 

TEMP BUFFER 

MVI 

B , 128 


CALL 

MOVE 

COPY BUFFERS 

MVI 

C,WRITE 

WRITE FUNCTION 

LXI 

D,DEST 

OUTPUT FCB 

CALL 

B DOS 

ISSUE WRITE 

CPI 

OF F H 


JZ 

ERROR 3 


CPI 

2 


JZ 

ERR0R4 


C PI 

1 


JZ 

ERR0R5 


LXI 

H, OB UF 

RESET POINTER 

SHLD 

OUT PT 


JMP 

OUT 1 

CONTINUE 

{ G E 

T B Y T 

» 

• 

; ROUTINE TO 

READ A BYTE 

* 

; OUTPUT: 

A =B YT E 

• 

GETBYT: LXI 

H, IB UF ♦! 28 


XCHG 


BUFFER END A DDR. IN DE 

LHLD 

INPTR 

CURRENT POINTER IN HL 

CALL 

C PHL 

TEST FOR END OF BUFFER 

JZ 

GETB2 

YES, READ 

GETB1: MOV 

A , M 

GET BYTE 

INX 

H 

BUMP POINTER 

SHLD 

INPTR 

SAVE POINTER 

ORA 

A 

RESET CARRY 

RET 

GETB2: MVI 

C,READ 

READ FUNCTION 

LXI 

D,SOURCE 

FCB ADDRESS 

CALL 

B DOS 

ISSUE READ 

CPI 

0 

ERROR? 

JNZ 

ERR0R2 

YES 

LXI 

D, TBUF 

POINT TO TEMP BUFFER 

LXI 

H , IB UF 

INPUT BUFFER 

MVI 

B , 128 


CALL 

MOVE 

COPY BUFFER 

LXI 

H, IB UF 

RESET BUFFER POINTER 

SHLD 

INPTR 


JMP 

GETB 1 

CONTINUE 

; m 

0 V E 

«« ft 

• 

; ROUTINE TO 

MOVE BLOCKS OF DATA • 

MOVE: LDAX 

D 

GET BYTE 

MOV 

M , A 

STORE BYTE 

INX 

H 


INX 

D 

BUMP POINTERS 

DC R 

B 

DECREMENT COUNT 

JNZ 

MOVE 

LOOP 


RET 


ROUTINE TO COMPARE HL VS DE 


MOV 

A , H 

CMP 

D 

RNZ 


MOV 

A ,L 

CMP 

E 


Continued on page 48 


Page 46 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

263 




































algebra anak 



Another approach to the interchange 
problem uses a swap primitive. It works 
by simply exchanging the smaller segment 
to put it into its proper position and 
then applying the same procedure to the 
remaining segment which itself requires 
an interchange. A C program which does 
this is given below: 


BY DENNIS ALLISON 

MERGE SORT REVISITED 

My old friend, Sylvan Rubin, sent 
on to me a major improvement in the 
nonrecursive merge program published in 
DDJ # 44. Rather than build the merged 
list backwards and then, later, reverse it, 
he builds it in the right order to begin 
with. This cuts the number of assign¬ 
ments per data element from 9.5 to 4.5 
assuming randomly distributed data. He 
also improved the control structure a 
bit to eliminate some tests. All in all 
a much better program. 


fashion. In the real world, here is a trade¬ 
off. Recursive code is usually smaller 
and shares temporary random access 
memory with other disjoint computa¬ 
tions; interactive code is usually longer, 
uses dedicated storage, and runs much 
faster. Which form of algorithm one 
wants to use depends upon the applica¬ 
tion. 

INTERCHANGE AGAIN 

Richard Karp pointed out two other 
solutions to the interchange problem 


int aC803; 

interchange (n,n) int «,n; < 
int i,j f k; 
i * i; 

n * n-n; /• n and « are segment sizes */ 
for<;;) < 

k * <«>n)?n:«; 
if(k»*=0) return; 
swap(i, i+n+n-k, k); 
if(«<n) < 

n *- 

> else < 

i «♦ n; 
n =- n; 


swap < i, j, k ) int i,j f k; < 
register int t; 
while(k—) < 

t * aCi3; ati+O = aC j 3; 
aCj♦♦3 * t; 

> 

> 


/# MERGE algorithm using linked lists. 

/t written in C. 24 Mar 80 Sylvan Rubin» Algorithmic Eng. 


merge <i»J) int irj> -C int t*k»i*$ 

if<aCi3<a[JD) < m=i» i=J» J=m»> 
t=i» k.=t» 
i = 1ink C i 3 J 
while(i1=0) < 

if<aCi3<aCJ3) 

1 ink.Ck.3=i f /# 
k=i » 

i*linkCi3» 


<m=i» ia'J* J=m»> 

link next largest element to tail of 

merged list 


1 inkCk.3=J» /* 
return (t)» 


link remaining list to tail of merged list 


RECURSION VERSUS ITERATION 

Sylvan comments that he doesn’t 
think that we should publish the recur¬ 
sive form of algorithms since their trans¬ 
lation into assembler or BASIC is a non¬ 
trivial task. I don’t completely agree. 
The purpose of this column is to ex¬ 
pose some of the fundamental mecha¬ 
nisms behind algorithmic solutions and to 
gain some appreciation of the aesthetics. 
That goal must involve recursion in some 


presented last time. And I decided I 
should have said something about the 
shift-register version. 

The shift-register version requires m* n 
operations. The idea is to start at the 
shortest segment, pluck out the element 
at the end, move everything over one 
(to the right or the left depending upon 
which end the shortest segment appears) 
stick in the selected element and repeat 
until the interchange is completed. 
Graphically the procedure is 


But the truly elegant solution is this 
one attributed by E.W. Dijkstra to J. 
Ichbiah. One needs an array reversal 
primitive-an easy thing to do with a 
single temporary. The algorithm is best 
seen graphically: 



One first reverses each of the segments 
independently and then reverses the 
entire array. Not as efficient as the group 
theoretic scheme, but it does have a 
pleasing aesthetic quality. 


Number 46 

264 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 










BIT REVERSAL 

There’s never really much call for an 
algorithm to reverse the bits in a word. 
Nonetheless, this algorithm, due to C. 
Strachey [CACM 4:3 961 p. 146] is 
interesting because of its aesthetic beauty. 

To see how it works it’s best to 
pretend we have a double length register 
and write out the bits in the order we 
have them and the order we want them. 
We then write down the shifts required 
to get each bit from where it is to where 
it should be and write down the binary 
representation for that number. We 
then program a select-bits, shift, and 
merge sequence for each power of two, 
thus generating the result. Figure 1 shows 
the whole procedure worked out for a 
16-bit operand. 

A double length register is not neces¬ 
sary. One can do it in place by observing 
that after the selection one can shift 
both operands, one right and the other 
left. Further, one can use the same mask 
to handle the selection. The C program 
below will reverse the bits of a 16- 
bit word. Note that only one more step 
would be needed for a 32-bit word since 
the complexity grows as the logarithm 
of the number of bits. 

There are, of course, several alternative 
ways to accomplish the same task. The 
Continued from page 46 - 

• RET 


p' o' n' m' 1' k' y i‘ h' g' f' e' d' c' b‘ a' a b c d e f g h 1 j k 1 m n o p 

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 shift numbers 

0000000011111111 shift 16 
0000111100001111 shift 8 
0011001100110011 shift 4 
0101010101010101 shift 2 
1111111111111111 shift 1 

a be d e fg hi_j_k_l_mn > o_£ initial position 

1jklm£££abcd£££h^. shift 16 

mno£ijk^lef 2 £ab£d. shift 8 

0£m£kl1j_gh_ef.cdab. Shift 4 

.shift 2 

poTimlkjihgfedcba. shift 1 


Figure 1. Schematic Bit Reversal 


int naskU < 

OxFFFF, 0x5555, 0x3333, OxOFOF, OxOOFF 


rtvtrit! val ) < 

regnter int 
i * val; 
j * 8; k ■ 4; 
while!j) { 

i ■ (<ilMafkCk])«j)l((i»j)JnatkCk]); 
j ■» l; 

k—; 

> 

return!i); 


obvious one of performing the reversal 
a bit at a time is costly to perform in 
place and is Unear in the length of the 


word. A 16-bit word requires 16 opera¬ 
tions to reverse the bits. Anyone knowing 
a good appUcation for bit-reversed data 
won’t suggest the FFT (which leaves 
its results in reverse binary order) since 
there are better ways to reorganize its 
result than direct selection. 

On a byte-oriented processor it might 
be better to have a table of reversed 
bytes and simply look up each byte 
of the number and then reverse the bytes. 
While this approach is also linear in the 
number of bits, it has the advantage of 
being small and efficient of space and 
time. 

<D ; CLOSE FILES A RETURN TO C PM ^ 


W E 0 

F 

IMI 

« 

ROUTINt TO 

FILL UP LAST RECORD • 

WITH CP/M 

EOF MARKS 

ft 

Mil 

rfEOF : LXI 

H , OB UF ♦! 28 

; END OF BUFFER 

XCHG 

LHLD 

OUT PT 

;W HERE WE ARE 

CALL 

C PH L 

; S A M E? 

JZ 

OUTBYT 

;YES, WRITE LAST RECORD 

MVI 

A , • Z ' - 4 OH 

;N0, GET A C PM EOF MARK 

CALL 

OUTBYT 

;OUTPUT IT TO BUFFER 

JMP 

W EOF 

;KEEP GOING 

C L 0 

S E F I L E 

• i 

• 

SUBROUTINE 

TO CLOSE FILES 

• 

ii 

CLOSEFILE: 

MVI 

C.CLOSE 

;CLOSE FUNCTION 

LXI 

D,DEST 


CALL 

B DOS 

;CLOSE DESTINATION FILE 

MVI 

C.CLOSE 

;C LOSE FUNCTION 

LXI 

D,SOURCE 


CALL 

B DOS 

-.CLOSE SOURCE FILE 

RIT 

; ERROR 

HANDLERS * 


ERROR 1: LXI 

D.MSSGl 


JMP 

ERRMSG 


ERR0R2: LXI 

D.MSSG2 


JMP 

ABORT 


fcPROR3: LXI 

D,MSSG3 


JMP 

ERRMSG 


ERROR4: LXI 

D,MSSG4 


JMP 

ABORT 


ERROR5: LXI 

D.MSSG5 


JMP 

ABORT 


ERROR6: LXI 

D.MSSG6 


JMP 

ERRMSG 


ERROR7: LXI 

D.MSSG7 


ERRMSG: CALL 

MESSAGE 


JMP 

FIN 

;R ETUR N TO C PM 

ABORT: CALL 

MESSAGE 



M E S S A C E 

SUBROUTINE TO OUTPUT MESSAGE 


MVI C, PR INT 

CALL B DOS 

RET 


;PRINT FUNCTION 


MSSGO 

DB 

•AlS- 8 to 


DB 

'by Ed Eli 

MSSG1 

DB 

'Source fi 

MSSG2 

D3 

'Read past 

MSSG3 

DB 

'Directory 

MSSG4 

D3 

'Disk full 

MSSG5 

DB 

'Error in 

MSSG6 

DB 

'No source 

MSSG7 

DB 

'No destin 

MSSG8 

DB 

'Conv ertinj 

MSSG9 

DB 

'Done' ,CR, 


DATA 

BUFFERS: • 

TEMP: 

DS 

1 

TEMP2: 

DS 

1 

DELIM 

DS 

1 

FLAG: 

DB 

0 

LOLC NT : 

DB 

0 

DEST: 

DS 

33 

OUTPT : 

DW 

OB UF 

INPTR: 

DW 

IB UF ♦ 1 28 

IB UF : 

DS 

128 

CBUF : 

DS 

128 

OLDSTK: 

DS 

2 


DS 

4 OH 

NEW ST K: 

EOU 

$ 


TEMPORARY SAVE BYTE 
ANOTHER ONE 

ASC DELIMITER SAVE BYTE 
SWITCH FOR QUOTED STRINGS 
END OF LINE COUNT 
DEST FILE FCB 

OUT PUT POINTER 
INPUT POINTER 
INPUT BUFFER 
OUTPUT BUFFER 

OLD STACK POINTER 
;STACK AREA 


Page 48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

265 


























AN IMPROVEMENT TO ZANT’S MODULAR 
PROGRAMMING 


Dear Suzanne: 

The article on modular programming, authored by me and 
published in DDJ #38, contains a program for appending 
Applesoft programs. The published version of the program 
works on tape-oriented systems and on systems using DOS 
3.1, but will not work correctly on later versions of Apple’s 
DOS. 

The problem is caused by DOS 3.2 recalculating the chain 
pointers for Applesoft statements each time a program is 
loaded. The Append program must therefore be modified to 
remove the instructions that perform this same function. A 
listing of the modified program is enclosed. 


Sincerely, 

Robert F. Zant 
Associate Professor of 
Information Systems 

:ASM 

1000 

1010 

1020 

1030 

1040 

1050 

1060 

1070 

1080 

1090 

1100 

1110 

1120 

1130 

1140 

1150 

1160 

1170 

1180 

1190 

0308- 00 1200 

0309- AD 08 03 1210 

030C- DO 24 1220 

030E- EE 08 03 1230 

0311- A5 67 1240 

0313- 8D 04 03 1250 

0316- A5 68 1260 


North Texas State University 
Denton, Texas 96203 


» APPEND FP 

« 

» ROUTINE TO APPEND 
« APPLESOFT PROGRAMS 
« ON THE APPLE II 

K 

« WRITTEN BY: 

* ROBERT F. ZANT 
» 

» 01-07-80 

* 

« ASSEMBLED USING 
* S-C ASSEMBLER II 

« 


BEGINL 

»EQ 

$67 

BEGINH 

.EG 

$68 

SAVEL 

.EG 

$304 

SAVEH 

.EG 

$305 

ft 

.OR 

$308 

FLAG 

.DA 

«*-» 


LDA 

FLAG 


BNE 

SECOND 


INC 

FLAG 


LDA 

BEGINL 


STA 

SAVEL 


LDA 

BEGINH 


0318- 

8D 

05 

03 

1270 


STA 

SAVEH 

031B- 

A0 

00 


1280 

AGAIN 

LDY 

«$00 

031D- 

B1 

67 


1290 


LDA 

(BEGINL).Y 

031F- 

AA 



1300 


TAX 


0320- 

DO 

06 


1310 


BNE 

C0NT 

0322- 

C8 



1320 


INY 


0323- 

B1 

67 


1330 


LDA 

(BEGINL).Y 

0325- 

DO 

04 


1340 


BNE 

CONTI 

0327- 

60 



1350 


RTS 


0328- 

C8 



1360 

C0NT 

INY 


0329- 

B1 

67 


1370 


LDA 

(BEGINL),Y 

032B- 

85 

68 


1380 

CONTI 

STA 

BEGINH 

032D- 

86 

67 


1390 


STX 

BEGINL 

032F- 

4C 

IB 

03 

1400 


JMP 

AGAIN 





1410 

«■ 



0332- 

CE 

08 

03 

1420 

SECOND 

DEC 

FLAG 

0335- 

AD 

04 

03 

1430 


LDA 

SAVEL 

0338- 

85 

67 


1440 


STA 

BEGINL 

033A- 

AD 

05 

03 

1450 


LDA 

SAVEH 

033D- 

85 

68 


1460 


STA 

BEGINH 

033F- 

60 



1470 


RTS 






1480 


,EN 



SYMBOL TABLE 

BEGINL 0067 BEGINH 0068 SAVEL 0304 


SAVEH 0305 
C0NT 0328 


FLAG 0308 
CONTI 032B 


AGAIN 031B 
SECOND 0332 


MAYBE JUST GALACTIC 

Dear Dr. Dobb’s, 

In DDJ # 43, Bud Gramer states that CP/M is “the only true 
universal operating system.” Others have also made this statement. 
Obviously a “universal” operating system must run on (almost) every¬ 
thing. Therefore CP/M (or anything else) will not be a universal 
operating system until there are versions of it for the 6800, 6502, 6809, 
Z-8000, 68000, etc., etc. 

One approach to a really universal operating system would be to 
pick a suitable high-level language such as C or PASCAL, and write 
most of an operating system and the required utility programs in that 
language. For each target computer, a small amount of assembly 
language code would be needed for device drivers and interrupt 
handlers. Most of the system would be the same (or nearly so) for all 
computers. 

While Mr. Gramer is “sick” of hearing about certain non-CP/M 
systems, I am tired of the attitude of much of the microcomputing 
community that the 8080, Z-80, and S-100 bus are the only things 
that exist. 

Sincerely, 5472 Playa Del Rey 

Jim Howell San Jose, CA 95123 


Number 46 
266 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 55 



A FEW THINGS . .. 

Dear Suzanne, 

I would like to inform your readers of an address correction 
necessary for their responses to the article “Some Useful 
Subroutines for a Z-80 Assembler” in DDJ #44. 

I have received a significant response to that article, but 
my mailing address has changed since the article was sub¬ 
mitted. For information concerning the subroutine library, 
or for a copy of it, requests should be sent to: J. W. Carter, 
3538 Deerwood, Memphis, TN 38111. 

I would like to also add another opinion to the “adver¬ 
tising controversy.” I consider it unfortunate that Dr. Dobb’s 
finds it necessary to include advertising in the publication. 
Dr. Dobb’s is one of the few journals in this field with such 
a select, and consequently devoted, audience. With no pretty 
pictures and pie-in-the-sky dreams generated by ad¬ 
vertising, the reader receives only top-quality articles in the 
field. Also authors, knowing a select audience exists are 
encouraged to provide good quality manuscripts. With adver¬ 
tising entering the picture, I see this philosophy decaying; for 
with advertising comes additional profit which is usually 
passed on to the author. I would expect that, with advertising, 
quality authors will tend to send manuscripts to other journals 
which provide fiscal compensation. 

I would rather see you raise the subscription rate and 
include more of the material you have been publishing, than 
see Dr. Dobb’s go the way cf the modem majority. 

Sincerely, Memphis State University 

John W. Carter Memphis, Tennessee 38152 

Computer Systems Technology 



REMARKS AS ENTRY POINTS 

Dear DDJ: 

Bruce Thompson’s letter in DDJ #45 states that jumping 
to a remark in a program is a “serious error in programming 
style,” but he fails to recognize that cramming as much active 
code in a given amount of memory as possible is not the 
only programming consideration. In many cases, readability 
and ease of modification may be more important. 

As a professional programmer, I know that memory is 
usually cheaper than software, and have adopted a style that is 
totally contrary to Mr. Thompson’s. In my programs, remarks 
are defined as entry points either to in-line code or to subrou¬ 
tines. The advantage to this style is twofold: First, since you 
know that a remark is an entry point, you will leave it alone 
and won’t accidentally change it when performing modifica¬ 
tions to the program. You can add more code at the beginning 
of a routine without having to shuffle line numbers. Second, 
it is a tremendous aid in promoting readability to a program. 
When you see the statement GOTO 1000, you can simply 
look at the remark at line 1000 to see what happens when 
you get there without having to wade through the code. 

Not all entry points in my programs are remarks since 
this would be wasteful in trivial cases, but all remarks are entry 
points major logical procedures. Once it is understood that 
this is the case, it adds a great deal of flexibility to the pro¬ 
gram. 

Very Truly Yours, DATASMITH Micro Software Systems 
Burks A. Smith 15501 West 109th St. 

Lenexa, Kansas 66219 


IMPROVEMENTS TO APPLE USER INTERFACE 

Dear Suzanne, 

I was very pleased to see the User Interface to the APPLE II 
Program Renumbering in DDJ #42. 

I found some errors and a possible error. 

The errors: 

1. Line 106 of the code is out of place. It should be between 
lines 102 and 103. 2. At line 432 the S94B0 should be 
94CO. 3. At line 551 on page 50 the code should read 20 
58FC. 

The possible error — it is at least an omission — is at line 
563 and thereafter: the ASCII bytes for the headers. Perhaps 
it is supposed to be obvious that they are not there. But a 
beginner might be very perplexed, and certainly would be 
dispma/ed at not having the program work properly. Below 
is the correct code: 


95 7E 

C5 

CE 







9580 

D4 

C5 

D2 

A0 

CC 

C9 

CE 

C5 

9588 

A0 

CE 

D5 

CD 

C2 

C5 

D2 

A0 

9590 

C4 

C5 

C6 

Cl 

D5 

CC 

D4 

8D 

9598 

A0 

A0 

CE 

C5 

D7 

A0 

D3 

D4 

95A0 

Cl 

D2 

D4 

A0 

AO 

A0 

A0 

AO 

95A8 

A0 

AO 

A0 

A0 

B1 

B0 

B0 

A0 

95B0 

A0 

A0 

A0 

A0 

CE 

C5 

D7 

A0 

95B8 

C9 

CE 

C3 

D2 

C5 

CD 

C5 

CE 

95CO 

D4 

A0 

A0 

A0 

A0 

A0 

B1 

B0 

95C8 

B0 

A0 

A0 

A0 

A0 

A0 

D2 

Cl 

95DO 

CE 

C7 

C5 

A0 

D3 

D4 

Cl 

D2 

95D8 

D4 

A0 

A0 

A0 

A0 

A0 

A0 

A0 

95E0 

A0 

A0 

B0 

A0 

A0 

A0 

A0 

A0 

95E8 

D2 

Cl 

CE 

C7 

C5 

A0 

C5 

CE 

95FO 

C4 

A0 

A0 

A0 

A0 

A0 

A0 

A0 

95F8 

B6 

B5 

B5 

B3 

B5 

A0 

A0 

A0 


A few comments. If you are not going to use the program 
with a disk (because you might not have one, for instance) 
change each of the three bytes in line 549 to EA(NOP). 
If you would like to have different default values for the 
NEW START and NEW INCREMENT change the byte at 
$9424 to the desired value. For example, I wanted my NEW 
START to be Line 10 and my NEW INCREMENT 10 also. 
I changed the value at $9424 to $0A. (I see no way of chang¬ 
ing one of those default values and not the other.) After I 
made that change I then changed the ASCII data for the 
headers so that ‘NEW START 10’ and ‘NEW INCREMENT 
10’ are displayed. 

That’s all. Hope this is helpful . 

Yours, Rt 2 Box50A-l 

Stephen E. Bach-AA4B Scottsville, VA 24590 



Page 56 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 46 

267 



ON DIABLO 

Dear Suzanne: 

The enclosed program is based around a Z-80 USR call 
that calculates the advance necessary for a Diablo printer to 
print a string any desired width. The code has been expanded 
somewhat to make it easier to install on other machines. The 
last line of code could be replaced by a jump to whatever 
location serves the same purpose. If the routine is used as is, 
the defaults are a 72 character line with a 12 point type daisy 
wheel. 


Yours truly 

L. Barker Chicago, IL 


10 ' Variable printing for a Diablo 
20 CLEAR MOO 
30 DEF1NT 1,J 
40 DEFUSR0 = &HA000 

50 W = 41123! Width to be printed (in characters) 

60 FOR 1= 0 TO 176 
70 READ J 

60 POKE 40960 Ul, J 

90 NEXT 

100 INPUT "Print what file (.rXT)";F$ 

110 INPUT "Print file what width ";J 
120 IF J < 20 OR J > 132 GOTO 110 
130 POKE W, J 

140 INPUT "Advance ( = 120/point) ";1 
150 IF 1=10 OH 1=12 

THEN POKE W+1, 1 
ELSE GOTO 140 


loO OPEN "I",1, F$+".TXT" 

170 LINE INPUT #1, A$ 

160 IF 1N5TR(A$,"=£ND") > 0 GOTO 220 
190 IF LEN(Ai) < .75 • J 
THEN LPH1NT A$; 

ELSE A$ = USH0(A$) 


200 LPR1NT 

210 If NOT EOF(1) GOTO 170 
220 CLOSE 
230 END 


240 ' Program loads at 0A000H (40960) 

250 DATA 235, 70, 35, 94, 35, 6o, 33, 0, 0, 34,159,1o0, *4,161,100,213 
260 DATA 58,163,160, 95, 64, 56,164,160,205,1*2,loO, 34,157,lo0,225, 5b 
270 DATA 161,160,184, 40, 77,229, 60, 50,161,160,23/, 91,157,100,205,1*2 
260 DATA 160, 14, *3,175, 24, 5,164, 56, 1,144, 6*. 2*7,106,2*5,2*/,lOo 
290 DATA 235, 23, 13, 32,241, *1,237, 91,159,1o0, *4,159,160,16*,2*/, 62 
300 DATA *5, 56,162,160,235,225,167, 40, 16, 14, 2/,203,105,IbO, 14, *1 
310 DATA 205,165,160, 75,205,1o5,IbO,123, 50,1o2,lO0, 76, *5,205,1o5,loO 
320 DATA 24,17*, 14, 27,205,165,160, 14, *1,203,165,loO, 56,164,160, 60 
330 DATA 79,195,165,160, **, 0, 0,229, 14, 6, 41,22 /, 2*/ , 106,22/, / 


340 

DATA 46, 

6, 25 

, 46, 3,227, 35,22 1 , 13, 32,23*.204,201,144, 03,210 

*50 

DATA 75, 

69,210 

, 72, 10 


*60 

DATA 56, 

0,207,2*0, 2, 40,249,121, 50, 1,20/,201 


370 





380 

’ The last 

data 

Tine is to send register C to the line 

printer. 

390 





400 

• L1NEP: 

LD 

A,(PORT) 


410 

• 

AND 

2 


420 

■ 

JR 

Z.LlNEP 


430 

i 

LD 

A, C 


440 

• 

LD 

(PQHT+1) ,A 


450 


RET 



460 

• URG 

0CF00H ; modify as system 

requires 

4/0 

• PORT: 





A NEW LISP INTERPRETER 


Dear Suzanne: 

This is to announce availability of a new version of the 
LISP interpreter which appeared in DDJ # 30. This program 
is available from me on 8 inch, single density IBM format 
CP/M diskette for $10. 

GCLISP is a version of the Dr. Dobb’s LISP which has 
been modified to run under CP/M (by addition of appro¬ 
priate drivers, has improved behavior when presented with user 
program errors and can collect list garbage when memory is 
exhausted. In addition, the code has been rearranged into a 
slightly more logical format (all variables have been collected 
at the end, data statements done more compactly) and initial¬ 
ization has been made more understandable. Provisions have 
also been made for saving the system after defining new (inter¬ 
preted) functions. 


CP/M features: The interpreter now sets up its own stack. 
There is an assembly time option to use CP/M line buffered 
input. The advantage of line buffered input is that LISP doesn’t 
see the line until carriage return is typed, so the line can be 
corrected during type-in. The assembly also generates an 
equate for PAGSAV which is the number of pages for a CP/M 
save command to allow using DEFINE to create a set of 
functions and constants, then ctrl-C back to CP/M and save 
the result. The interpreter uses the CP/M string type routine 
to send error messages. 

Improved control: In the original interpreter, errors in a 
user program caused the interpreter to abort. In this version, 
most errors result in a message and return to the EVAL- 
QUOTE driver. In addition, EVAL checks for ctrl-D from 
the terminal to abort long computations. The EVALQUOTE 
driver now prompts for input with an underscore. 

The interpreter has one new function, EXIT, of zero 
arguments which returns control to CP/M. 

Sincerely, 1522 Brockton Ave., Apt. 5 

Darrel J. Van Buer Los Angeles, CA 90025 


ELF TINY MONITOR 

Dear Dr. Dobb’s: 

Here’s an Elf Tiny Monitor for the Netronics Elf II that 
has proven to be a big timesaver for me. The Elf II is virtually 
identical to the 1802 based Elf introduced in a series of 
Popular Science articles by RCA’s Joseph Weisbecker starting 
in August 1976. The monitor presented here is an improve¬ 
ment over a similar program in the March 1977 issue because 
it is shorter, performs the same functions and displays memory 
location. I’d like to hear from anyone having a shorter pro¬ 
gram with equal features. 

Load the following program starting at memory location 
00HEX. Then turn off the RUN, LOAD, and Memory 
Protect switches. 


F8 

ID 

AF 

EF 

6C 

30 

1C 

7B 

3F 

08 

6C 

AE 

37 

OC 

8E 

5F 

EF 

64 

2F 

3F 

13 

EE 

C5 

6C 

C4 

64 

30 

OC 

30 


1. To start execution at any memory location press the two 
HEX keys that define the location and turn on the RUN 
switch. The monitor writes into location 1DHEX, so user 
programs must start after this. 

2. To examine memory start execution at location 08HEX 
according to instructions in (1) above, then press and 
release the I key. The memory location (address) will 
be displayed. Press and hold the I key to examine memory 
contents, then release the key to display the next address. 
Continue to press and release the I key to examine succes¬ 
sive memory addresses and contents. 

3. To change memory start execution at location 07HEX and 
follow the same initial sequence as in (2). The Q light will 
come on indicating the memory may be altered. After the 
memory location is displayed press the two HEX keys 
that define the memory contents (data) to be entered 
and press the I key. When the key is released the next 
address will be displayed and the monitor is again ready 
for input data. 

4. To change modes turn off the RUN switch and begin anew. 

Sincerely, 468 Velarde Street 

R.C. Briggs Mountain View, CA 94041 


Number 46 

268 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 57 



THE LOW DOWN ON TOP-DOWN 


Dear Editor: 

The letter by John R. Culleton, Jr. in DDJ #43 claims that 
top-down programming is impossible in PASCAL (in con¬ 
trast to COBOL). I have used PASCAL heavily for five years, 
and I always thought that on my best days I was working in 
a top-down fashion, and quite successfully. The definition of 
“top-down” must need clarifying, so here is mine. 

“Top-down” programming is a method of designing and 
writing programs which proceeds from the most general to the 
most specific aspects of the problem to be solved. Typically, 
the first step will be to write a skeleton program (or a narrative 
outline) of what will be done. Subsequent steps, as many as 
are necessary, provide detailed expansion of things that are 
only outlined or named at a higher (previous) level. The task 
is done when everything has been reduced to a form which can 
be executed by a computer or which can be automatically 
translated to such a form. 

Niklaus Wirth calls this “stepwise refinement” and has 
written two excellent books showing its use with PASCAL. 
It can be used with any language. With none is it impossible 
because it is almost independent of the qualities of the lan¬ 
guage used. One does not program in a language but into 
a language. 

Can Mr. Culleton define “top-down” in a way that makes 
PASCAL unsuitable? And if so, can he defend the usefulness 
of such a definition in the multi-lingual world we all inhabit? 

Sincerely, 6440 Regent St. 

David Rowland Oakland, Calif. 94618 



(Continued from page 13) 

be able to act as a front end processor, which 
will handle all the communications chores for 
a host machine. Once this is running, we can 
see some very powerful and exciting possi¬ 
bilities for distributed processing! 

The protocol currently used is a simple 
“Aloha" type random access system. It has been 
enhanced however and uses carrier sense and 
priority acknowledgments. Since the current pro¬ 
tocol will probably be defunct by the time it is 
published, here is the new version outline: 

The Format 

SYN 

SYN 

SOH 


Destin 

Call 

6 bytes 

Destin 

Node 

2 bytes 

Origin 

Call 

6 


Origin 

Node 

2 


Service 

Flag 

1 

(bit mapped) 

Number 

Flag 

1 

(bit mapped) 

Length 

Byte 

1 

(bit mapped) 

Data 


0 

to 256 max 


Checksum 2 bytes 

The Protocol can almost be derived by 
looking at the format of a packet. It is carrier 
sensed, that is, stations don’t transmit if they 
hear another station on the air. Priority ac¬ 
knowledged, i.e., if a station hears a packet 


and the checksum is correct, it is presumed that 
the destination station also got it correctly 
and that an acknowledgment will be forth¬ 
coming. The transmission of a waiting packet 
is delayed to allow the ack to go by unhinder¬ 
ed. 

Where a station fails to get an ack to a 
transmitted pac, it will try again, up to three 
times. The interval between retries is random 
to avoid two stations continually clobbering 
each other’s pacs. All pacs are preceded by an 
ASCII SYN (synch) byte and the ASCII Start 
of Header characters. The Service flag is used 
to indicate by setting a bit high (1) whether 
the packet is an ack, a repeated pac or ack, 
whether this is a file transfer, and ASCII or 
binary data field, with a couple of bits to spare. 
The bits are arranged as follows in this flag: 

Bit 7 6 4 3 2 1 0 
ARFB ???? 

Where A = Ack 

R = Pac or Ack from the repeater 
F = File transfer in progress 
B = Data contains binary coded info 
? = Spare for future use 

Note: there was a terrific temptation to 
rearrange the flags to read as B A R F, 
but in software the ARFB series was easier. 

The repeat flag is used to prevent a station from 
receiving two packets if he hears both the 
origin station and the destination. The 


computer will respond to and keep the one 
R flagged, and ignore the other. Don’t forget 
the repeater transmitted pac will get there 
after the original since it is store and forward. 
The file flag is used to indicate that the re¬ 
ceiving station should file the packets sequen¬ 
tially and not allow other packets to intrude 
in the file. You can imagine what getting a 
“Hi Bob” pac would do if it was inserted in the 
middle of a program I was receiving. Files are 
also written to disk on the receiving com¬ 
puter. The binary flag is used when a file 
(program etc.) is binary coded as this would 
allow us to apply offset loading etc., to the file. It 
will also allow a program to “come up running” 
on a user’s machine. 

The next flag in the sequence count is used 
to keep packets composing a file in the right 
order. It will also be used eventually to im¬ 
plement a virtual circuit where a certain 
number of pacs will be allowed outstanding 
without acks. This will allow for improved 
throughput with an ACK to NUMBER (X) 
arrangement. The length byte is obvious: it 
simply tells the computer how long the packet 
is. The only restriction is that packets cannot 
have more than 256 bytes in that data field. 
The last two bytes are the checksum which 
is used to establish that the packet has been 
received error free. This is currently done 
in software but we expect to do it in hard¬ 
ware with the Fairchild 9401 CRC generator 
checker chip in the final version. 


Page 58 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E. Menlo Park, CA 94025 


Number 46 

269 





Dr Dobbs (ouRNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


Number 47 


August 1980 


Volume 5, Issue 7 


A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 


ZX65: Simulating a Micro 

Richard M. Kruse 

Clean Starts for COSMAC 1861 Video Output 

Gary H. Price 

Indirect Addressing for the 8080 and Z80 

Anthony Skjellum 

A Z-80 Circuit for the H-8 

Ted T. Stowe 

Harlie: A “No-Programming” Computer 

J. L. Lawrence and Jay Sprenkle 

...and, as always, even more 


271 






ZX65 : Simulating a Micro 


BY RICHARD M. KRUSE 

6221 Woodlow Drive 
Wichita, KS 67220 

ABSTRACT 

This article gives complete details, 
including source code, of an assembly 
language program which functionally 
simulates the operation of a 6502 micro¬ 
processor device using a Z80 based host 
computer system. Under control of 
ZX65, a wide variety of 6502 software 
may be directly executed in any of 
several modes. Useful for 6502 software 
development as well as for its tutorial 
value, ZX65 should prove to be a signifi¬ 
cant addition to the Z80 user’s software 
library. Occupying only 4K Bytes of 
system memory, ZX65 is sufficiently 
flexible to be readily adapted to system 
environments other than the one 
described. 

Having logged many hours of software 
development work on my Z80-based 
system, I recently decided that I was up 
to a particular challenge: using my system 
as a development tool for a totally 
different microprocessor; specifically, the 
6502. This decision, 1 must confess, 
was not altogether based on a burning 
lust for knowledge, but rather on a more 
practical requirement: I had become 
involved in the development of a 6502- 
based device, and had no ready access to 
a 6502 development system. 1 decided 
that a simple cross-assembler wasn’t good 
enough, and set out to write a 6502-to- 
Z80 object code translator/simulator/ 
interpreter. 

The program described here, which I 
have dubbed ZX65, is the result of my 
efforts to generate a software package to 
perform this task. It is useful not only for 
the intended purpose of software 
development, but also for the rewarding 
experience of exploring a whole new 
field of good software written for a 
processor other than one’s own. 

ZX65 operates as an interpretive 
simulator; that is, a simulated 6502 CPU 
is maintained in system memory, and 
each encountered 6502 instruction is 


decoded and processed interpreter- 
fashion to properly act upon the simula¬ 
ted CPU registers. The entire package 
resides in just over 4K Bytes of high 
system memory, leaving the remaining 
portion, including the all-important (for 
6502) base page, free for program and 
data storage. Note that CP/M serves only 
as a loader and is not used thereafter. In 
fact, while the program loads normally 
into CP/M’s Transient Program Area, it 
immediately relocates itself into high 
memory, overlaying both the CCP and 
the BDOS portions of CP/M. The user 
I/O linkages (CBIOS), however, remain 
intact and are used by the package to 
perform disk and console functions. The 
functions which must be provided by the 
system are a subset of those required by 
CP/M and should thus be readily avail¬ 
able. These functions are all accessed via a 
jump table within the interpreter and 
thus can be readily changed to accom¬ 
modate different system requirements 
(See Table 1). Parameters must be passed 
to the drivers in register “C” (register 
pair “BC” for item six) and data, if any, 
is returned in the accumulator. 

ZX65 is referred to as a package since 
it includes three distinct function groups. 
The first and largest is the interpreter/ 
simulator itself. The second group is an 
elementary monitor providing the func¬ 
tions of memory examine and modify. 
The third group consists of a self- 
contained, elementary disk operating 
system (DOS) (Note: ZX65 files are not 
CP/M compatible). The normal configura¬ 
tion assumes a two-drive system, with 
the system diskette on drive A, and all 
internal disk access routed to drive B 
(Modification for a single drive system 
could easily be done, requiring the user 
to switch diskettes after the package is 
loaded). The package is written in 
standard Zilog/Mostek source code and 
is quite heavily commented. Much use 
is made of the Z80’s special instructions 
and index registers, and operation on an 
8080 is definitely not possible without 
extensive modification. Although the 
commented listing should guide you 
through the program’s operation without 
too much trouble, a brief description of 
the interpreter portion is in order. A 
study of the small but powerful instruc¬ 
tion set of the 6502 will reveal certain 


patterns in the op codes, as also occurs 
with most other processors. The eight 
“BRANCH ON CONDITION” codes, for 
example, all have zero as a low-order 
nybble, while the high-order portion is 
always an odd value. 

Another pattern, not so obvious, is 
that every instruction having an odd- 
valued op code uses multiple addressing 
modes. These and other such patterns are 
exploited by the program. Even so, much 
of the code is devoted solely to decoding 
the op code and transferring control to 
the proper instruction processor. The 
code beginning at “STEP” (line 241) 
performs the initial decoding, and fully 
decodes certain instructions such as 
“RTI”, “JMP”, and a few others. In most 
cases, decoding proceeds to a point where 
the instruction is known to be part of a 
group, such as the branch group described 
above. In these cases, look-up tables are 
used, but not always in the same way. 
The branch group and the flag set/reset 
group, for example, derive mask patterns 
from the tables which are used for test¬ 
ing, setting, or resetting the condition 
flags. 

In the case of multiple addressing 
mode instructions, however, the tables 
serve an entirely different purpose. The 
table contents are, in these instances, 
decoded into addresses for indirect 
jumps; first to the addressing mode 
processors, and then to the actual instruc¬ 
tion processors. Each processor performs 
its instruction as required. The “ADC” 
instruction, as an example, causes a byte 
of data to be fetched from memory or 
from the object code, depending on the 
addressing mode. After setting the Z80 
carry flag to match the simulated 6502 
carry flag, this data byte is added to the 
value currently in the simulated accumu¬ 
lator, and the result is stored there. The 
simulated carry flag is then updated to 
again match the Z80 carry, and the 
simulated sign, overflow, and zero flags 
are set or reset according to the results 
in the accumulator (In this case, the over¬ 
flow flag is set or reset according to a 
logical exclusive “OR” of bits six and 
seven). Considerable care has been given 
to treatment of the flags, since Z80 flags 
and their 6502 namesakes do not always 
have the same meaning (Case in point: 
the 6502 carry flag assumes a logical 


Page 4 

272 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 



“NOT” BORROW meaning during 
subtract and compare operations, while 
the Z80 and most other common pro¬ 
cessors invert the carry flag internally 
during these operations so that it repre¬ 
sents a “TRUE” BORROW; other flag 
differences, for the most part, are more 
subtle). 

Finally, each individual processor is 
responsible for exiting with codes for the 
mnemonic, the addressing mode, and the 
number of bytes occupied by the instruc¬ 
tion available for use by the “DISPLAY” 
routine (line 173) to index into yet 
another set of tables and retrieve the 
ASCII messages for mnemonic and 
addressing modes. Upon exiting the 
instruction processors, the value stored in 
“NEXT PROGRAM COUNTER” is up¬ 
dated, and control is passed back to the 
COMMAND section where the operating 
mode in effect determines whether to 
display the updated CPU contents, and 
whether or not to continue execution 
with the next instruction. 

Several distinct operating modes are 
available, defined briefly as follows: 

Single-Step Mode: One instruction is 
decoded and executed. The console 
then displays the address of the instruc¬ 
tion just executed (Current Program 
Counter), the decoded instruction (Mne¬ 
monic and Operand), the state of all CPU 
registers, and the address of the next 
instruction to be executed (Next Program 
Counter). Control is then returned to 
the user. 

Multi-Step Trace Mode: The user speci¬ 
fies up to 255 instructions to be executed 
with the results displayed as above 
following each step. This occurs at the 
rate of approximately two instructions 
per second. Control is returned to the 
user after the required number of steps 
have been executed and displayed. 

Run-to-Breakpoint Mode: Instruc¬ 
tions are executed without display up to 
and including the user-specified break¬ 
point. CPU registers are then displayed 
as above and control is returned to the 
user. 

Free-Run Mode: Instructions are ex¬ 
ecuted with no display and no break¬ 
points. The console keyboard, however, 
is monitored, and CPU contents are 
displayed as above and control is returned 
to the user at any point upon console 
input. 

The user may examine and modify 
any or all CPU registers, including the 
program counter, at any time that he 


has control, without otherwise disturb¬ 
ing any operation in progress. 

The 6502 “BRK” instruction (soft¬ 
ware interrupt) is handled through a 
vector location, just as in a normal 
system. Optionally, however, the BRK 
instruction may be used (and is initial¬ 
ized) to return control to the user in the 
same manner as the breakpoint mode des¬ 
cribed above. The BRK instruction and 
breakpoint mode operate independently, 
and both may be used in the same pro¬ 
gram. Additionally, up to five different 
“user” subroutines may be called for 
transfer of control to Z80 routines 
(such as console I/O). These are in¬ 
voked by executing either a “JMP” or 
“JSR” instruction to addresses 0000, 
0001, 0002, 0003, and 0004 (HEX). 
Control is passed via a jump table located 
within the intepreter, which the user 
may load with Z80 “JP” mstructions 
to the desired subroutines. The sub¬ 
routines must be terminated in the nor¬ 
mal Z80 fashion by one of the “RET” 
instructions. Note that the first two 
entries in the table (JMP or JSR 0000, 
0001 HEX) are initialized as console 
input and output via the 6502 accumu¬ 
lator. Three parameters may be passed 
to and from all user subroutines, as 
outlined in Table 2. Table 3 lists the 
locations of the BRK vector and the user 
subroutine jump table. 

Although the interpreter is quite vers¬ 
atile and all 6502 mstructions are handled 
properly, there are some limitations to 
its use. Perhaps the most important of 
these is that, even in the “free-run” 
mode, execution is quite slow compared 
to an actual 6502 running at normal 
clock speeds. No attempt has been 
made to correlate execution times with 
normal 6502 clock periods (this may, 
in fact, be impossible due to the way 
in which the system handles multiple ad¬ 
dressing modes). Therefore, programs 
incorporating software timing loops will 
not execute properly. Also, since the pac- 
age was intended for software develop¬ 
ment, hardware interrupts are not sup¬ 
ported, and only a limited amount of 
hardware interfacing can be performed 
through the “user” subroutine calls. 

Two program listings are included 
here. One, “ZXLD” is located at the end 
of this article. Its function is to boot 
the main program from the CP/M Tran¬ 
sient Program Area to high memory. 
The other listing is the interpreter itself, 
assembled to reside from 6F00 to 7DFF 
(HEX) in a 32K system. 


Note that this leaves 512 bytes, 
normally containing CBIOS, unaffected. 
The program is not relocatable, so that 
in order to run in a different memory 
configuration, it will be necessary to 
reassemble the source with a new value 
in the “SIZE EQU XX” statement. 
All other addresses are derived from this 
value. If the object code is to be manu¬ 
ally loaded for the 32K system then 
“ZXLD” must be loaded first, starting 
at 0100 (HEX). Then start loading 
ZX65 at 0110 (HEX), continuing until 
the end. Finally, use the CP/M “SAVE” 
command (SAVE 15 ZX65.COM) to 
write the object code to disk. The pack¬ 
age can now be invoked by answering 
“ZX65” to the CP/M prompt. If you 
are reassembling the package, then you 
should also reassemble the ZXLD routine 
(modified for your system) so that you 
have a .HEX file for each module. Then 
load the package using DDT as follows: 


DDT ZXLD.HEX 
IZX65 .HEX 
Rdisp 

Where “disp” is the load offset value 
required to load the object code from the 
.HEX file at a different address than 
that specified. (DDT will calculate 
“disp” if you type “HI 10, ssss”, where 
“ssss” is the actual starting address of 
your program. DDT will respond with 
the sum and difference of the two values, 
and the difference will be the required 
value “disp”.) Finally, save the object 
code as directed above for manual load¬ 
ing. 

To run the program, place the disk 
with ZX65 .COM on drive A (this disk 
should also have a copy of CP/M so that 
the system can be restarted, if necessary, 
without changing disks). Place the ZX65 
data disk on drive B. Start CP/M and in¬ 
voke ZX65 by answering “ZX65” to the 
CP/M input prompt. The system will 
prompt you with a header and a “ > ” 
symbol. You are now in the command 
mode, and typing one of the command 
codes (see Table 4) will cause the appro¬ 
priate action to occur. Note that if you 
are using a disk not previously used for 
ZX65 on the drive B, you will be unable 
to use the ZX65 DOS functions until 
you have initialized the disk. This is done 
simply by typing “I”, at which point the 
system will ask you to verify this request 
with a “Y” or “N”. The reason for this 


Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

273 



(note this well) is that the “I” command 
clears and initializes the directory on disk 
B. This is the equivalent of the CP/M 
command “ERA *.*” and must be 
used with caution. 

For those unwilling to type in a 4K 
Byte program by hand, I will make the 
package available on a standard 8 inch 
IBM format, single side, single density 
diskette (Sorry, I can’t handle any other 
format!) at a nominal charge of $15 
to cover time and material. Write to me 
and specify your system memory size. 
I will send a diskette containing both 
source and object files assembled to re¬ 
side in high memory as described above, 
as well as a copy of ZXLD. A command 
summary, operating hints, and other 
general information will be included on 
the disk. 

Finally, although this program has 
been rather exhaustively tested with a 
variety of 6502 software (both simple 
and sophisticated) I cannot guarantee 
it bug-free. I have included no copyright 
notices of any kind, and I hope users will 
feel free to copy, add, delete, and im¬ 
prove at will. (I would like to hear 
of any major modifications... I may 
want to include them myself!) As stated 
at the outset, the package was developed 
as a side benefit of another project, not 
as a money maker, and if anyone else 
finds it useful, so much the better. 

Acknowledgments: 


CP/M is a registered trademark of 
Digital Research, Pacific Grove, CA. 

While not specifically mentioned in 
the text, I have relied heavily on the 
information contained in the book 
“6502 Assembly Language Program¬ 
ming” by Lance A. Leventhal (Os¬ 
borne/McGrow-Hill Inc., 1979). 


Function Address 

1. Test console input status 7A2EH 

2. Get single character from console 7A2BH 

3. Send single character to console 7A28H 

4. Select disk drive (A or B) 7A34H 


5. Home R/W head of selected drive 7A31H 

6. Set disk transfer buffer address 7A3DH 

7. Set sector number for disk access 7A37H 

8. Set track number for disk access 7A3AH 

9. Read one sector from selected 

drive 7A40H 

10. Write one sector to selected drive 7A43H 

Table 1: Functions which ZX65 requires of 
the host system, and their locations within 
the interpreter. 


6502 Register Passed as 

Accumulator 

X Index 

Y Index 

Table 2: 6502/Z80 Parameter 
subroutines. 

Z80 Register 
Accumulator 

B Register 

C Register 

passing for user 

_ 

Description 

Address of vector or 


jump instruction 

BRK Vector 

7A55H 


User 0 

7A46H 


User 1 

7A49H 


User 2 

7A4CH 


User 3 

7A4FH 


User 4 

7A52H 


Table 3: Locations for ‘BRK’ 
jump table. 

vector and user 


Command Function 

C CPU register display and modify. 

D Directory display of ZX6S files 

on disk B. 

Format: FILNAM.TYP 
LOAD ADDRESS # RECORDS 
E Examine a block of memory. 

System will prompt for starting 
address and number of bytes. 


G Go to 6502 program per Current 

Program Counter and execute 
without display (free-run). 

I Initialize a fresh disk on drive B. 

(Must be formatted.) System will 
prompt for verification. 

K Kill a ZX6S file on drive B. Simi¬ 

lar to CP/M ERA. System will 
prompt for file name. 

L Load a ZX65 file from disk B. 

System will prompt for file name. 

M Memory substitution. View 

sequential memory locations and 
update if desired. System will 
prompt for address. Mode will 
continue in effect until a ‘. ’ 
(period) is typed. 

R Load and run a ZX65 file from 

disk B, starting at the address 
specified in the directory. (Must 
be an executable 6502 program.) 
System will prompt for file name. 

S Save a ZX6S file on disk B. 

System will prompt for file name, 
starting address, and number of 
bytes. 

T Trace several 6502 instructions 

with display following each step. 
System will prompt for desired 
number of steps. 

SPACE Single-step command. System 

will execute one 6502 instruction, 
display the results, and stop. 


Table 4: A command summary for 
ZX65 ( in alphabetical order). 


LISTING 






CD 


CL 








z 




O 




LU 


b- 












CD 



z 

LU 









<1 




«X 




b- 

z 

ID 












CJ 



<L 

r-J 

Ll 


















O 















X 

►—« 









CL 




z 

CO 



b- 














CD 



o 

CO 

b- 


LU 






<L 




3 

O 




CO 

CO 





CO 






LlI 

IL 





<r 


S 






LU 



X 

CL 




CL 

z 

z 





•D 






CO 

LU 



o 


x 







_1 



LU 


CU 



z 

© 

o 





IU 


cr. 




ID 

CO 



F- 

CL 

LL 


Lj 






CJ 



b- 

X 

CJ 




CJ 

cj 




CL 

CL 

CL 

o 




CL 

Hi 




<_• 

Lj 


LU 









CO 

LU 










CD 

O 

O 

i— 









Ll 

Ll 


8 






■— 1 



> 


X 

CJ 

1- 

X 

X 

X 


LU 

1-' 

1- 

a 

b- 

<) 





CL 



X 









b- 



CO 

X CO 

LU 

<L 


LU 

LU 

LU 


> 

<1 

CJ 

■a 

CJ 

LU 




x 

LJ 



LU 

LU 

CL 


l L 










<1 > 






F- 

LU 

LC 

LC 

LU 


111 

CO 




Of 

Ll 



L— 

Hi 

LU 


LL 






CL 



X 

CL Of 

CO 

CO 

X 

Of 

CO 

CO 

X 

a 

b- 

CO 

CL 

CO 





CL O 




CO 

-J 

LL 








LU 



V* 


> 


LL 

> 

> 

>- 

5 




UJ 


<L 




i—i 


LU 


>■ 

<1 

LJ 


CD 






. J 



LL 


CO 

X 

3 

CM 

CO 

CO 

X 

b- 



Ll. 

<x 






LL 



CD 

> 

CL 


Z 






CU 



o 


LU 






i j 

(J 

CJ 

X 


UJ 




x 

LU 

<1 




LL 








X 




3 



X 



b- 

> 

LU 

UJ 

LU 


a 






□ 

i- 



LU 



3 






LU 




Cl 1- 

to 

CO 

N 

CO 

0> 

CD 


-J 

_J 

_l 


<x 





O CL 

X 



IN 


Z 

o 

LJ 






CO 




O CJ 

o 

> 

a 

o 

o 

o 

CL 

IU 

LU 

UJ 

IU 

LU 

LL 




CO CJ 

LU 

LU 


CO 

<1 



-J 






CO 



» 

f- <r 

X 

cO 

CJ 

X 

X 

X 

a 

CO 

CO 

lO 

U) 

CL 

3 




"V 


LL 






J 






























































X 

V 




Cl 



Li. 



























1- 

Cl 

CO 


CL 

Ci 


CL 








a 





















C.J 

_J 


CD 

LL 

s 

LU 

LU 






X 

-j 



<4- X 

















CD 


_J 


Ll 

U. 

-1 

X 






b- 

LU 



CN O 

X 





X 

T 

X 

X 

X 

X 

X 

X 




Z 

lu 

<L 



IL 

LJ 

Cu 

f- 










o o 

o 





*. 3 

CU 

UJ 

LU 




c 





o 

CJ 


lj 

<1 

cj 

X 







CD 

li_ 




o 


CO 

-0 

o 

o 




IN 

CN 

IN 

CN 




O CD 




LU 



LU 

> 






LU 





CN 




+ 

+ 

+ 










CL Z> 

-I 



_1 

1— 

LU 

CO 

LU 






Of 

Q 



LU 1 

1 








F- 




b- 




CJ 

_] 

V 


lU 

CL 

CJ 

CO 






X 

ID 

Z 



r-J ll 

Q 


CO 

CO 

CD 

CO 

CO 

CO 

CD 

0*' 

• 0 

CO 

CD 




— CO 

<1 



i_ 

LU 

LL 

<r 

O 





o 

<1 

<1 



—• O 

o 


o 

o 

O 

o 

o 

o 

o 

CD 

O 

CD 

CD 








LU 

CM 

—I 


LU 





CJ 

CJ 

LL 



CO 1- 

b- 


X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 




LU 

LU 



0) 

Z 

LJ 

o 

i—i 

X 






LU 




















<r h- 

□ 

Z 




CD 

CD 

<X 

LU 




in 

CL 

0. 



CO Of 

CD 

b- 

CO 

CO 

CO 

CO 

C D 

CO 

CO 

CO 

CO 

CO 

CO 


fO 


CD 

<1 



<i 



rvi 

LJ 

-L 




« 

O 

o 



LU LU 

LU 

CD LU 

LU 

LU 

LU 

LU 

LU 

LU 

LU 

LU LU 

LU 

CO 







CO 


LU 

CO 






X 

b- 



in 

CL CL 

CL 

O 

CL 

CL 

LL 

LL 

LL 

iL 

LlC 

CL 

CL 

CL 

CL 


LL. 


z CO 

LL 

ju' 


LU 


LJ 

X 



r-u 

<T 

LU 


CO 



X 












CD 



LU 

o> 



I'J 

-J 

LU 

LU 

-J 

LU 




or 

X 



















1- Q 

LL 





iXl 

.J 

CD 

X 

X 



in 






















<E LU 


a 


z 

CO 

X 

<r 




























_J CD 

O 



o 


LU 

CO 

> 

CO 

in 

o 
























_< <1 

1- 

X 



CL 

CO 


<1 


>0 



LU 






















x cu 


LJ 


CO 

LU 

CM 


X 

b- 

X 

IN 


> 





ZD ZD 

ID 

ZD 

ID 

ID 

Hi 

Hi 

H 

ZD 


ZD 



—1 




— i 

LJ 

•— 1 


LT 

-L 

<1 

d 


Q 


O 

o 

<L 

CO 

3 


G 

G CJ 

CJ 

G 

Q> 

a 

G 

G 

G 

G 

G 

G 

G 

G 

G 

CL 

Q 

G 


LU 

X 


LU 




X 

LJ 


LL 

o 

CO 

IU 

O 


LU 

lU LU 

LU 

LU 

LU 

LU 

LU 

LU 

LU 

LU 

LU 

LU 

UJ 

LU 

LU 




00 

Z 

3 


> 

O 

LU 


<a 



























r-J 

CD 




i 

CL 

CD 

CL 



























in 


n> 


CO 



CD 







CL 









1- 


> 


CJ 







-U CL 

CD 

i L 




Q 

£ 

Cl 






LU 

LU 






X 


Z 

z> 


ir 

cr 

UJ 

Hi 


LU 




x O 

LU 

-L 


X 

O 

i 

i£ 






x 

> 


LU 

LU 



CL 

CO 


o 

LU 

a 

»- 

0) 

LU 

a 

b- 




t-sl li_ 

LJ 



y- 



LL 







O 



CL CO 

CO 

CO 

3 

z 

z 

z 

X 





<r 






















CO 

O <X 

o 

> 

O 

8 

o 

CJ 

o 

LU 

LU 

LU 

UJ 

LU 

CL 




• CN CO 

in 

o 


00 

&• 

O -i 

CN 

CO 

<3- 

in 

<i 

oo 

■>. 

o 


IN 

CO <4- 

in 

o 


GO 

o 

o 


CN 

CD 


in 


|x 

0D CK 

O 


O O O O 

o 

o 

o 

O 

O 









IN 

IN 

IN 

CN CN 

IN 

CN 

IN 

(N 

IN 

CO 

ro 

CO 

CO 

10 

•v, 

CO 

CO 

CO CO 



o o o o 

o 

o 

o o o 

88 

o 

o 

O o 

o 

o o 

o 

O 

O 

O 

O O 

o 

O 

o 

o 

O 

o 

8 

<p 

O 

o 

o 

o 

o 

O O 

O 

O 

o o o o 

o 

o 

o 

O 

o 

o 

o 

o o 

o 

o o 

o 

O 

O 

O 

O O 

o 

O 

o 

o 

O 

o 

o 

O 

o 

o 

o 

o 

O O 

O 

O 


Ui 


O 

O 

O 

O 

o 

CO 

sD 

o- 

CJ 

CO 

LU 

UJ 

_ 


fx 

<1 

o 


C4 

O 

O 

O 

o 

o 

o 

o 

o 




CN 

CN 

C-4 

CN 

o 

O CO 

O 

O 

U_ 

UJ 

UJ 

LU 

LU 

LU 

LU 

UJ 

UJ 

LU 

LU 

IU 

LU 

LU 

Ll 

O O 

O 

00 

-O' 


fx 

F- 

r*- 



r-'- 





F- 

r^- 

JD 

Ll Ll 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

A 

-O >0 


Page 6 

274 


Dr Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 







Cl LU 


CO Z 

O UJ o 

Q t- CJ 


X- 

1 - o» 

Z O CL 

O 3 

U UJ 

Cl. CL “D 

cc 

1 - O 

Z Ul 

0 X 

UJ O 

<1 3 

CD h- li- 

z 

<x 

h U. UJ 

X> LL 

Ct: CJ — 


►— z 

CO z 

0 

0 - t- 

z 

<f> 

^ 0 

CL 

1 - 1 - 0 . 

Ul •— 

UJ t— 

<L O Z 

<L Cl. 

z 1 - Z X 

0 

CL Z 

Ul 

UJ CO 

— x 0 

<x t— 


O X u 

J ►-« 

CL ill CL CL 

0 . X 

O CL 

Cl CJ *—« 

O Q 

CL. Z CL Cl. 

co CL 

Q 0 - 


UJ 

LU 

CD 

CD 

CD 

UJ UJ 

z 

Z 

CL CL 

CO <x 

<x 

c- 

1 - X 

X 

1- X 

z 0 

CJ 

X 

UJ 


LU U 

h- CL 

0 

Z *- 

z 0 

z 


0 u 


O Z 

CJ 

II 

1 - ►- 

t— 


<r 

t- cl 

UJ 

1 - CD 

z X 

CJ 

z <r 

— 0 

<1 


CL CL 

LL 

0 0 

Cl Cl 

co 

0 . Ci 


a i 

CO 

CJ CJ - i 

ca <5 <x cj ; 


— UJ CO 

i ^ q: t- 

<r CD z 

iuo_ ~ —« 

Ld Ul -I 

lu l— LlI - rvj 

' — <f> a <r a z 


*—• Q_It— CL- 

—» - UJ CL CO 03 CO 

N t- O) CO - o 

<XUZ(/)Q^nO 


UJ + + 

CC Ld * UJ CL ~ 

** _ 9 O I Ci Q o 

J t - 1 <r cl q a cd - <x +kcii 

>■ u. uj z a: cc uj ^ uj x>- cl \ 

Z _J CJ UX-O— 3 Z 3 tt:<JX U. >£| M m 2; 3 

*-• u_ j .z >hot-<ia. <iojz^hOh 

co co uj xa:>cciiiirccLu _ z >■ . cd cd - cd Ld uj 

jd l-J H; M (jM|lQCLLL 0 rNj VM tQ(jQ_ujQ.ilO 


31 —J _J —I J I 

CO _l _J _l _J _J 

D<rQ<iQ<i<r<i(rDQQ l 

HuJOJOOOIJJJi 


coa. O’HNCOtlD'ONCOO. 0 -<CN(»)' 
— CNCN CNCNCNCNCNCNCNCNCOOOOOCOl 

OOOOOOOOOOOOOOOO- 


Ncoo'O-cNco-tirj-oNODao-csm-tin^Ni 

icowco^^-tt-t-ti-^-t-tininininioininini 

0000000 oooooooooooooo- 


Q O H N CO in -O 
CO O' O'- O- O- O- o 

U-U.U-U-U.U_U. 

-o -o -o -0 -o -o -o 


— O' O CO O CD O <X 

co r^- ir- h- uo h- . r^ 

^ o. co co >0 co o in >0 E* uj r* co 

cn o >0 in o in o oo^^cnujo 

Cl Q Q U Cl 00 dODCQOQCOQiXiCO 
U. OOUJU UJ N CQMNmfMU-UM^ 

COOU-'N'OOQUIU.’-»(NCOinCO<EQU. 
O O -O' <L <t <X <X <T <Z CO CO CO CO CO CO 03 03 
U. U_U_U-U_U_U_U_U_U_U-U_U_LlU_U-U_ 

-O ' 0-0 -O'O'O'O'O-O-G'G-G'O-O-C'O'O 


<x <x <r <x 

t-*- r'-h- 

■> <1 O O- O O -sf |_I O O O O O O- o 
NCN-ONSN >000 NNONNN O 

i rl o 9 £< o co <r co m u. cj uj o o co co co co in 
uj^cNijDincQin-ooincNO'tcoKcQin'OONMUJ 
QQQuuGQQCOQC^iQQQQuuCOQQO 
QOU.UUJOOUNUIU.OOOQUUONOQ-H 

UJ O CO N d UJ -1 N a. Q - CO >0 O- U lL W in N d u 
uQDQQQUJUJUJUJUJU.U.U.U.Ij.U .00000 
4 rU-U_U_U_LuU_U_U_U_U_U-U-U-U-U.U.OOOOO 
•O-O'O'C'^'O'O'O'O-O'O'O'O'O-O'O'OSNNNN 






CD 

CJ 




z 

X 



(ft 





X 



Cl 

<L 




►—« 

a. 


z 






CD 

co 



t— 




0 

0 



*6 


Ul 



Cl 



Z 

CO 




0 - 



> 



rvi 




> 

CL 






V 

> 

O 

«I 

CL 





z 

CL h- 

UJ 


z 

Q 

> 


<r 

u 

CL 

_l 

y- 


X 



X 

Q — 

Cl 

t- 

0 

z 

CL 

> 

UJ 


Z 

(L 

co 


<r 


cr 

ct 


<r 

z 


-a: 

O 

QC 

ct 

0 


0^ 

z 



LU 

Ul 


LU t- 

UJ 


lC 

X 

X 

O X 

CO 

0 

X 




y- 

co 

a 

Cl 

t— M 

X 

0 

Cl 

X 

UJ 

X X 


X 

0 

a 

CO 

CL 


<x 

<r 

z 

<1 z 


Cl 

0 

0 

X 

Ul »- 

0 


a: 


UJ 0 


z 

CL 

0 

<T 

> -« 

y- 


<1 

0 


x co 

I- 

> 

u 

UJ 

z 0 

a 


LU 

_j 



z 

> 



X 



_l 


CJ 

0 





O 

^ a 


Z 

t— 

t— 

<L 

CO CL 

z 

LL 

z 

<T 

LC 

CO 

CO 

CO 

00 

<r 

CJ z 

CL 

<r 

UJ 

LU 

X 

x 0 

—) 

OO 

X 

CL 

x O 

0 

0 

O 

0 

0 

<X <L 

CL 


cc 

CD 

LU 

co u 

CL 

O 

CL 

y- 

UJ u 

0 

a 

Cl 

Cl 

_i 


1 cd 1 cl 

CL X X UJ Cl t- 

x <r co cc iii co z 

1 u x cj x x > cl cd x 

JOt—' UJ N CO - S CO ' Ld '■ LC 

IJCCXUIUJ - X - X co *0 - CD - I 
: X O 0 - CD ' r^j n •—1 r-si'. ru \ r-J 


I Ld 

UJ u 

ZLLlXt— JQOUI 
OO •— —- J <E CD > 

x co o z ►— o cd <r - 

Ul - '• 0 .'- H-*s id \ Js J'. co 

-XO - *- - J - Ld -CO - 


I I— cc o 

: x 3 a 

• t— t— Ul - 

■ Cd ui - rvi . 

• Cl CD <X Z <T 


X J J J _J 

CO J J J _| 

Q_'<I<I<rilLLa.llULL(IlIU-LLLLCLLCLLlIQLLCLCLU.lICLli.CLQ.U.u.lIUClLC 
JlOOUUlUDJOOOlCjDODUDJUDUDODODUDODJOD 


X 

I Oh w 

u UJ UJ D 
J Q LC LL 


«3- in -0 00 O ' 

« 3 - I 

o o o o o o • 

000000- 


•- — — 

CN CO in N CO O'- O *- CN CO -t in -O N 00 O' O -H CO <t in •£! NCO O- O -- ‘N CO -t in <£' N |> o 
inininininininin*o-c-' 0 ' 0 > 0 ' 0 >c>^-o-or^r^h.rvh-r^r^r^hvr^ooooocico co *'o o:- oo >x« oc- a-- 
0000000000000000000000000000000000000 o o 
000000000000000000000000000000000000000 


— CN CO - 3 - 

O - i>- O'- O'- 

o o o o 
o o o o 


in -o h- co o o 

O- O' O' O' o- o - 

o o o o o — 

O O O O O © < 


<x <x -o -> o- 

N N -O N N 

« 4 - — O' Ll 

CO 01 CN Cl 

U LI U U Cl 

OCJU.CC- O 


u O' O' <1 in -o a u_ u <x -o r—. r-. -o -o r-v <t 

-o r- r- r^- r^in -o *o 'Cih-r^-r^-r^r^-r^-r- 

in u.O"Oino'Qca^N«i'nujNr-«tQO' 0 ’H^coO'CQffl>ooinNajc , icou.oj -l- 
—- «it in ^ uj * 4 - «*- cn ^ -ci <*- o in cs c>i co <n ««■ <x o co u. ud uj ud —- co ^ j <n 

H|OQQQUJ<IUJ<[QUJiJ5UJ<IUJ<IUJC0UJ00QUJCUJ4:UJCUJ<IUJ<IUJ<IUJQ0i 
CMUJOOOUOUOQU-C'JU-OUOU-CMU.CMCiU.OU-OU.OU-OUOU.OO O — 

in000'OU.N^N0'UO(M^«0 0'CQUJON«t'0<IOU.-t'00'CaUJOC , )y. C0«IQ 

^ ^ ^ ^4 »_4 f\j c^j 04 c-j <n co co co co co co co *t’* 3 ‘« 3 ’^'i _ * 4 '« 4 -ininininu"'in-o« -c- -c- -o >c- 
U.U-U-U.U.U.UU.U-U.UU.U-U-UUU.UUUUUUUUUUUU-UUUUUUU 
vO'O'O'O'O'O'O'O'O'O-O-O'O'O'O'O'O'O'O'O'O'O'O'O-C'-O'O'O'Ci'O'i'-O'O'C'-C'-C' 


U O' O' 

— 1 — r-- 

— O-- CO <N — 

CN Uj -0 OO 

QQQOIOUJ 
U CJ O h' CN CO 


li_ OO 'Ll O-- <T CJ 

u u u u u u 

-0 -0 -0 'O vj -0 


<l o o <r 

h- 

-o — h- 
in o- — in 
CN Q o <T o CO in 
CO CJ CJ CO CO CJ u 


uj — <4- r'- <r co 0 

h- co co o:- co co 00 

u u u u u u u 

-0 -O -0 -0 -Li -O 


Number 47 


Dr. Dobb s Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 












<x 

X 

o 


CL 

X 

CJ 


LU Q 
> O 
LU X 


Z LU 

O CL 

- u u 
h liJ Q 
CJ Q <1 
ID O 
CL O CD 
P— LU Z 

to a — 


J LU 
X X 
CL 
O 3 
P- o 

O to LU 

LL LU O 
~ O < 


z 



CQ 

o 


h- 

O CJ O 

CQ h- 



LU 


-L 


X 

CJ 

X 

CQ 

CL 


Z 

o 


LU 

V 

LU Q. 

LU 

Ll LU 

lL 


o 

P- 

0Q 

Q 

OQ O 

hU 







O 







CO 

CL 


- ■ 







2 


or. 









CD 

f— 

CJ 







P- 

2 

UJ 








3 


2 

z 







O 



o 







LU 

O 


X 







X 

»- 

I— 

LU 







LU 


X 

z 








o 

LiJ 

X 


_J 





Q 

2 

Z 


CJ 

X 





Z 



o 

U- 





0 - 

<L 

1 — 

o 

2 

2 

^ _J 


CD 


_J 


2 

L— 



O X 


OQ 

CO 

z 

CD 



Q 


Q. — 


Cl <X 


CL 

z 

O 

o 

_J 

a! 

o . 



LU 

U_ 


LL 

z 

O 

— <r 

<E 

fx O 



Q 



X 







O 

-J 

h- 








o 

X 

Z 

CJ 







LU 










a 

X 

o 









t- 

0 - 

LU 




y- 

LU 

Q. 

CL 



Q 

Q 

q a 

OR 

CL — 

_J 

3 

o 

3 

_J 

O 

_J 

3 _J 

3 CU 



Li- 

q: 

X 

U 







LU 

LU 

X 

LU 







Cl 

L— 


a 





00 


o 

Z 


o 

0 - 




z 



LU 

3 

X 

LU 





i L— 

LU 







| 3 

LJ 


X 



Q 


3 

o 


LJ 



O 


X 

o 

Z 

z 



X 




LU 

a 

CL 


CQ 



Cl 

> 

or 

CQ 


1 — *— 


CD 

lj 

LU 

LU 

3 

CD 

CD h- 


1 — 


V 






CQ 

LU 

LU 


CO 

CQ 

CQ 3 

LU Q 


CD 

LU 

LU 

CQ 

CQ 

CQ X 



LJ 

o 

LU 

LU 

LU 

LU 

O O 




o 

CJ 

O 

CJ LU 



CQ 



o 

O 

O CQ 



LU 

L0 

Ll 

CD 

CD 

CL _l 

LU CQ 


CL 

X 


a_ 

CL 

0- LU 

QC X 

— 

- 





.. .. 

.. .. 


LU tO 

a a 

o LU 


CL 

E 

3 


co 

CL 

0 - Q O 

X CO 

id e a_ 

3 CO 

z z 

LU LU O LU tO 
CD CL >o _ ; 

O CO LU LU 

H H h \ CTj 

to LO CO 0 O 

j lu lj q a: 

X CL h— O CL 


LU 

0 - 

O 


Q 

X 

LU 

X 

O 

3 

CL 

>- 

CJ 





CQ 

Q 

3 

0 - 

OQ 

Z 


o 

<E 


CD 

LU 

CQ 

CQ 

LU 

y- 

LC 

CQ 

CQ 

z 

o 

LU 

LU 

LU 

p— 

07 

O 

O 

8 


LU 

CL 

CD 


CL 

CL 

Cl 

LU 




CL 

LU 


CL 

OQ 

Cl 


CL 

to 

3 


CO Q 

P— O 
CL X 


I 

04 _J 

CL. ~ CL 
X _l X 
— X *-« 

- ^ <1 Q. I 

a - - ~ 00 


to 


<r 

>- CO 

P- cd 

u-IX 

- Li- <T 
NCL O 


'CLQ.CLQ.a_CLCLa.Q_a:a*-«G_Q_CLCLa_ 


oj 

h 

CD 


- <o o co a 

to X — OQ Z Q 

t— ♦— I I <3 *-hO 

-> X X Q_ JCl I 3 3 E 

- — O <r - XXX — XCLXCLh- 
N - Ll - r-x O - —< . CJ . (J - _J 

z«io«tzNua.<itN^NX 


CLQZ-hq_clClClQQ.ClClQ.Cl 

3_J<£eD3CJ33.JCJ3CJ33 


o 

o 


CD — 
LU CO 

LU 

o 

CO P- 
CL 

o o 
co z 
to 

LU P— 

CJ z 
o ~ 

QC O 
0- CL 


. CO 


P- Q 

— z 

CD X 
O 
CO 

3 O 
I- I- 
«I 

P— I— 
tO LU 
CL 
X. 

CL li- 
CO —. 


^ - X 

—I . 

m- i <r 


o *h m co in 

CO CO CO CO CO CO 
<N CM CM C'L CM CM 
O O O O O O 


2 ^ L2 ^ 2? a o ^ ^ 1:0 ^ ^ ^ o cm co it* -o r-- to 

' 0 CO 0 ) 0.1 *4" «3- «3- ^ < 3 - m in in in in in in in in U"j xj -O >0 xj -O uj xj u : ! 

^^CJ^^^^^^^^N(NCN(NN(NiNCMCN'NCNCMCMCJCMiN(N(N(NiNSS 

ooooooooooooooooooooooooooooooooo 


|> 0 -H IN 0 <t ID >0 N CO O O - CM CO 
CM CM CM CM CM CM CM CM CM CM CM CN CM CM CM 

ooooooooooooooo 


't ir.i -o n co i> o h 
CO CO CO CO 00 aj o. o. 
CM CM CM CM CN CN CM <N 

oooooooo 


O- o 

rx rx 

M5 CD o:> LU 
O Q O Q 
LU CO LU CO 


o:« a*- o o 
o o © © 

i— 


<L 

<x 



o 

CO 





h* 



rx 

rx 




M- 

CM 



-o rx 

00 

u_ 

00 


-0 

>0 



ll m- 


5 



<1 

CM 

LU 


<r cu 

CM 

-O 

o 

UJ 

CM 

CM 


Cu 

CJ CJ 

CJ 

LU 

CM 

rx 

« 

CN 

o a 

LU rH 

CO 

JO 

CO 

CL 

CN 

O 

o- 

-> 

•> <r 

<L 

<L 

<r 

<T 

o 

o 

o 

o 

o o 

o 

O 

o 

O 


— -• — CO 

rx ix rx rx rx 

N <1 O C J O O- O Q W CO 





CM 


IN 

CM 






CM 


CO 







co 

UJ 




rx 


r- 

rx 






rx 


rx 

rx 



rx 


rx 

fx 

o 

LU 


rx 


co 

cu 

00 

CL 

o 


o 

rx 

xj 

o 

00 



CJ 


CJ 

<x 

00 

Uj 

O 


o 

CM 

a- 

LU 

UJ 

o 



Ll 

'Ll 

O 

fx 




m- 

m 

3 

CD 


(_j 

C 1 

LU 

LU 

CL 

LU 

<r 

CO 

UJ 

c* 

LU 

Jj 

cu 

CJ 

LU 

<x 

co 

UJ 

LU 

<r 

UJ 

<r 

CO 

iZJ 

CM 

rx 

o 

O 

Li. 

CJ 

u 

u. 

CM 

rx 

LU 

CJ 

O 

Ll 

o 

CJ 

rx 

Ll 

CJ 

Ll 

CJ 

o 

a 


-o 

rx 

O' 

CJ 

LU 



>0 

00 

o- 

cu 

LU 

o 

l>4 

in 

00 

O 

CD 

LU 

o 

CO 

s£f 

O 

CJ 

o 

U 

Q 

O 

Q 

Q 

Q Q 

1=1 

Q 

1=1 

LU 

UJ 

LU 

UJ 

LU 

UJ 

UJ 

u. 

u_ 

Ll 

O 

o 

o 

O 

o 

o 

O 

o 

O 

o 

o 

o o 

O 

o 

O 

o 

O 

O 

O 

o 

o 

o 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 





UJ z 



CQ 

1 - o 



LD 

Z E 



LU 

UJ 



1 — 

O Z 



CQ 

cl e: 





s 

LU 

CD 

LU LU 

CJ 

3 CQ 

LU 

> > 

CL 

3 Z 

CD 

«X <L 

Z 

<E — 


CQ CQ 


> N 

_J 




_) 




<1 





Q 

Z 

<1 





lD 

o 



X 

OQ 

E 


CJ 


UJ 



e: 

z 


LU 

o 

E 


LU 

CL 



CL 

Ll 

a 


X 


LU 

h- 

L— 

JZ 

iD 

►—< 


LU 

CJ 


P- 

Z 

<1 

uL 

Z 

e: 

CL 

O 




•3 

CD 

L— 

L— 

CL 

Cl 

LU 

UJ 

Z 


Q 

CD 

3 

•3 


.. 

.. 

.. 


CL 

a 

LU 

<t 


o 

o 

LU 


CL 

Q 

Q 

<r 


CL i 

Q CJ 

<T LL LU 

LU CJ CL 

li_ I Xj — 3 Xj 

-J - Z - L— Z 

xox>ccLucrQeo>-cj: 

-l(aOMQ.QQ.Q.fljMQji 


o <x o 

<1 O d LiJ □ 


I 

CM 


CQ 


O (J 

7 § q + p— # u- a 

E UJ X >- I Z LC 

3 _ 5 E ^ <1 Q tu xj —• LU Mj — 3 

¥ ^ , -. ¥ , . “ ., “ <r o - - z in z — p- q-2.1- 

Ija£8o3iiU«« r «u3Q2;££2:«iui£2S£Bg:2 


O LU 
0- CL 


ll^^tiiaaliiaalaaSiaSaSiSlsytS^aSSSaaaS^a^^SSa^E 


LL 

to 

Q 


> 

_1 

Q- 


.. -. .. LU 

co ^ o ^ cm co «nn 

sI'ONNNNNM 

OOOOOOOO- 


0 - 

cq 

Q 


LU 

Cl O- 
Q CJ 


UJ O 
O -• 
O O 
rx rx 


O'¬ 

o 

—< 

CM 

CO 

«3- 

tn 

<• 

rx 

CO 

O'- 

o 


>N CO 

*3" 

in 

>0 

rx 

oo 

CN 

o 


CM 

CO 

«3- 

in 

xj 

rx 

00 

O'- 

O'- 

o 

o 

O 

o 

o 

o 

O O 

o 

o 










(M 

0*4 

CM 

CM 

CM 

CM 

CM 

CM 

04 

CM 

—f 

CM 

CM 

CM 

•N 

CM 

CM 

CJ 

CM 

CM 

CM 

CM 

•N 

CM CM 


CM 

CM 

C>l 

CvJ 

CM 

CM 

CM 

CM 

CM 

CM 

CM 

04 

CM 

CM 

04 

o 

O 

O 

O 

O 

O 

O 

O 

o 

o 

o 

O 

O 

O O 

O 

o 

o 

o 

o 

o 

o 

O 

O 

O 

o o 

o 

o 

O 

O 


<r 

. - rx 

o> o o cm o o 

N 0j N -C- N N 
Ll — CJ CO CM O 
M- CM CO in CU CO 


00 

<x 

—• CJ 
CM Li- 


CI 

rx 

co 


o o o- 


'I W U 1 W 

QIDQQQQQQ-^u^wlu-wu.' 
Q U O Ll U 111 U U u Ll U Ll n <1 u IT- ■ 


UJ 

-0 

oo 

CM CO 


in 

oo 

04 


O' 

rx 


rx 



o 



rx 

rx 

rx 

o 


o- 

rx 

, 

in 

rx 

CJ 

U“ 

in 

CM 

— O 


o 

CM 



U- 

Ll 


CM 



UJ 



04 

04 

04 

o 

CM 


O'- 

LU 

o 

co 

a 

Cu 

CD 

CD UJ 

LL 

xj 

CD 

CD 

rx 

o 

lD 

in 

3 


Ci 

o 


co 

CD 

CD 

Du u. 

xO 

Cu 

1=1 

Q 

o 

xj 

Ci 

Ll 

U- 

CJ 

CJ o 

<r 

o 

CJ 

CJ 



CJ 

o 

CJ 

o 

° 

04 

o 

rx 

CJ 

CJ 

o in 


U- 

U- 

O 

U_ 

O 

CJ 

«X 

LU 

o 

(N <1- 

xJ 

rx 

O- 

CD 

a 

LU 

O 

CM 

CO 

XJ 

rx 

CQ 

<i 

CD 

CJ 

LU 

O 04 

CO 

in 

O- 

Du 

LU 

o 

CM 

OO 

CO 

M- 

M- 



*4- 

M’ 

<3- 

«t 

in 

IT' 

U7« 

in 

ir« 

in 

in 

in 

in 

in 

<• -o 

xZ- 

Xj 

o 


xj 

rx 

rx 

o 

o 

O 

O O 

o 

O 

o 

O 

o 

O 

o 

o o 

o 

o 

o 

c- 

o 

o 

<D> 

o o 

o 

o 

o 

o 

o 

o 

o 

rx 

rx 

|x 

rx rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx 

rx rx 

rx 

|x 

rx 

rx 

rx 

IX 

rx 


<x 

rx 

o cn 

N «0 N 


j u u O lii Q u u i.r 
lOQ^OLUCJQU 


rx rx ix rx ix rx rx 


Page 8 

276 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 









t- 

tfi 






-J 





X 

<L 





X 





X 

1- 

O 




Z X 

z 

X 

oo z 



3 X 


X 

X X 



3 H- 

o 

CO 

<r 3 



Z 

X 


*—« 1— 


X 

1— • 


X 

O X 


z 

CJ o 

X 

o 

X X 

(J 

3 

X X 

o 

X 

X 

X 

-J 

X 



if) X 



LH X 

X 

1— 

if) 

3 

uo 

X z 

X 

oo 

X 

X 

X 

Z 3 

a 

X 

o o 

z 

<L 

— 3 

<x 

h- 

x a 


- 









oo 




X 




X 


(J 




<r 

> 

X 


L— 


z 


OO 

oi> 

X <L 




X X 


z 


X <E 


o 

X 

I X 

LJ 





z 


o z z 


X 


O X X 


3 

OO 

3 3 



OO 

ci y- 


X 

<1 

Z X X 


X 

X 

<1 X X 

- 





: in r? i 

. _ © 

i o z x <j < 

ffi liJ IQ i 


CO h I X 

D U - - Q 

'ZCOJLUaJZ 
« LL Q Q u UJ 


X _J 

X X 

— — © 

~ —I - _J - rsi 

Ul I u I <1 u Z 1 


©XX 

CJ ~ ~ 

© Q <X <L 


O UJ 
X (X 

UJ CO LU 

3 3 Ci 

X <L ~ - 

- - > (J CJ > 

<1 LU « CO CQ M 


<X © CJ 
O CN CO ^ - 

+ + + — 

XXX O CM 00 

HH I—« I—« + + + 

v ^ V > X X X 

.. .. , H H H H O 


: u Cl Z u i 
I X 3 X ' 


1 J JO. 
i <x <r o x x x 

Q (J CL LU UJ “D 


3 CJ J— 

uZQZQlXLU 
-I — _J — _J O X 


L-XJ- 
Q CL LU O LU 
J 3 X x CZ 


UJ Ci 

=' Cl Cl Cl 
U-I _1 d 


X 

Cl CO Cl 

QQ QQD Q I 
<T X X _J X <x . 


insONCOO. O-J<N02«tin>0N00(>. O^CM(0«tin>ONCOO'. 0-JCMCOJtlOMDNOO^OrHCMW^inONaiO,0-iCMm«tLO^Km(v O T-t iN CO 'i - 1|—| «£i n 

u-jujirjirjirj'0'0>o>0'0'0'0>0'0-i)rvrvh-fvr^r^r^f^r^i^cococooooocococioooooo. o- i> o>. ■> a- i> a. O' ^ o o 6 o o o o r. o ^ ^ U in i h 

ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


© ID CM 'fr CM CJ ^ -• <3- 

o c* o I s * o o h' c- c- 

Hi IjO iu u CO C- X 00 X ^ O ON <i f-v 

CM N iN O N Q *0 O <'<10 ill U. Q 

QQQQffl^rooo^romucoMjflj-HQoiOQQ’Hffliaco 

X X X 3 X O 3 CM © -• CM ID CM ID X O 3 CM 3 3 3 3 X X 3 


<i ^ O CM CO O CM CO 

<3- c- o o o o o o 

O th uj 0-. LU <' LU '> C~ © *-i 

O CM O T-iS«t«tUJNNN 

lO'OfflWCOliQHinQQDQaQQQH 
O-NCOCOiniLOOLQQQLQQQU 


n N n N N n — r~- — r--r— i— r— 


r^r^r^rvi^r^r^r-r^r^iv.r>- 


CM CO IT' -O N CO |> Q O -H CO <• O', i J LU t N 
Q Q uj Q lu ill Q Q u U O 3 CJ CJ CJ Cl Ci Cl 

NNNNNNNNfvNNrsNNNNrsN 


SSSSSSSSSSSSSSSS^SSSSSS^SSSSSSSSS^SS^ 


1-0 —J 

CO f— «I O X 

3 E H 00 

1 h X 3 

Ci X O X X 

<X X Z CO '• 


X * I 
X oo 
X LU X ►I 
CO K O Z 
Z X w 
O ►- X 


<T 



© 

h-i 



z 

oo +- 

z 

1 

h- 

X 

oo to 

X 

X 

X 





Cu 

z 

l_l 

o 

X 


© 


h- 

3 

X 

oo 

X 

o 


OO 

z 


o 

1— 


oo oo 

I— 


X 

o 

X 

oo 


X 

L— 


<1 

X 

X 



0) 

X 

o 

X 

O 


oo o 

3 


Z 1 


X 

z 

:> 

h- 

h— 

H- 


X 

z 

oo 

X 

X 

OO X 


X 

CJ| 

CD 

Q 


X 

<r 


LU 


h* 1—1 


3 

H 

X 

X 

o 

X 


X 

O 

<3 

V 

X 

© 


CJ 

© 

© 


Z 

cl 

O h- 

»- 

z 

I 

X 

CJ 

<L 

LJ 

o 

z 

X 

X 

© 

z 

© 

o 


O OO 


X 

oo 



-1 

Q 

oo 

LJ 

X 

X 

X © 

l_l 

z 

CJ 


X X 

o 

o 

_J 

X 


X 

O 


CJ 

l_l 

o 

M <L 

CJ 

<E 



X 1- 

3 

z 

X 


t- —« O — X I <* 

~ X + + + OO X I 

X CO CJ X >- >- x ox 

XX lu •—•»—••—• CO x OO 

o — - -> o — ~ ~ -. I- X 

- - > >- X M , <r 

(BUwOOOOOHlH^OfflZfflNXffl 


X I X CO o 

=' i -* *-• x co <r i-jj 

XX X 3 Cl ” I- M 

J— CO X X 

-J O — X h- JOU ClXZ 

r-j <T - - ~ - X ~ Z Z X o 

Z X © X C- r-4 i_i XX <T_i X 


I X 

•N 

J— CO — 

CO 3 X I © 

h- X CO co >- + 

3 - 3 uj X > 

X X ru 2 -J CO II 

X CO Z • X h- 


X X X X 3 © 3 H- Cl Cl h- (JO 

LjLjCiXXXXXOZ-iCiCiClXZXXZXXCiCi*-'XXCiClX 
x x x oo co oo oo © <x *-• © x x x 3 <x 3 3 <r 3 3 x x © 3 © <1 x 3 


3 <r 
01 X > 
UJ X 3 X 
0-J Z X X 
x hu <r 

CJ I— OO X 
O X' X 
X o o o 
X X t- z 


CM CO ■? yi -LI N CO O'. O U CM CO «3- ID O X X O —• CM CO 'tlD-ONCOO'-O-H 

O' O' «>• O' O'. O- O |>. O o O O C' O O O O O —I —' —' ' ’-I —' —' CM CM 

CM CM CM CM CM CM CM CM CO CO CO CO CO CO CO CO CO CO <vj CO CO CO CO CO CO CO CO CO CO CO 

OOOOOOOOOOOOOOOOOOOOO © o © o o o o © o 


O-. O CM CO M - llj N CO O'- © —< CM CO *3" ID <■ C*. CO O-- O CM CO «t If) M) N OO ■>• © «-i CM X «*■ 

—« CM CM CM CM CM CM CM CM CM CM CO CO CO CO CO CO CO p) C-j O t ^ t -J ^ T ^ IT' ID ID ID ID 

CO CO CO CO CO CO CO co co CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO OO CO co CO CO CO CO CO 
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO © o © o © © 


«4- O IT' © © -r-< o ID <X <3- 

o c- o © © © n n o r** 

c- <3- «3- x id x x h* x x in •> 

o cm —• © c» cm c- 04 c- r-v cm © id cm x 

ID O • CO CO O © Q Q CD Q © Q Q <E t-i oo 

X 'N O O CJ CM 3 X X X X X X X CJ CM O O 

X L ^ (N Ifi Oji>. U II <1 <■ <1 I?.. O X —< 'T' C- 

IlIlOOOOOOOhhhhuhNCSN 

LJ LJ —I ’ I ' r ~l **—* ’ I —' 'H ’—t T—i T—« tH tH tH tH tH 

rv.rs.i^iv.h-r^r^h-r^h-r^r^r^r>>r^r^r^r^ 


|_| —• o ^ 

oo o © o c- 

© —j O- I>. (O- O- I>. x X <1 IT' C- LU CM »>• © X —i © <i 

© CM OO OO CO OO © It N <■ -J- O © O © © O h- O OX 

<| X L_I X X X X uj I_I CO X X X X O © OO CO o © 00 < X X CO ID cr. <i CO 

O *t Ll. o CJ CJ CJ O X CM CJ X X X CM <E CM — <T CM — — ID CJ CM —' —< O O 




-I — UO' © 

C- c- c- o 

ID CM —1'^-'^- 

<C © X -• © 0- 

CO X © X OO X X 

CM CJ CM CJ ’-'OX 


r^. c» Cv rv. c> c« 


Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

277 















(ft 

<r 


2 O 

=' X © 

<1 CJ uj CL iX 

X ' J =« X 

© <r © © © 


50 

Lj 

<X Z h- 
H- 3 
CO O 
© © 
2 CJ 

Odd 
10 _J 
LU CL 

O Cl LU 
d Zd 


d 0*1 (ft 

O O') LU 
I— LU CL 

ix o 

<X V I- 
d I- h ilj 
J d LU LU 
Cl © (ft in 


CL (ft 
O Ul 


<r 

Cl t— 

Cl to <r 
cr.» ci 


§ 

R 

o 

■S 

.1 

c 

R 

<3 


X O I — 

+ »-• + in +x + 

: x Q x h CO X X (ft XX 

, ^ <3- >HQ j>HH 

■ — UJ — Cl -.©©'-'00©©^©. 

• - - .ZOZ W * - O (ft - |_I 

iMLNllJCOlilhdODhdOQj 


X X o 

_j — in _j — ©. + 

• »- _i o — <> _i — © > 

LL ►-«_' + CO Cl <3- —> + Cl N- > m 

O' 1 i—i CL x Z 0*' ~ Ci Cl x CO - © © ^ 

'>>OZOHH^>oZOHH>OZtn> - 
1-*|— CuLUCi'-OjI— CuLUCi'-'l— CiUJt— *-<<I 


— <x 


— <r 

► iN 


+ — X I + — X . . 

x CM i>. _J x CO Ci J x 

M + Od*-i + udi-i 

~ x O 2 — x O 2 — 

~ ~ ,Q - —i - O - . _ - 

<r ^ o (Jd^ood^oud 


— <i 

-.oo~ 

x i + — x 

o in j x o ci —* i 

+ Q d h + q to i 

x O Z ^ x O Z i 


•owu UJ 


s! T 

5 5 

u! xi 

, o 01' - 

>• , di N 

wQO Z 


X 

to 

Ci Zj 


o —I © 

u UJ d u 
J Ci o Cl 


dduddQddQdQi 


1 H- 

: ci uj 

1 _J in 


lUduuuduCiudQQudu: 


Ci Ci LL IX 


’-i CM CO 
uj 0j «Xi 
<3- «3- 
O O O 


«a- in >o 

•jj CO ijj co 

o o o o 


Ijj 

CO Ijj 

N" ■=!- 


O — 
•>. © 

o o 


CM CO 
•> •>. 

o o 


<3- in 

i>. •>. 
N" <3- 


-o r- ijj •>. 

i>. ©•• © 

<3- ^ <3- <3- 

o o o o 


O -• CM 

o o o 
in in in 
o o o 


• >o h* co 
o o o 
' in in in 
o o o 


© o 
o -I 
in in i 
o o ' 


1 N" IT.I <1 hv 1 30 ©. O — ' CM CO -t 111 -CI MB a- O -H CM CO «3- in <' N CO ^ O ^ CM 

1 r? T? r? ^ <N 'N CM CN CM CM IN CM 'N CM CO CO CO CO CO CO CO CO CO CO «*■«*■«* 

in in in in in in in in in in in in in in in in in in in in in in in in in in in in in 

o © © o o o © © © © © © © © © © © © © © © © © o © © o o © 


© © • 


■ © © © © • 


LU UJ LU 

i_j CQ Ll 

— -•co-ico^^in© in t-i © in 
oor^or^oi^KO o © r^ 

© © CO CQ CO IT 1 'O UJ Q 0j LU ^ r^- CO © 

o o hohcoq©ncj©on ©. r-> cm © 

QQ'NQO’HfOQQUJ'XiQQLUlfiiQQQ' 


QQU.QOOOiJQOhOQOUIlU.OOO cj 


co cm © <4- in <* cm in *3- ir.i © 

h*- © h- r>- © r'v o rv. hv © 

co © uj in >o ^ © © <i <3- co lu 

■h di N 111 © (>• © Q N O !?■■ © © (N N 

CO Q Q © Q -h CO □ Q © ^ CO © © Q ©. 


I © C_1 O © O © O O l 


o 


1 9 9^‘ r ^ i: ‘3 L yi H ;fr^$ c Sr't u ’“ , ^t'' ,: ' rx '‘ I ' : -j©OC0'-0©. cj©cNinco©©-i«3-r''..>.,;j 
ir.i 'O ~Li ^ 'O r^. r^. rv hv ijj ijj uj 1 X 1 ijj co co ©• ©• ©. © © a-. <i <i <c <x <c © © © © © 

£ 4 Id 4 l 4 L 4 ^ £ 4 J^ -4 £ 4 T 4 L 4 l 4 ,N ,N f* 4 ,N ,N ,N ( ' 4 ,N CM CM CM CM IN C-4 iN iN <N CM CM iN CM CM CM 


© cm © co cm © co © m- 

© © © © © © © © r-. 

LU r-' O- I j UJ N O 'N LU h- U“i CO UJ N © © ill 

NN'JhNNQwNSQONNQUJ 04 

l—I l_l LU Ijj LJ LJ LU Ijj lj i_i LU CO © © LU © CO 

© i—l © -"-i Q i—I © ■'-' Q © C 1 '—' © © © o h 


i—l © CO llj N d u U. N O' ijj UJ ■h CO <1 

© CJ O O O O O O © Q © © © © LU LU LU 

CM iN CM CM iN 'N CM CM CM CM CM CM CM CM CM CM CM 

Ovr^r^r^r^r^r^r^h'r^h'r^-r^hvr^r-'O' 


o oo CM 

CM © © O 
© <1 LU © 
U_ © Ll CM 


■jj O UJ © 
LU LU LU U. 
CM iN -N CM 
N N N N 


CO 

z 

IX 


LU LU 

IX IX 

o p 


0j 

►— 

in 


z 



o 

X 


to 

© 



y- 



S 



© 


Z 


<r 

y— 


0j 


o 


j 

(ft 



ift 

cn 


© 

<r 


X 2 


© 



.j 

□ 

o © 




> 


© 

© z 

© 

<r 


© 

> o 



Z 

h- 

(St 


►i y- 

© 

© © 


<X 

© © 

© 


cn 

cn cn 


© 

co cn 

i_i 

o y- 

o 

o o 

X 

© 


z 

y- z 

y- 

l— h- 

J 

© 0j 

© X 



(ft 

to ©1 


> 

> 

© 

© o 

© 

© © 

X 

o o 

o o 

z 

to © 

cn 

cn cn 

3 

z y- 

Z 1— 

<r 


o 

i— 


o 

UJ 

X 


Li. <X 
m Ll 

'jj © 
LU CO 

in i ■'j 


I - © LU 
O Z IX 
© LU LL 


^ ^ i 

- © © 

CJ Z Uj > 
LXl LU I— •—« 


i-i Cl. 
— 0j 
- > 
' X h- 


I — <X 
xiN .1 
© + O- 
l- x ^- © 


— <X 


+ ~ X 
X CM *-i J 

IL ll t <T »—' + ©© 
X - — X ~©^X©Z 

© rvi ^ *— ijf z , m ^ o 
o- z d ^ ca uj d ^ o o 


<L 

£ 

© 

cn 


O CJ CJ CJ CJ © co 


© © 
i- y- 
© © © 
z >— z 
— © -« © 
- ~ i-i 

> ~ >- © 
M N « -J 


CM X 

+ U"| 


_J CO X _J 


ch¬ 
in X _J CO X : 
+ IT' © + O i 

x iii uj x in • 


Q w -> O M V CJ 


(J) 

(ft 

© 


—I —I I I © 

©|X©©©Z©©© 

_J 0.1 to Ijj to <X o _J “ 


O ©' CJ CJ to 

ZQlXZQ©LU©©LU©LUiX 
hh_i d h j j i—i —i j a j cn Ti 


co &. 


© -I 

CM CM 
© © 


iN CO ■ 
CM CM i 

^ <3- 1 


Ij"i 'O 
I CM |>4 
cJ" 


rv cc* •> 

CM CN CN 

N- N- N- 

© © © 


© © 
cn cn 
© © 

© CM CO 
CO CO CO Ijj 

N- '4- «*- M- 

© © © © 


© 


n- in 

0 j CO 

M- M" 


'Ll f'' 0j 

CO 0j CO 

M- M" N" 

© © © 


2iS!^22!£S!i22SS^'£i£2SK?^lt ffi ° ° " ,N <•> 'tm-dMuooH m n l-:* <■ m o 

^ ^ 2 ^ ^ ^ ^ ^ ll -i ll in U ,i ll .i ll .i ll .i U .i li ,i li j vjj Mj -O' -"D '0' >0 'Oi 'ii 'Ll 'Ll |v hv f'' fv Cv K- hv Ijj 

© © O © © © © © © © © © © © © © © O © © © © © © © ©i o o © © © © © © © © © © © o ©, 


Li.• © — ’-i m- M- »-» li - .i © © in 

r-- o©iv.©r^rv©h.rv © © 

m- co lu i>. in << o-- h- m- co lu co v 0 © 

O C'4 N N d d U d d u © IN 'Ll CM -0 © 

u u Q u Q th 0j Q ^ CO Cl u Q Q p CO 

O Ll Ll u CJ © CJ CJ © CJ CJ Ll Ll Ll Ll CJ 

'MJLUnitrsdD © CO i?© LU © CO 
©©©LULULULULULlLlLlLlU-Ll©© 
1 ■•— 4 *■"' ’■" l ,r - l ’—i i • r -* '-i ■ t— i CM CN 

fV'NNrLi'^r-vr''r>'Nr>-NNNNr^N 


CN <3- N- N- «$- CM CM 

© © © r^- © © 

© j UJ N |>. <1 LU N -I CO 

O N N u u N N U LU 

UJ © D Q h CO © © LU CO 

Ll CM © © © iJ © © © CJ 


<1 CO <E © © CO -Ll O i J LU 


fL 


'-J 


o iio m- in 
in ^ 

O- O' i> a- u_ co —- <i —i <r 

CO CO CO CO © © CM © CM © 

Ll © © © © <i LU © <T © CO 

N- 'j O IJ 'J LU Ll Ll CJ © 'J 


■— CM ^ 'Ll Ijj <r lj © IN U“| !>■ 

I.N IN CM |>4 CM CM CM CM CO i*0 CO 

•N CM iN CM CN CM CM CN CM CN CM 

r^r^iL.r^r-'i^rLr^h'i^r^ 


^ in co n i>. o in in in in ■> © n- 

co 'O' —• co -li © co in © co in o © 

© © 0 j © © co © © 0 j © © © © 

© © -• © © '- © © —I © O © CM 


CJ © ’-* CO -0 CO d Q © -'-I N- s0 ‘I 

CO CO M- N- N- N- N- N- in UO U"j in 

CN CM CN CN CM CM <N CM CM CM CM CM iN 

h- i^- fL ^ r^> r^. C" r^. h- r- 


Page 10 

278 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

















I .A.I .I JJ .= 

q “no programming 

BY J. L. LAWRENCE AND JAY SPRENKLE 

Computer Science Dept. Software Lab I 1 

University of Missouri —Rolla 1 

Rolla, Missouri 65401 __ 


It was with much interest and skepticism that the authors 
read the article “Build a Self-Learning No-programming Com¬ 
puter with your Microprocessor” by Klaus Holtz in DDJ #33. 
The article describes a computer which requires no program¬ 
ming, is educated almost like a human child, and is relatively 
inexpensive. Applications suggested'for this new computer in¬ 
clude language translation, a typewriter which refuses to type 
incorrectly spelled words, unbreakable secret codes, and others 
which are currently difficult to implement. All of this is 
claimed to be achievable with no programming! 

The article’s author describes briefly the theory behind the 
proposed computer as “Knowledge Processing and Infinite 
Dimensional Networks.” It would be nice to have a reference 
for such an amazing theory, if a reference does exist. Rather 
than repeat the theory here, we merely pause to mention it. 
As Holtz points out, understanding of the theory is not neces¬ 
sary to implement his ideas. 

Figure 1. 

1ST REM 

20 REM * HARLIE • 

30 REM • * 

40 REM ••••••••*••••**••••••••••••• 

80 DIM I$(72).M1(2),M9(2),M5(2000,1),T$(72),T(72),W(72) 

90 DIM AjUlOT.l) 

100 N= 2000!M£(N,0)=-9999iM5(N,l) = -9999 
110 M=10»iA5(M,0)=-9999iA5(M.1)=-9999 
120 1 CHR$(26) 

130 I TAB(23),"-" 

140 I TAB(23) i "I H. A. R. L. I. E. I" 

1J0 I TAB (23 ) , "." 

160 111 TAB(19),"I AM A SELF-LEARNING COMPUTER"!IiI 
170 1iIi1$=""iINPUT "> ",I$ 

180 IF I$="*ST0P" THEN STOP 

181 IF I$=“»MEM” THEN 245 

182 IF I$="*CLEAR" THEN 246 
190 I9=LEN(I*)iIF 19=0 THEN 170 

200 IF It(I9,I9)<> " " THEN 230iREM GET RID OF TRAILING BLANKS 
210 I*=I$(1,I9-1) 

220 GOTO 180 
230 GOSUB 250 
240 GOTO 170 

245 GOSUB 1310IGOT0 170 

246 GOSUB 1500iGOTO 170 

250 REM SENTENCE ENCODING ROUTINE 
260 IF I$(l,l)=”»" THEN S=1 ELSE S =0 
270 IF S=1 THEN LS=I$(2,LENU$)) 

280 L9=LEN(1$) i IF I$(L9,L9)=”?" THEN 0=1 ELSE 0=0iREM WAS IT OUESTION 
290 IF Q=1 THEN I$=I*(1,L9-1) 

300 IF I$(1,2) = "A»" THEN Q.21REM IS IT AN ANSWER 
305 IF 0=2 THEN S«11 REM ALWAYS STORE ANSWERS 
310 IF 002 THEN 330 


320 I4>=I$ (3. LEN (1$)) 

330 L9=LEN(I$)iJ9=1iW1=-1iF2=0 
340 I $=""1 FOR I=J9 TO L9 
350 IF I$(I,I)=" " THEN 390 
360 T$=T$i1$(1,I) 

370 NEXT I 
380 GOTO 440 
390 J9=1*1 

400 GOSUB 1040i REM CONVERT T$ TO T 
410 P9=-liG0SUB 8901 REM SEE IF I KNOW IT ALREADY 
420 W1=W1111W(W1)=AiIF F> 0 THEN F2=F 
430 GOTO 340 

440 P9=-l1GOSUB 1040■GOSUB 890 
450 W1=W1U iW(Wl )=Ai IF F >0 THEN F2-F 
460 FOR 1=0 TO WliT(I)=W(I)iNEXT I 
470 T(Wl«l)i32 

480 ?9=-2iGOSUB 890iREM ADD SENTENCE 
490 IF P>0 THEN F2=F 

500 IF 0=1 AND F< 2 THEN A9=AiREM ADDRESS OF LAST OUESTION 

510 IF 0 =0 THEN 6101 REM NOT A OUESTION OR ANSWER 

520 IF F2=0 OR F2=l THEN 560 

530 IF F2=2 THEN I$="»”» I DON'T KNOW •***" 

540 IF F2=3 THEN I$= ”»••• more STORAGE REQUESTED ***•" 

550 GOTO 650 

560 GOSUB 700iREM GET ANSWER 

570 IF F=0 THEN 5901 REM 1 KNOW THE ANSWER 

580 GOTO 610 

590 GOSUB 1190 

600 GOTO 650 

610 IF F=0 THEN !$."•••• I KNEW THAT ••••" 

620 IF F*1 THEN I$."**»« I WILL REMEMBER THAT ••••• 

630 F2-F 

640- GOTO 530 
650 I IS 
690 RETURN 

700 REM ASSOCIATIVE NETWORK ROUTINE 
710 F=JP 

720 IF 0=1 THEN 750i REM ANSWER NOT SET 

730 Ml(1)=A9iMl(2)=A|REM PUT IN NEW ANSWER TO OUESTION 

740" GOTO 760 

750'Ml(l)=AiREM PUT IN OUESTION 

760 4=0- 

7706 G=A5(A,0)1 P=A5(A,1)iM9(1)=GiM9(2)“PiREM FETCH MEMORY WORD 

7806 IF THEN 8301 REM ALL ZERO 

7906 IF G=M1(1) THEN 8601REM OUESTION-POINTER 

800 A=A»1 

810 IF A5(A,0)< >-9999 THEN 770 
820F=3iGOTO 880!REM MORE MEMORY 
830 IF 0=2 THEN 850! REM ANSWER KEY SET 
840 F=2iG0T0 860iR£M I DON'T KNOW 

850^A5(A,in*Ml (1) 1 A5</^jl )=M1 (2)1 F-PGOTO 880iR£M STORE MATRIX REGISTER 
860 IF 0=2 THEN 850iREM ANSWER KEY SET 
870 A=M9(2) 

880 RETURN 

890 REM SERIAL NETWORK — FIGURE 2 
900 A=0i Ml (2) = P91 P5= -11 F=0 



Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

279 











Figure 2. 


91* P5-P5*l «i»l (1 )-T(P5) i REM GST NEXT INPUT CHAR 
92*C-M5(A,/).P=M5(A,l)iM9(l).GiM9(2)-PiR£M FETCH MEMORY WORD 
93/ IF G •/ THEN 98 /i REM WORD IS ALL ZERO 

94/ IF G-Ml(l) AND P>M(2) THEN 1/1/iREM WORD"MATRIX REGISTER 
95*A=A*liREM INCREMENT ADDRESS 

96* IF M$(A,0)<> *9999 THEN 92/iREM END OF STORAGE? 

97* F^JiGOTO 10V 

98* IF S=1 THEN 1/0/. REM STORAGE ENABLED 

99*F=2lGOTO 1/3/ 

1/// F=1iM5(A,/)=M1(1)iM 5(A,1)=M1(2)'RE» STORE MATRIX REG IN MEmORY 
inner Ml(2)=AiREM LOAD ADDRESS INTO POINTER 

lerzer if mi (i) <> 32 then 910 .rem gate=end code 

1D3B- RETURN 

latter rem convert t$ to t 

L0"5* L=LEN(T$) 

106/ FOR 1=1 TO LiT(I-1)=ASC(T$(I,I))iNEXT I 
1/7* T(L) = 32 
1080- RETURN 

109/ REM RETRIEVAL ROUTINE — FIGURE 3 
110/ P5=-1,T$="" 

1110-G=M5(A,/)iP=M5(A,1)iM9(i)=GiM9(2)=PiREM FETCH MEMORY WORD 
U2*P5=P5 *llT(P5)=G 

1130'IF P=P9 THEN 115/1REM POINTER = *(l) 

1140 A=PiGOTO 111/ 

1150" FOR I=P5 TO * STEP -1 
116 O’ TS=TS*CHR$(T(I)) 

1171* NEXT I 
118* RETURN 

119* REM RETRIEVE A SENTENCE INTO 1$ 

120*Wl=-liI$=""iP9=-l 

1210 K9=M5(A,1)'REM SKIP END OF SENTENCE MARKERS 
1220 Wl=Wl+l i T(W1 )=M_5(K9,/) 

123*IF M5(K9,l)=-2 THEN 1250 
124* K9=M5(K9,1)iGOTO 122/ 

125 * FOR 1=W1 TO / STEP -liW(Wl-l)»Ttl)iNEXT I 
126* FOR J =/ TO W1 

127* A=W(J)iGOSUB I/ 9 / 1 REM RETRIEVE WORD 
128*I*.I$+T$ 

129* NEXT J 
13/* RETURN 

131/ REM PRINT OUT MASS MEMORY 
132/ P5=/ 

133/ I P5.TAB(l/),M5(P5,0),TAB(2/).M5(P5.1).TAB(30), 

134/ IF M5(P5,/) > 31 AND M5(P5,/)< 128 THEN 1 CHR$(M5(P5.0)) ELSE I 
135 / ?5=F5M 

136 / IF M 5 (P 5 ,/)> =1 THEN 133 / 

137 / P 5 =*| I "ASSOCIATIVE MEMORY" 

138/ I P5.TAB(i/),A5(P5,/),TAB(2/),A5(P5,1),TAB(30) 

139 / P5=P5U 

14// IF A 5 (P 5,/)>=1 THEN 138 / ELSE RETURN 
15// M5(/,/)=/iM5l/.l)=/iA5(/,*)=/iA5(/ I l)=/' 

151/ «5(l.*)V M 5(l .1)"/aA5(1,/)=/iA5(i,i)=* 

152/ RETURN 


Being fully aware of the philosophical problems and impli¬ 
cations of computer “learning” (and wishing to protect our 
future as programmers!), we decided to implement the pro¬ 
posed machine. Instead of using hardware to actually build the 
machine, we simulated the machine in software. Figure 1 is a 
listing of the program in Northstar BASIC which we ran on an 
Imsai 8080. Furthermore, we have run the same program on 
an Apple II and an 8080 with CP/M and Microsoft BASIC. The 
code can be vastly improved upon, but the implementation 
was intended to reproduce the hardware description as faith¬ 
fully as possible. In the terminology of the original article, 
lines 890-1080 represent the Serial Network Routine, lines 
1090-1180 represent the Retrieval Routine, and lines 700- 
880 represent the Associative Network Routine. The rest of 
the code is fairly obvious and is used to enhance the I/O. See 
figure 6 of the original article for further clarification. As for 
main variables, array A5 represents the associative network 
memory, array M5 represents the serial network memory, Ml 
is the matrix register, and M9 is the memory word. 


I H. A. R. L. I. E. i 


I AM A SELF-LEARNING 


> «JLL? 

.... j DON'T KNOW *••• 


^ A*314-364-2831 

•••• I WILL REMEMBER THAT •♦** 


> *UMR? 

.... j DON'T KNOW ***• 


~3 A»UNIV. OF M0. ROLLA 

♦♦♦♦ I WILL REMEMBER THAT ***• 


> *JCL? 

.... 1 DON'T KNOW *•** 


> A*JOB CONTROL LANGUAGE 
***• I WILL REMEMBER THAT **** 


> UMR? 

UNIV. OF MO.-ROLLA 


> JLL? 

314-364-2831 


> “STOP 

STOP IN LINE 181 
READY 

Operation of H.A.R.L.I.E. is straightforward. Figure 2 illus¬ 
trates a sample run. Referring to figure 2, “>” is the prompt 
character indicating that H.A.R.L.I.E. is expecting a response 
from you. All user responses are underlined for clarity. To use 
H.A.R.L.I.E., the user merely types in the request/response at 
the keyboard. Any response preceded by turns on the 
storage flag and causes whatever was typed to be placed in 
the serial network memory (array M5) if it is not already 
there. Any response which ends with “?” is a question which 
H.A.R.L.I.E. will answer if he can. If H.A.R.L.I.E. doesn’t 
know the answer to the question, he will respond with 
“**** I don’t know ****”, as figure 2 shows. After an un¬ 
successful query, H.A.R.L.I.E. expects you to supply the cor¬ 
rect answer although it is not necessary. Preceding the re¬ 
sponse with “A*” causes H.A.R.L.I.E. to remember the cor¬ 
rect response the next time the appropriate question is asked. 
This is the way in which H.A.R.L.I.E. “learns.” 

Figure 3. 




memory location 
memory contents 

pointer 

end of question marker 
end of word marker 

end of sentence marker 
ASCII equivalent 


mm 




Page 1 2 

280 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 















17 

49 

16 

1 

18 

32 

17 


19 

18 

-2 


2d 

32 

19 


21 

85 

-1 

U 

22 

77 

21 

M 

23 

82 

22 

R 

24 

32 

23 


25 

24 

-2 


26 

32 

25 


27 

78 

21 

N 

28 

73 

27 

I 

29 

86 

28 

V 

3j r 

46 

29 

. 

31 

32 

30 


32 

79 

-1 

0 

33 

7 Jf 

32 

F 

34 

32 

33 


35 

77 

-1 

M 

36 

79 

35 

0 

37 

46 

36 


38 

45 

37 

- 

39 

82 

38 

R 

90 

79 

39 

0 

41 

76 

44 

L 

42 

76 

41 

L 

93 

65 

42 

A 

44 

32 

43 


45 

31 

-2 


46 

34 

45 


47 

44 

46 

, 

48 

32 

47 


49 

67 

/ 

C 

50 

76 

49 

L 

51 

32 

5/ 


52 

51 

-2 

3 

53 

32 

52 


59 

79 

9 

0 

55 

66 

54 

B 

56 

32 

55 


57 

67 

-1 

C 

58 

79 

57 

0 

59 

78 

58 

N 

60 

84 

59 

T 

61 

82 

60 

R 

62 

79 

61 

0 

63 

76 

62 

L 

64 

32 

63 


65 

76 

-1 

L 

66 

65 

65 

A 

67 

78 

66 

N 

68 

71 

67 

0 

69 

85 

68 

U 

70 

65 

69 

A 

71 

71 

70 

G 

72 

69 

71 

£ 

73 

32 

72 


74 

56 

-2 

8 

75 

64 

74 

0 

76 

73 

75 

I 

77 

32 

76 


ASSOCIATIVE 

MEMORY 


0-*- 

5 

24 


2 

53 — 77 



“JOB CONTROL IS DIFFICULT” were later added to the 
serial network memory. Only “IS DIFFICULT” would require 
additional storage, Holtz claims. Note that spaces are not 
stored except as “end of word” markers. 

Well, H.A.R.L.I.E. works as advertised but . . . he’s not 
practical. HA.R.L.I.E. suffers from two major problems. First 
of all, before H.A.R.L.I.E. can answer any question, he must 
have been asked that exact question before and have received 
an answer. Furthermore, H.A.R.L.I.E. requires that the ques¬ 
tion be asked in exactly the same way each time. Hence, 
H.A.R.L.I.E. can’t think or reason; he merely repeats what has 
been stored. 



►memory location 
►pointer to answer 
►pointer to questions 


Figure 3 shows the contents of memory after the dialogue 
of figure 2 has occurred; refer to the original article for a 
description of how to follow the pointers. The point to be 
made here is to illustrate what Holtz means when he claims 
that the more information stored, the less storage required to 
store additional information. From figure 2, note that “JLL” 
and a phone number was entered. Later, “JCL” and “JOB 
CONTROL LANGUAGE” were also entered. Looking at fig¬ 
ure 3, the “J” is stored only once. Suppose the sentence 


Secondly, H.A.R.L.I.E. is intolerably slow. Getting answers 
out of HA.R.L.I.E. can take an extremely long time and is 
highly dependent upon the order in which he first “learned” 
what he “knows.” (If you have read “When HARLIE was 
One,” you’ll recall that this imagined machine could answer 
any question, but the answer might not come in the ques¬ 
tioner’s lifetime. Hence, the authors chose the name 
“H.A.R.L.I.E.”) Many things could be done to speed up 
H.A.R.L.I.E., such as programming in machine code or even 
using hardware, but this won’t help very much for very long. 
The problem lies in the extensive use of pointers which any 
experienced programmer knows is costly in terms of speed. 
Hence, improvements could be made but they aren’t worth the 
extra effort. Note that the original article specified the use of 
tape for mass storage, because it’s cheap, which would further 
degrade the speed of H.A.R.L.I.E. 

In conclusion, H.A.R.L.I.E. does work but he is highly im¬ 
practical. Users won’t be dumping accumulated “knowledge” 
from one tape to another as Holtz envisions, nor will know¬ 
ledge be sorted in all-knowing Super Computers with this 
particular design, which accomplishes the task of fact retrieval 
in a very awkward and inefficient manner. Much better tech¬ 
niques exist that are currently operative in many database sys¬ 
tems. After reading Holtz’s article and this one, the reader will 
realize that both are meant to be taken with a healthy sense 
of humor and a large block of salt! 

(Author’s Note: H.A.R.L.I.E. is taken from the science fiction 
book “When HARLIE was One” by David Gerrold.) 


Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 

281 



CLEAN 5TART5 FOR 
\ C05MAC I8bl 

1 DEO OU T F U T 

Sunnyvale, CA 94086 


The 1861 low-resolution video chip is 
a versatile adjunct to the 1802 Cosmac 
microprocessor, but the interrupt soft¬ 
ware required for frame formatting typ¬ 
ically slows program execution by about 
a factor of two. This overhead can some¬ 
times be alleviated by enabling and dis¬ 
abling the 1861 under software control, 
as is done, for example, by Netronics 
ELF II TINY BASIC when using the 
1861 for character output. A clean start 
is not assured, however, on the first frame 
following an 1861 re-enable unless spe¬ 
cial precautions are taken. The 1861 DIS¬ 
PLAY STATUS line provides a means, 
as will be described, by which a re-enable 
can be synchronized with the interrupt 
and DMA requests to the 1802 through 
which the video frame is produced. 

The 1861 DISPLAY STATUS line is 
set low twice per frame, once during the 
last four horizontal scans preceding the 
display window and again during the last 
four horizontal scans of the display. The 
interrupt request by which the display- 
refresh routine is entered is set during the 
last half of the first of these two 
STATUS-low periods. Sync signals are 
output by the 1861 even while disabled 
in order to maintain frame synchroniza¬ 
tion. Thus, if the 1861 is re-enabled with¬ 
in the display window (as can occur with 
ELF II TINY BASIC), the initial series, or 
partial series, of DMA requests following 
the enable will be received during execu¬ 
tion of code outside the display-refresh 
routine. Such an occurrence is accom¬ 
panied by a flash of “garbage” on the dis¬ 
play screen. 

The code given in Listings 1 and 2 a- 
voids such bad frames by assuring that 
the 1861 is enabled outside the display 
window. DISPLAY STATUS is assumed 
to be connected to 1802 flag line No. 1 
(active low), and DISPLAY ON and DIS¬ 
PLAY OFF are assumed to be connected 
to the decoded N lines set by the 1802 
I/O instructions IN,1 (69) and OUT,l 
(61), respectively, as in the ELF II. Regis¬ 
ter 2 is assumed to be pointing to an a¬ 


vailable memory location for the I/O byte 
transfers associated with the IN and OUT 
instructions (e.g., the next location on 
the top of the stack). Two versions of the 
routine are given. That in Listing 1 per¬ 
tains to the case in which DISPLAY 
STATUS is directly connected to the 
1802 flag line. The version given in 
Listing 2 is for the ELF II with I/O- 
monitor board installed. In this system, 
the 1861 DISPLAY STATUS and SYNC 
signals are ORed to generate the flag in¬ 
put to the 1802. 

Listing 1. Basic 1861 reactivation routine. 


Label Instruction 

WAIT1 B1 

WAIT1 

WAIT2 BN1 

WAIT 2 

SEX,2 

SEX,2 

LOOP NOP 
NOP 
DEC,2 
IN,1 
OUT,l 
B1 

LOOP 

IN,1 


Listing 2. 1861 reactivation routine for 
ELF II with l/O-monitor board installed. 


Label Instruction 

WAIT1 B1 

WAIT1 

B1 

WAIT1 

WAIT 2 BN1 

WAIT2 

SEX,2 

LOOP NOP 
NOP 
DEC,2 
IN,1 
OUT,l 
B1 

LOOP 

IN,1 


The initial tests of DISPLAY STATUS 
preceding LOOP in the listings allow 
entry to the loop, the timing of which is 
critical, only on initiation of the STATUS 
signal. With only the first B1 in the 
WAIT1 loop in Listing 2, about 99 per¬ 
cent of the starts will be clean, but two 
tests in sequence are necessary in this case 
to prevent dropping through the hold on 
the SYNC pulse. In both the Listing 1 
and Listing 2 versions of the routine, 
synchronization of the 1861 timing with 
the 1802 instruction fetch/execute cycle 
will be reestablished during the holds if 
it has been disrupted (e.g., by any 3-cycle 
instructions closely preceding entry into 
the routine). Once the final loop has been 
entered, the 1861 is enabled only during 
a series of brief windows between possi¬ 
ble DMA-request bursts. Should the 
STATUS signal be that preceding the dis¬ 
play window, the onset of the interrupt 
request is caught by one of these enable 
windows, and an ordinary display frame 
is generated by the interrupt-service rou¬ 
tine. Upon exit from the interrupt-service 
routine, STATUS is high, and the 1861 is 
permanently (until the next disable) en¬ 
abled as the loop finally is exited. Should 
the STATUS signal be that preceding the 
end of the display window, however, no 
interrupt is encountered during its dura¬ 
tion, and the loop keeps the 1861 dis¬ 
abled during the periods that it otherwise 
would be initiating DMA action. Once the 
inhibited frame has passed, as indicated 
by STATUS going high, the loop is 
exited, and the 1861 finally is enabled 
permanently. The timing of the signal 
lines involved is shown in Figure 1. 


Gary Price is a physicist at SRI who is 
learning about microprocessors from his 
ELF II. He has done a hand-compilation 
for the 1802 of Dick Duda’s Othello pro¬ 
gram from its original BASIC, and he 
would be happy to share this program on 
a Netronics-format tape. - SR 


Page 14 

282 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 



Figure 1. Timing of some 1861 signals and 1802 responses. 

1802 instruction cycles (each 8 clock cycles) 

M I i l l i i i l| M tl I I I I 1 I I I I I I | I II | l l I ) l M I I l l I I I I M I I I I l l i I II I I i i I 


DISPLAY STATUS 

~l_ 


SYNC 

“U U U-LT-—U 


INTERRUPT REQUEST 


I - 1 interrupt response cycle 


DMA REQUEST 



I I I I I It It 1 I II II 1—i — I I I I I I I I I I It I I I I I I I M- 

DMA cycles 


Notes: 

1. Start of display window only 

2. End of display window only 



Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

283 

























The PCNET Project has operated a 
bulletin board system* in the San Fran¬ 
cisco Bay Area for about two years. 
The system we’re running now is the 
Apple Bulletin Board System from Peri¬ 
pherals Unlimited. In late May/early 
June of ’80 our ABBS experienced a 
(for me) novel problem; a person or 
persons would call the system, give a 
CB-like ‘handle’ instead of a name 
during logon, and then leave messages 
making free use of all the well known 
anglo-saxon expletives. 

Other bulletin board systems in the 
area experienced similar behavior by 
someone using the same handle. Systems 
operators discussed the matter, and we 
all agreed that the commercial time¬ 
sharing service procedure of requiring 
login via password would solve the pro¬ 
blem, but would sharply restrict the pre¬ 
set free access policy of BBS systems. 
We rejected this approach as putting 
too much of a damper on easy BBS 
access. Meanwhile back at the system 
the bad guys had grown more disagree¬ 
able, threatening to crash the system 



as well as leaving offensive messages. 
I was intrigued by the problem of devis- 
sing BBS security programs which would 
detect and discourage abusive behavior, 
but which would not be too much of a 
burden for (or better still not even be 
visible to) ordinary users. I coded up 
some security extensions to the ABBS 
which seem to have been effective against 
the bad guys; the number of offensive 
messages has dropped to near zero and 
there have been no system crashes in spite 
of several threats to that effect. 

Two security measures seem to be 
particularly useful. Both are straight¬ 
forward technically, but one involves 
some interesting psychology. 




THE DIRTY WORD FILTER 

This is a string parsing subroutine that 
detects any use of offensive words or 
phrases. The Dirty Word Filter is used 
on names submitted by users during the 
logon procedure as well as on almost all 
other strings sent by the user while he 
is on the system. If a dirty word or 
phrase is detected, the phone connection 
is immediately broken. 

THE UNDESIRABLES LIST 

The kind of person who gets his 
kicks from this sort of thing seems to 
have an ego involvement with the 
‘handle’ he uses. He becomes the focus 
of attention with the added advantage 
of anonymity; “the mysterious DIRTY 
HARRY strikes again!”. The undesir¬ 
ables list contains the names used on all 
objectionable messages. Whenever such a 
name is used on entry, the system breaks 
the phone connection. If new aliases 
are used, they are easily added to the list. 
It’s hard to build up a reputation as a 
mysterious evil doer if you have to keep 
changing your name. 


Some systems (e.g., ABBS) have the 
unfortunate property that if crashed 
the remote user is given full control of 
the system with the ability to alter the 
system program and do other anti¬ 
social things. Proper attention to detail 
in writing the system software can make 
a provoked crash very unlikely; there is 
a hardware fix that can make it impos¬ 
sible. It’s called a watchdog timer. The 
concept is fairly simple; a hardware 
monostable multivibrator is built that can 
be reset by an output signal from the 
system computer. A circuit of this kind is 
easily built using a 555 timer and a few 
other parts; the whole thing should cost 
less than $5. The timer is set to time out 
in 1 to 5 seconds. A subsroutine is added 
to the BBS system that restarts the timer 
each time it is entered; this subroutine 
is called from enough places in the BBS 
so that the timer is always reset before 
it times out. If the system crashes for 
any reason the subroutine doesn’t get 
called and the timer times out and hangs 
up the phone. 

If all else fails your friendly local 
telephone company is prepared to assist 
in preventing your computer from being 
embarrassed by bad language. They have 
equipment which, with modest coopera¬ 
tion on the part of the BBS operator, 
can trace the number from which the 
dirty data was sent. Use of obscene words 
over the telephone turns out to be illegal, 
even if the languge is ASCII. So all you 
obscene data callers out there had best 
be careful. Your next visitor may be a 
cop with a bunch of printouts showing 
just what was sent from your phone and 
when. 

I’ll be happy to share the full details 
of all my system security measures with 
other BBS operators. I’m not going to 
put them in this article; one doesn’t 
provide detailed plans of the bank vault 
in an article on how to foil bank robbers. 
Write me care of DDJ and I’ll arrange 
to supply you with the details. 


You can write to Dave Caulkins at 
PCNET, P.O. Box E, Menlo Park, CA 
94025. 


* (See The Electric Phone Book 
on p.21 of the June/July DDJ for a list 
of them.) 


Page 16 

284 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 






PROGRAMMI 

PASTIMES 

AND 

PLEASURES 

©1980, BY CHARLES WETHERELL 


Dataflow Computers 


There is a tremendous range in speed 
between the fastest and the slowest 
computer in common use today. I don’t 
know what the slowest commercial com¬ 
puter is (perhaps we should have a write- 
in contest?), but an 8-bit addition in 
5 microseconds seems reasonable. This 
rate is still about the same as the addition 
speed of the IBM 1401 that I learned to 
program on back in 1964, so really this 
may not be so slow. 

But it is not nearly fast enough for 
scientists who need answers to big prob¬ 
lems. They often use a Cray-1, perhaps 
the fastest computer available on the 
market right now. A Cray-1 can do a 
64-bit addition in about 15 nanoseconds. 
Ignoring questions about carries, the 
Cray-1 also does eight times as much 
work. But this is not the whole story. The 
Cray-1 sometimes can do five operations 
at once. So the additions could possibly 
go on 13,335 times as fast on a Cray-1 as 
on the microprocessor chip you bought at 
your local computer store. 

How much of a difference is a factor 
of 13,335? Assume that some program 
takes exactly one minute on the Cray-1. 
The microprocessor would take almost 
1-1/3 weeks! And if the Cray-1 program 
took one hour, the micro would take 
slightly more than 1 Vi years! Since 
Cray-l’s are commonly used for time- 
dependent problems like weather predic¬ 
tion, a delay of a year and a half in turn¬ 
around could make a forecast of rain for 
tomorrow fairly useless. 

Money and Technology 

Speed is not the whole story, of 
course. Our hypothetical micro might sell 
for a couple of dollars and I could likely 
package it with memory and power for 
well under $100 in a useful configuration. 
The Cray-1 has a price tag of $5 mega¬ 
bucks. (Admittedly, the Cray-1 does have 
much more memory, but memory is 
relatively cheap.) The price ratio is 


50,000 to 1, about three times my 
optimistic estimate of the speed ratio 
and perhaps ten times a more conserva¬ 
tive speed ratio. Scientists pay heavily 
for the speed they need. And now many 
scientists are calling for gigaflop comput¬ 
ers capable of one billion floating point 
operations a second. Imagine what these 
giants will cost. 

There is hope, though. The cover 
article of Scientific American for May, 
1980, describes how superconducting 
computers built from Josephson junc¬ 
tions might be built. A prediction of 
about one nanosecond per instruction is 
also made, exactly what is needed for a 
gigaflop execution rate. But the article 
demonstrates, albeit indirectly, why a 
Josephson computer (and the Cray-1) 
will cost so much. To build the superfast 
giant, whole new areas of technology and 
engineering have to be developed, 
improved, or refined. All the learning and 
research cost money. In high technology 
manufacturing, serial number 1 of a new 
product is always expensive (remember 
the first transistor radios and hand calcu¬ 
lators). After a hundred, a thousand, or a 
million items have been sold, the research 
cost can be spread out and drop to dollars 
or pennies per item. 

The villain here is the necessity to use 
components employing the most ad¬ 
vanced and expensive technology. What 
if the $2 microcomputers could somehow 
be connected together to solve the big 
problems using only reasonably standard 
technology, particularly using no super¬ 
fast components? Then the supercomput¬ 
er might not require an appropriation 
from Congress to buy. 

An Army of Ants 

How can a $2 micro beat a Cray-1? 
By enlisting a lot of friends. Assume that 
I can buy a reasonably cheap micro¬ 
processor that will do a 64-bit add in one 
microsecond. If 1,000 of these micros all 


run continuously on the same problem, 
they will average an operation per nano¬ 
second. More realistically, if 5,000 micros 
each operate only 20% of the time 
because of scheduling and communica¬ 
tion delays, the whole group will still 
average one nanosecond per operation. 
Metaphorically, an army of ants might be 
able to crash through the jungle as fast 
as an elephant if the ants can get 
organized. 

Dataflow graphs are a way to organize 
the ants. Consider a typical calculation 
like (x 2 + y 2 )/(x 2 - y 2 ). In a normal 
computer, this would take at least five 
steps. But look at the dataflow graph: 



Now it is clear that two computers could 
cooperate and do the calculation in three 
steps by sharing the work. If you remem¬ 
ber that scientific calculations are much 
more elaborate than our simple example 
and that thousands of similar elements 
have parallel computations done on them, 
you can see that there is plenty of oppor¬ 
tunity for parallel operation. Conven¬ 
tional computers hide this possible speed- 


Page 18 


Dr Dobb’s Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

285 




up because instructions must be executed 
sequentially even though the dataflow 
graph shows there is no dependence 
between two instructions. In fact, many 
programs could have entire loops or sub¬ 
programs executed in parallel if their host 
computers could do the job. 

A New Architecture 

A dataflow computer has five main 
components: instruction memory, data 
memory, arbitration network, distribu¬ 
tion network, and a battery of processors. 
In a conventional computer, instructions 
sit passively, waiting for the CPU to call 
them for execution. On a dataflow 
machine, each instruction takes an active 
part in the computation. An instruction 
waits for all of its operands to be ready; 
when they are, the instruction signals the 
arbitration network that it is ready for 
execution. The arbitration network packs 


the data and the instruction together and 
ships the package to a free processor. 
When the processor is through executing 
the instruction, the results are shipped 
back through the distribution network to 
any instructions waiting. In the graph 
above, the output from the left-hand 
square instruction would be passed to 
both the add and the subtract. 

We can notice a number of facts about 
a dataflow machine. First, many instruc¬ 
tions may be clamoring for execution at 
the same time; it is the responsibility of 
the arbitration network to sort out the 
chaos. There is no requirement, by the 
way, that the instructions be processed 
in order of readiness. Second, processors 
do not have to be synchronized at all 
nor need they all have the same capabili¬ 
ties. Data gets back to waiting instruc¬ 
tions whenever the processor gets 
finished. The arbitration network must 
make sure instructions go only to proces¬ 


sors that can execute them. Third, this 
scheme will work only if on average 
there are several thousand instructions 
ready to execute at one time and if 
bottlenecks, when only one or two 
instructions are ready, occur only rarely. 
Dataflow relies more than most architec¬ 
tures on good statistical behavior in 
programs, a property likely in scientific 
computations. Finally, the data store will 
be used to hold large data aggregates like 
records and arrays. This part of the 
system will require considerable 
engineering because it will have to be 
smarter than the average memory. 

Dataflow is the idea of Jack Dennis 
at MIT and right now researchers around 
the world are working on ways to build 
dataflow machines. The promise of 
growing a fast, large computer out of 
many slow, cheap components intrigues 
scientists, computer engineers, and 
administrators who pay for computers. 
Here’s hoping for success. 



Number 47 

286 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 











Z - 80 “~— 

Circuit for the 

H-8 


BY TED T. STOWE 
704 Harbor Road 
Bricktown, NJ 08723 

Thought you might be interested in a Z-80 circuit for the 
H-8 computer. I have had this circuit running for several 
months and have had only one minor problem, and that is that 
I had to go to CP/M for a Z-80 assembler as the Heath disk 
operating system is strictly 8080.1 find in retrospect that my 
only gain with HDOS is faster instruction execution time, 
which created a problem with system utilities which sampled 
the real-time clock. However, the latest release of HDOS 


(ver 1.5) which is intended for the H-89 (Z-80) and H-8 
(8080), has been updated in that area (both use the same clock 
speed and essentially the same monitor). 

To enable the front panel single-step to function, it is 
necessary to remove IC108 and tie pin 8 to pin 11. This circuit 
has been operating with all of the Heath H-8 boards and the 
only problem to date that has popped up is with the latest 
version of the Heath 16K board, part number 85-2197-1. 
A minor conflict with the bank-enable exists that I haven’t, 
as yet, had the time/inclination to resolve. If any problems/ 
questions arise I will answer any correspondence. 

(continued on next page) 



Page 20 


Dr Dobb s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

287 


eftT 




Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 


if 











inDIRECT ADDRESSIfie 

FOR THE 8080 AflD 280 


BY ANTHONY SKJELLUM 

1695 Shenandoah Road 
San Marino, CA 91108 

Abstract 

The 8080 and Z80 microprocessors 
do not provide indirect addressing modes 
for all instructions. This article, a re¬ 
sponse to a previous one dealing with 
indirect CALLs for the 6502, deals with 
the implementation of indirect addressing 
in software. Three techniques are ex¬ 
plored: the “ mini-program, ” as discussed 
in the 6502 article, the self-modifying 
subroutine and the self-modifying macro 
instruction. These techniques are applied 
to various instructions which lack the 
indirect mode. As well, the use of the one 
byte RST calls is suggested as a means of 
accessing the indirection routines in a fast 
manner. Finally, a specific example 
dealing with the Z80 indexed addressing 
mode is provided. The many listings are 
provided to act as a tutorial and an 
impetus to the reader to use the methods 
suggested in future software develop¬ 
ment. 

After reading Kenneth Skier’s article 
“Indirect Addressing for the 6502,” 
in the January issue of Byte, I compiled 
a set of routines to handle indirect 
addressing for some of the cases where it 
is not available for the 8080 and Z80 
microprocessors. While the particular case 
of indirect subroutine CALLs handled 
by Mr. Skier is easier to implemenet on 
8080-type processors, several other oper¬ 
ations are not available with the indirect 
addressing mode. The particular aspects 
dealt with here are (1) the implementa¬ 
tion of the indirect CALLs as mentioned 
above, (2) the lack of indirect mode for 
memory loads and stores of 16 bit 
registers where the direct mode is pro¬ 
vided for, (3) indirect addressing for 
input-output (I/O) instructions on the 
8080 specifically, and (4) indirect mode 
for indexed addressing on the Z80. 
Besides the several general examples, 
one specific programing example has 
also been included to give the reader 


an idea of how the techniques discussed 
here might actually be applied. As well, 
the use of RST CALLs is included to sug¬ 
gest a fast access technique for some of 
the self-modifying routines included 
below. 

Indirect Calls 

Creating indirect mode for subroutine 
CALLs was one of the main points dis¬ 
cussed in the previously mentioned article 
dealing with the 6502. This procedure 
is very easy to accomplish on the 8080 
and Z80 microcomputers without the 
use of dedicated Random Access Memory 
locations as suggested by Mr. Skier for 
the 6502. Listing la provides a trivial 
routine to allow this procedure. The 
routine ICALL is CALLed by the main 
program with the HL register pair set up 
with the address of the target subroutine, 
i.e., the subroutine to be executed in¬ 
directly. The main program’s CALL 
places the correct return address of the 
hardware stack where it remains until 
the target subroutine performs some sort 
of return instruction (assuming that the 
stack is not tampered with). The PCHL 
(Program counter := HL) instruction 
directs the program flow to the target 
subroutine by executing an indirect jump 
to the address contained in the HL regis¬ 
ter pair. This effects an indirect CALLing 
system. 

However, suppose the subroutine re¬ 
quires data of some sort to be sent in the 
HL register pair (as is ofter the case). In 
such a situation this technique will not 
suffice. A modified version of Listing 
la (in Listing lb) uses a dedicated word of 
memory to store the value of HL to be 
passed to the target routine. ICALL2 
takes HL and places it on the stack above 
the main program’s return address. It 
then loads HL with the contents of the 
location MEMW, which contains the cor¬ 
rect data, and executes a RET instruc¬ 
tion. The RET fetches the top address off 
the stack which is the target subroutine’s 
address. Execution continues at the target 
routine as before and the additional stack 
usage will not affect the main program’s 
return address, also on the stack. 


Indirect Register Addressing 

In the 8080-type microprocessors, 
the accumulator is provided with indirect 
addressing over the BC, DE, and HL regis¬ 
ter pairs. In fact, the eight bit general pur¬ 
pose registers B, C, D, E, H, and L may 
even participate in indirect addressing 
referred to the HL register pair (i.e., 
MOV B,M does B:=(HL)). However, no 
such mode is provided for the sixteen bit 
register pairs such as HL which IS pro¬ 
vided with direct addressing. We will now 
consider several aspects of creating indi¬ 
rect addressing for the 8080 and Z80. 
Listing Ha illustrates the routine LHLI 
which performs an indirect load of HL 
from the address pointed to by HL ini¬ 
tially. Note that this code is not self¬ 
modifying but that it uses a 4 byte buffer 
called SCRATCH which must reside in 
Random Access Memory. The function 
of this routine may not be openly ob¬ 
vious. What’s being done is that the 
routine effectively creates a “mini¬ 
program” in the SCRATCH memory 
which consists of an LHLD opcode (load 
HL direct) a two byte operand field for 
the LHLD instruction and a RET instruc¬ 
tion to give control back to the main pro¬ 
gram. (To get a visual idea of the “mini¬ 
program,” see Figure 1.) 

memory address SCRATCH. 


OPCODE FIELD: 

One or two bytes in length. 


OPERAND FIELD: 

One or two bytes in length. 


RETURN INSTRUCTION: 
One byte in length. 


FIGURE I. The general form of 
a "mini-program" as presented in 
this article. Note that Z80 in¬ 
structions may use two byte 
opcode fields. Two byte operand 
fields occur more often for both 
Z80 and 8080 instructions. 


Page 22 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

289 




It is the modification of the operand field 
of the LHLD instruction which allows us 
to create the indirect load. The LHLI 
routine stores the address provided on 
entry into the operand field. Then it 
executes the “mini-program” with a 
jump (JMP) instruction. The HL pair is 
loaded with the contents of the provided 
address and then the program RETums to 
the address found on the top of the hard¬ 
ware stack. Of course, this is the return 
address to the main program and execu¬ 
tion continues there. 

Listing lib contains the routine $LHLI 
which performs the same function as 
LHLI in Listing Ila. However, because it 
uses the self-modifying technique, it is 
shorter and faster than LHLI. Essentially, 
the “mini-program” that was executed 
through LHLI is done in-line. The first 
SHLD (store HL direct) stores the address 
which the main program provided. It is 
stored into the operand field of the fol¬ 
lowing LHLD instruction which proceeds 
to load HL with the contents of the given 
memory address. The self-modifying ver¬ 
sion looks more inviting than its predeces¬ 
sor. However, it should be noted that this 
technique is not available when programs 
are stored in Read Only Memory. Addi¬ 
tionally, as pointed out by Mr. Skier, the 
method can be volatile and potentially 
cause disastrous results to a program if 
used incorrectly. Finally, Listing lie is the 
macro for $LHLI. It provides a means for 
direct in-line use of the self-modifying 
routine directly within the main program. 

Sometimes, it is also advantageous to 
perform indirect stores into memory. In 
this case, it is not practical to have the 
register pair also serve as the indirection 
pointer (i.e., when would (HL):=HL be 
useful?). Instead the DE pair may be used 
as in listings Ilia, Illb, and IIIc, and Illd 
(the macro for SSHLID). The routine 
SHLIDE takes six bytes of program mem¬ 
ory while the method employing the 
“mini-program” in SCRATCH is about 
three times as long and consequently 
slower. Analogous routines are possible 
for the Z80 type load-store direct in¬ 
structions (LDED, LSPD, SBCD, etc.) 
where the two byte opcode must be ac¬ 
counted for when creating the SCRATCH 
“mini-program” as well as in the self¬ 
modifying versions. 

Indirection For Input-Output 

The 8080’s I/O instructions are limited 
to direct mode with accumulator ad¬ 
dressing. That is, the ports referenced are 
always constants and the data is either 
sent from the A register or loaded into it 
depending whether the instruction is an 
OUT or an IN. Once again it is possible to 
circumvent this with either self-modifying 
code or the SCRATCH technique which 
has been used above. Listing IVa presents 
IND, a routine which creates a “mini¬ 


program” and executes it in a fashion 
analogous to LHLI. IND expects the port 
to input from the accumulator and loads 
the accumulator with the returned value. 
Listing IVb presents SIND which is the 
self-modifying version of IND while 
Listing IVc is the macro version of IND 
for in-line use in the main program. 
(Once again the same caution must apply 
to the use of the self-modifying code.) 
Listing Va contains OUTD, a routine to 
effect indirect output instructions for the 
8080. Again the SCRATCH buffer tech¬ 
nique is used. This time, data is sent in 
the B register and the accumulator con¬ 
tains the port number. Listing Vb is the 
self-modifying version $OUTD while 
Listing Vc is the macro routine, OUTD, 
which is analogous to Listing IVc. It is 
important to note that Z80 users have no 
need for this type of coding for indirect 
I/O since it is provided in the Z80’s in¬ 
struction set. Any of the general purpose 
registers or the accumulator may be used 
for the data pointer while the C register 
holds the port number. Special block 
input and output instructions (OUTI, 
INIR, etc.) are also provided. 

Z80 Indirect Indexing Mode 

The Z80 provides eight bit signed 
two’s complement indexed addressing on 
its IX and IY registers. The indexing 
modes involve many varieties of opera¬ 
tions, but the basic drawback in some 
cases is that the index is fixed. However, 
it is possible to create routines similar to 
those previously presented to alleviate 
this problem. Fortunately, the index off¬ 
set byte is always the third byte of the 
index instruction no matter which one it 
is. Therefore, one example of a “mini¬ 
program” and self-modifying code should 
serve as examples for the reader’s own 
possible use. Listing Via, VIb and Vic all 
perform an indexed MOV instruction 
while the second is self-modifying and 
the latter is the macro instruction. The 
following section is a specfic example 
which uses the macro IXMOV of Listing 
Vic to illustrate how these “software 
generated” indirect addressing modes 
may be used to increase program effi¬ 
ciency. 

A Specific Example 

Listing Vila contains a portion of a 
LIFE program that I wrote some time 
ago. The routine MCOUNT was designed 
to lookup the number of neighbors of 
each life cell on the video display screen 
which it uses and to save the number in a 
one kilobyte storage area for later access 
in determining the fate of the next LIFE 
“generation.” The point of including this 
routine here is that it uses the indexed 
register MOV instructions of the Z80 to 
access the different neighbors’ memory 


locations relative to the cell under inspec¬ 
tion. However, each of the eight checks 
requires an indexed MOV followed by a 
CALL (the CELL macro expansions) to 
the neighbor tally routine, CHECK (see 
Listing Vile). It would be preferable to 
write a loop which performs each loca¬ 
tion check in eight iterations. However, 
this is not possible with the use of the 
direct indexed addressing mode. Thus, it 
is necessary to incorporate the macro in¬ 
struction sequence, IXMOV, into the pro¬ 
gram in order to make the routine more 
efficient. This allows the neighbor checks 
to be done in an eight count loop instead 
of as a series of eight MOV-CALL (CELL 
macro) sequences. Listing Vllb demon¬ 
strates the recoding of the NCOUNT 
function to include the IXMOV macro 
sequence and an inner loop. The recoded 
version, SNCONT, uses about twenty- 
two less bytes than the previous routine, 
NCOUNT. As hoped, the routine utilizing 
the indirect mode macro is more efficient 
than its predecessor. (Note that Listing 
Vile contains references used by both 
NCOUNT and SNCONT.) 

Using Restart Vectors 

I’d like to make one last point about 
the use of the self-modifying routines. 
They are usually short enough to use in 
one of the 8080 and Z80 type RST vec¬ 
tors located in page zero. If a particular 
type of instruction is called frequently by 
the main program, it may pay off in 
terms of throughput and memory to uti¬ 
lize a RST call to execute the special in¬ 
direct instruction. RST instructions per¬ 
form one byte CALLs, and at a saving of 
two bytes per CALL, this may save mem¬ 
ory space where short, or help speed up a 
routine which is inherently time related. 

Conclusion 

In this article the implementation of 
indirect addressing modes for certain 
8080 and Z80 instructions has been dis¬ 
cussed. This included indirect memory 
addressing for sixteen bit registers (specif¬ 
ically HL), indirect I/O addressing, indi¬ 
rect subroutine referencing and indirect 
indexed addressing for the Z80’s IX and 
IY registers. As well, the use of the 8080- 
type RST vectors was touched on as a 
possible code and time saver in imple¬ 
menting these ideas. 


BIBLIOGRAPHY 

1. Skier, Kenneth, “Indirect Addressing 
for the 6502,” BYTE, January 1980, 
pp. 118, 119. 



Number 47 

290 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 



o 


i 


**«*»***»»***»*» 


SH “• 

O £ 2 ! 

u 

l-l 


«1 Ml - r-o 

£ s = i 

-Ob 4-0 

■5 55 

a* tv »— cc 

4 * <X (_) 

me oc cn 

-* 04 CJ ~ 

<- > to - 

Q. •-< w — 

o tr> - CN 


Ml AS o 
•>*-*- 
(. a- a 

S»s 

s: JS c 

ft v 1 
> 

•H ft ft 
Pin r 

£2^ 


S 

? c c 

m m e o 

t 0 •* 

: : P> h v 

c o -*-> a 
• « 3 

*- Q. 3 f- 
9» (- -»J 

O ♦» m 
_ _ _ C ¥* ff 

04 U O f> CL -** C -ft 

— "I I «J •** 

: j O 

' <= <t l— _j 

hOuji 
c ce _J 


r5j 

O u 


c 

o 1 
a 1 


: 4* c 

■ * ♦* -4 . 
I X 04 ro 
L ft (. > 






Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

291 










Number 47 Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 Page 25 

292 


















LISTING Hid. : LISTING IVb 



Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

293 


























Number 47 

294 



o <r 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 


NVI H.NOVAH i stick in "NOV A,K" opcode 

; which it the second byte of 
; the direct index node opcode 
















tn o 

+• Ui 



Hint 



* 



****** 

£ 



• 

i 

; § 



3 53 

01 O 




O U ^ 

O ai 

1 t ~ s. 


Silt 

fTJ pH ♦» Ol Q 

1*1 

5 2> ^ tin 

* u « 


"O «_l 3 »-* 

52 2^ 

■•H £ C ll U£ 

w m ♦> u 

m ^ u $- •> -pH 

o k C 
■h h r 
£ 3 u 

* *- <r 

• O C 


oc 3 m 

uJt m -H 

•*■> %- *J PH c 

O -H fc -H H* 

•pH ■»» • 

0) ♦> 

* S ■¥> O 


•-h a v- a. 

- * Ql ^ P ** 

o T? PH Ol 

* ■** P M 


5 > ( ° 

*0 -r* <2 S’ ** JQ 3 

V U 

• C (7JU. 


(O O • w 

A C Of C M A 

%- U Ol V- 

* « • —1 


-i o* c 

X U U H* 3 • • 

—• C 3 Ol 



e •> 

a* A V 3 V «• 

C D» M at 



M -C Ol 

j « K U Ok * 

UJ U £ HI k- _J Of 

X Of o o 



CO i- 

t-> c -P> ♦» 3 _J • 

^ • 1^ C i» « 3 

A 

O S 1- >. 



MOO 

k a3 ■»* C JTJ cr> 

0-0.0 



lO O -ph c 

A M O O PH Ol _ -pH 

-PH Ol X pH 


CD 

4i ■*> 0 3 cr. 

«f _ _ it «> u c 

c c 



PH e 

£ >> C £ O «« £ O 

•ph o c a. 


cn 

3 U Ol -pH 


k. ♦* n 

* at 

—j 

(• W pH 1 A 
k —< 

.. 

> w o w 

* o 

ai 

m a> ^ a< 3 
•«* Hf u > C 

Ol 

♦» 

M 

p* ♦» Of -O 

• at 

3 

H -P« • pH « 


H C f— • 


«* 





52 


3- S5 


*- >v 

e u i 

f 2 j 


O p« pH 

O U 

-C o oi 
tf > 

•»h m t- 

S « ai 

in p-< 

ai a» —« 


c * 

c ■*» 


T? -pH 
-ph 

> V 


"& ♦» S . 


•H C WV 'O cr> ai -»< v- ■o a» 


o 3 Of ~ » r4 ,4 ^4 (. 

«*» o - - - — - - 

u 

c -• 

•pH p* 

o at 
Q. u 


■O IT> t C 

■-* ■** 3 a* 


-*> u C ^ a* C 

♦* 3 V C -ph 

c x -*> O O O ■*> 

••h • X u o -O ff 

~ • o 

c w m o 


u > e 

Oi <- 

u « o * 

rt h Id HI fc 


*-*-*-«■ 

• Of T. - -- -- 

18:£22 8 g 52 


<- «f» t >- ai v 

i-uiiuvniivio 


'•O *1 • c V 


•p-h—«MOO.(OT>> 




Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

295 

















Number 47 Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 Page 29 

296 













Cl 

a u •> 
© © 
CL _l 


.. 


Ll 

O' 


y- to 


LU 

LU 




O 1- 

2 


© 01 


<r 

o 


LU 


Cl y- 



=> CL 


X o 

X 


X 


CL 

o 


1— 1— 

cl 

cl y- 


X 

LU LU 

01 

OHIO 

X 


01 01 


CL 01 Q 

3 

01 

.. ... 


... .. 

... 



> 
i— 
01 


X 

o 

— CJ 

X LU 

3 Cl 


+ © »- J- CO H- 

x^. x CCi Ul <r I © LU 

*-• w oo ca to Q o to ui 

- z -• Cl Z K 00 Ci CL 

~ u ^ o -• x> ~ o <r 

Nj C/7 © <1 E <1 CO ll <1 X CJ 


LU <1 O 
01 Q « 
2 1-0 
►- O ~ 

co 0 . <r 


4ft CN 

I x + »- X 

> © X <X © 

CO CO ►- Cl CJ 

<1 LL Q - o 

- - o - c> - 

pn X <1 Cl <E 


CO 

x + h- X 

CO X d «t 
CQhQU 

a ~ i- o 
o - x - 

2 <1 CL <X 


I Q — 

> Q iN *h I 

_l Q + CO 00 

<x cl ci x z 
-- . o - 

H N E ^ (/) d 


Cl ~ 

Cl CO — X 
Q + 01 (J 
ci x z 
o — — ~ 

X — CO <1 


I 

> X 
CL CO 
O CO 
d Cl Q 

- . o 



4ft 


1— 

X X 

y- 

<L X 

Cl CO 

— <E 

Ci O 

CJ CO 

01 Q 

y- in 

d(LQ 

2 y~ 

x - 

- - o 

t-i _ > 

cl <r 

— pn X 

<X 01 0- 


LU X 

CO 00 

> z 

X >—« •» 

U Old 


—I -J —J —J _I I _I I _] _J _J _J _I _I _I _I _I _I I _I _I I _I I 

_ -J CL _ —J —J —I —I ►— —I —I <X —I —I ►— y— _I _I J— _J _J t— _| _| l— _J _J I— I— _I i'i | | k— l_ _I (J I _I ►— _J_J l— (j 

0JdpQU < lLCddQUJddC£:ddQUJ»-'CCdOdQliJdQdQLJH(tdQdQLiJdQdQLiJ*-'CCdLJddDLJ M £CdZd | ICiLUddOliJZ 
cooo—Itruwuuuicuotroo uctffl - , cjjcjjce(jJtj_iQcaj“jcjJOJQCo_j(jja:co - jocioojQccociS^oojacooja:»-» 



y- 



CL 





CL 


CL 




X 





01 





3 


3 




H 


© 



-J 





CL 


CL 




01 


Cu 



Cl 





cu 


CU 




CL 

o 


00 o 

o 


CN 

CO 

«*- in 

>0 


00 

& 

o 


CN 

CO <3- 

© 

o 

© o 










CN 

CN 

CN 

CN CN 

Nj 

-0 

>0 -o 

NO 

«o 

>0 

O 

NO -0 


« 

-o 

o 

-u 


•O 

>0 O 

o 

o 

o o 

o 

o 

O 

O 

o o 

o 

o 

o 

o 

o 

o 

o 

O O 


uoNjr^coOk©~«cNco3inNjr^ooo© 

CN CN CN CN CN 00 00 CO CO CO CO CO CO 00 CO 3 ■ 


CO 


in 

-0 


CO 

O'- o — 

IN 

CO 

*3- 

in 

NO 

r- 

00 

in 

in 

in 

in in 

in 

in «o o 

NO 


O 

NJ 

NJ 

NJ 

NJ 

o 

o 

vt) 

>0 

>0 

>0 

N1 -o <> 

N1 

-o 

NO 

NO 

NO 

NO 

NJ 

o 

o 

o 

o 

o 

o 

o o o 

o 

o 

O 

o 

O 

o 

© 


■r-* 

<3- 



in 


<3- 

in 


in 

N" 


*3- 

in 





in 

■N 

in 


in 

co in 




in 

CN 

«3- 


in 

CO 

«3- 





UO 


«3" 

in 



in 

in 




»r 

© 







h- 






r-'. 






© 



r^ 

© k 




h- 

© 

h- 



© 

r^. 











fN 

h' r" 



r^- 


CO 

Q 

00 


<x 

Ll 

co 

co © 


<r 

© 


co 

© 

© 


iu 

o 

CN 

© 

© 

© 

0-4 

© © <3- 


© 

CJ 

© 

r^. 

o 

co 

© 


© 

<j 


© 


CN 


© 

Cu 

© 


© Q CN 

© co 

© 


•3- 

© 

(J LU 




>-•1 

LU 

a oo 



© 


LU 

© 

<T 



o 

co 


© 

o 

OO 

N © U 


'j 

o 

CN 


© 


CN 

h- 

© 



'd- 

CN 

•'■7 


© 

© 

LO 


«3- © CO 

© © 

Nj 


© 

© 

CJ 

i—i 

— LU 

CN 

© 

00 

© 

© LU 

Ok 

© 

© 

Ll 

© 

© 

© 

Ok 

© 

© 

© © 

© 

© Ok 

© 

© © © 

O' 

© 

© 

© 

© 

© 

© O' 

Q 

© 

© 

© 

O'. 

© 

CO 

© 

© 

© 

© 

© 

Ok 

© © © 

CJ © © 

© 

0k 

© 

O 

a 

(J 

O CO 

CJ 

o 

CJ 

o 

o co 

o 

CJ 

CJ 


o 

CJ 

CO 

o 

o 

CN 

CJ 

© 

CJ 

CO CJ 

o 

©0(0 

CJ 

o 

CN 

CJ 

© 

CJ 

CO CJ 

CJ 

© 

o 

co 

o 

CJ 

CN 

O 

co 

o 

o 

CO 

CJ 

UNO 

© O CJ 

© 

CJ 

O 

CJ 

co 

LL 

CN CO 

in 

NO 

Ok 

CQ 

LU r-s 

co 



<X 

© 

© 


co 

<3- 

<■ 

co 

© 

© 

CO 

«3- 

<x © 

© 

© 

CN 

9- 


<x 

© © 

© 

co 

sO 

CN 

© 

CJ 

© 

© 

co 

<3- 


<r 

CJ 

Q © —i 

n- in © 

© 

© 

© 


Nj 

Nj 

r- r^. 





co 

00 

© 00 

CO 

CO 

CO 

O' 

a- 

Ok 

O' 

O' 

■> 

» 

<r <e 

<r 

<r a; <r 

<E 

© 

© 

© 

© 

© 

© © 

o 

O iJ 

Q 

(J 

o 

J 1 

© 

© 

© 

© 

© 

© 

© © © 

© © © 

© © 

© 

iu 

CO CO 

co co 

co co 

co 

co 

co co 

CO 

n 

co 

m 

01 

CO 

CO 

co 

01 

CO 

© co 

CO 

© co 

co 

CO 01 co 

01 

•71 

m 

07 

01 

© 

CO © 

•?0 

co © 

CO 

CO 

CO 

CO 

CO 

© 

n 

CO 

07 

07 

© © © 

© © © 

© © 

07 

© 

r^. 

1^- 




N 


r- rv 





fN 






r- 


h* 

jn. rv 


N N N 



fN 

K 



i"-. 

N 





N 



r"> 

h* 


fN 


i— i— 

r^-1— r— 






Cl 


<X 

y— 

to 

2 


<X 

o 


* <E 

pn I— 

- <r 


© 


© 


iff 

Ll 


CL 

CL 


3 

07 



__ 


iff 





© 



<r 

CO 

01 

© CL 

© 

X 'jL 

CL 

© 

© 

© 

y— 

CJ 

© 

X 

CO 

CL 

© 




CL 


CJ 

y- 




X 

07 

or 

© 07 

<L 

01 © 

© 

f— 

07 


> 


iff 

© 



iff 

© 




<L 


y- 

X 

> 


X LU 

i— 

2 <r 

© 

1— h- 

Cu 

© 

2 

O 

© 

© 

© 

Cu 

l“l 


© 

CL 

CL 


© 

1— 



' h— 





X X 

© 

© if) 


CL 


y- 


1— 



T~ 


CL 

O 

'© 


© 

O 



01 — 


l_j 

^ f— 

X 


O 

iff 

y- 




l— 

<r 


Cu 




1— 




CL 


© 


■J 

© 

if) if* 

CL 

K 1— 


LU 

© 

y- 

1— 

© 

07 

y— 

m 

X 

l— 

© 

y— 

ul 

y- 

© 

y— 


y— 

> 

y- o 

© 

X 

<L © 

5 

© © 

o 

O 2 


© 

© 


© 

o 

<r 


© 

01 

© 

© 


Cl 

© 

O 


<r 

© 2 

X 

CJ 

X 1- 

Ll 

© CD 

© 

© <r 

X 

© 

CD 

«I 

y- 

CL 

X 


01 CD 

<L 

01 

CL 

co 

CL 

if> 

© 

co 

iff 

O <E 

o 


o >- >- i 

OlH. M | 

X <X <E 

©-->--■. I 

o — o —< cj <x : 


—« i —« —« 

+ co + + 

X _J X X 


3 Ci 
. 2 
CO LU 


X X 

u u « « 
Cu ill d (J 


2 — Cl 
> LL Cl 
LU “0 O CO 


U d U U U O d ' 


CL O -* X 


I 

h- Cl h 
*—' © © 
CO CO CO 

d LL U lit 

- - o <r 

— pn X • J 


© <X X 
CO l_l O 
Z h- o- 


~ 0 . <t 

- O LJ - 

<1 X CO co 


W <E CL 
d CO ^ N 


0 J d d d d u h Ci _J Cl 

ULCiCLCCCZ^QQQUlillXLCLtQQU. 
LT li: CC LC lC d CO J d J J “M_I d " u J J ~ 


_j <x _j _j y- h- j j d j j h- co _j cc> cih- 
dJdduLiJMLCddJddQLUUdl'QQX'HiE 
OOHJOJIirfflOOOKOOJCCEOQ-1 J d CO “ 


5 

^3 


X 

y- 

-J 

X 


CO 

*3" 

UO 



01 

Ok 



CN 

00 


lO 

Nj 


Ijj 


© 

4 

CN 


*3- 

m 

Nj 

r-N 

00 

a © 


CN 

CO 

3 

IT' 

*3" 

*3- 

*3" 

«3- 

*3- 

■3- 

<3- 

u • 

uo uo 

U"> 

u • 

UO 

u-i 

in 

U‘| 

UO 

NJ 

NJ 

N.I 

N.I 

NJ 


NJ 

Nj 

NJ 

nj 

PN 

P^ 



r- 

in 

a ' 

UO 

in 

U • 

U • 

in 

ll • 

U7> 

UO 

u 

U.' 

U ' 

in 

u 1 

u 

u • 

li i 

in 

in 

ll • 

in 

ir< 

UO 

in 

in 

uo uo 

in 

U‘i 

uo 

U" 

in 

o 

O 

o 

o 

o 

° 

o 

o 

o © 

© 

© 

© 

© 

© 

© 

© 

© 

© 

© 

© 



o 

© 

© 

© © 


© © 

0 

0 



















■3- 




■3- 



















© 

© 





© 

© 
















© 





© 

© 


O'. 

© 

© 

Nj 


Nj 

CO 

N7 


<3- 

Nl' 




«3- 




o- 

0 . 

CP 

•> 



<i 





© 

■3" 


o 

r3 


© 


<r 


© 


© 





i—i 





• •• 


... 

01 


© 

© 

© 

© 

© 

Nj 

CO 

© 

© 


LJ 

o 

© 

LJ 

00 

LJ 

LJ 

NJ 

co 




*—• 

uo 

© 

© 

iii U0 

UJ 

UJ 

© 

CO 


CJ 



—• 

*-« 

© 


•3- 

© 

© 

© 

CN 

IN 

d 

*-• 

© 

i—i 

O 





© 

CJ 

PN 

3 - 

O © 


CJ CJ 


© 


'-l< co i>. o 


o o 

pn 

CO IT' CO U0 
CO 1 ^ O - P" 

-« <X *- <E 
CN Cl 0-4 Ci 
Cl >' 4 Cl CO 
U. □ IL U 


•>. 

© 

T-t 

CN 

CO 

3 

uo 

Nj 

r^- 

<jj 

O' 

© 


CN 

CO 

3 

in 

07 

0 

O' 

O 

o- 

o-. 

O' 

O^ 

cr 

O' 

CP 

© 

© 

© 

© 

O 

0 

in 

m 

uo 

UO 

\n 

in 

m 

UO uo 

in 

uo 

Nil 

Nil 

Nj 

Nil 

Nl' 

Nj 

© 

© 

0 

© 

c- 

© 

© 

© 

© 

© 

© © 

© 

© 

© 

© 

© 


CN 3 uo 'ONOJdUQlLCMION CO CO Cl O CO U0 

U. Li. U. It Li It li U. L. L. O O O O O O - -H 

>N iN (M M CN W iN 04 «N 04 «?0 CO CO CO CO CO CO CO CO 

r^.r^r^0'r-o-r^o>0'r^r^o-r^r^r^r^o-o-0' 


co a o a uj o h co lo o o- <X © —' IT.' 

—• — —* —' —^ C-4 <0-4 *>4 'N 0-4 04 04 04 CO CO 

CO CO CO CO CO CO CO CO CO CO CO CO CO O') CO 


3 

in 



uo 

© 


pN 




© 

cu 

cu 


© 

CN 

© 

UJ 

Ci 

a- 


CO 


LJ 

Cl 

© 

o- © 

© uo 

a 


in 3 liO in 3 

o- p-- 0 - Ov 

<L O CO CO 'DC' Li O d lii 

’-i 04 LU Q O 3 t-* © 


tfj Hi u O W lJ‘J '» d Q O ^ <t N '>• d 111 ’-t CM (O -O N 

co co co 3 3 3 3 3 3 3 uo uo u - « in in in in ni Nj >o o o o 

CO CO CO CO CO CO CO CO CO CO CO CO CO CO 01 CO CO CO 00 CO CO CO CO 


Page 30 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

297 









LU 

Cl 

O 

£ 


cl 

01 


O LU 
_J Q 
U 

Ci cl 

■coo 
o u 

I- O CL 

I- 

<E O 

h- U K U 

duUJI 

a <L if) o 


z 

s 


a 

o 

£ 


O 

g 


o 

01 

LU 


I 

~ -T ~ O 

O i-t LxJ & 

+ <L + h- + Cl | 

X X CC XUJxd CM 

01 O — <r ►- CO —■ Cl o 

z in >-0 <i ^ o: -> . Qj □ a 

h-i tO « .OO * > <1 . N . d , 

to CQ «C •CiEOHD<IUfOZ<lLL<r 


CO 

o 


CO — 

o + 

Cl x 


LU 

£ 

o 


<r o 
t- o 
CO <x 


O LU Cl 
+ CO I <E I <T w 

X Z O LL O LL —' o 

0 -to - .0 ~ 

•^WOn 5n<0£04 


<x 

o 

f- o 
h- 

<r 

h- O 
<1 O 

ci <r 




<r 











o 

X 

<i 




<r 

+ 

CO 

c 

o 


X 

<x 


CQ 

<L 

+ 

to 

■t 

<x 


o 

Ci 

X 

z 

h' 

a 

<r — 


O 




o to 


<r 

£ 

— 

if) 

<x 

£ CQ 

CQ <£ 


lC 

cc 

C' 


_J J I _J 

J ll I— CO _l u j _I ►— o CJ <X 

(TOQLUUJdDQQclMCCQiiQd 

CJCL_ICCCCCJCL_J_JtJd~<X— <XC) 


LC 

o 

01 


o 

o 

cc 

CL 


—I -J _J _J _J J I _j 

_J u H-Cl l— —I _J ►— _I _J h- _J Oj CQ LL _J Q_ *— 

L-i cJ Z lC Li. LC UJ ■—1 Cl LlI <T Q CC Cl UJ <T Q <T O 1 1 1 — 1 >—i 1—1 —■ <T~ 1 —■ 1—1 1 1 1 

jociuTtoiLJirojojicojojKOflljjwcjaSja 


h- Q 

x Z 

Z £ 

O 

o 

H- O 


hh O 

o <x 

Cl Ci 


O 

O CC CL 

- « _J z 

<C O X — 


cc 

o 

Ll 


n 

o 

cc 


LlH-I—LL 
OH UJ O 
CO CQ CC O 






<r 






4 






LL 






LL 


CM 

CO 

'4- 

in 

v0 


co 

o 

O 


CM 

co 

CO 

W 

CO 

co 

CO 

co 

CO 

w 




't «*■ 

r^ 

rv 

h- 


h- 

rv 

rv 


h- 



r^- 

o 

o 

O 

o 

o 

o 

o 

o 

o 

o 

o 

o o 





-u* 






UJ 






CQ 






ir» 


««■ 





in 



o 




r^ 




O 

r- 



o 


o 


Cl 


to 


CQ 

't- 



LU 

CQ 

CQ 

co 

LU 


in 


y 




r-. 

Ci 

y 

o 

Cl 


LU 

o 

Ci 

p in 

i^. 

Cl 

Cl 

Cl 

o co 


Cl Ci 

z z 

£ UJ UJ 


05 

LL 

c 


U- U_ LL U_ LL .. £ UJ UJ - O 

22 £: ,9 £ G? S K? ;£ E; SS £: 9 ^ c 2 t 10 ^ ^ a> o o ^ cm co «4- in o ix 00 c* o cm 00 <4- in o rx 00 O' o cm co «■ 

If' 1 !P If' \L ■' IP m w p o o o o *0 o o o o o rx rx rx rx rx rx rx rx rx rx 00 00 00 co 00 co 00 00 co to O' o- oo o 


Ml 

Ll 

O <4 — 

O fx O 

l N CO O CO O <t CQ 

> MUOO tO O O 

> 00 rx a o <■ 00 uj on 0 ■ 

• CO CM Q o Ul CM U CM Ci • 


•t N CO <1 Ci u. (N O) <t N <1 UJ O ^ fO in 0C> CQ Q U. CO N O) <1 1 

rx rx rx rx rx rx co 00 co 00 © 00 o- O'. o- •>. cn O' o •>. <x <t <x <x <c < 

«4-'4-«4«4-'4-<4-«4-«4-<4-<4-'4-«4-«4-<4-«4-<4-*4-»4-«4-«4-ri-«4-«4-«4-<4-«4-' 

- ^ - - - - - * - - - - ■ 


O'- 

o 


CN 

CO 

in 

O 


01 

O 





U 1 

•u 

>0 

M.» 

o 

-o o 

-O 

>0 

Xj 

XJ 

rx 








h' 

rv 


rx 




|x 

rx 





o 

o 

o o 

o 

o 

o 

o 

o 

o 

o 

O 

o 

in 



uo 

o ^ 



in 






o 














Ul 

cc* 

to 



I s - Q 

«4- 









i—i 

m 



uj 









l—l 

Cl 

Ul O 

L—l 

ci a 

Ul 

i> 

a 

in 

r^. 

a 

o 





•_) 

L—l tO 

co 

Cj 

o 

to 

*4- 

a 

O'- 

CO 

Ul 

V—4 



h- 

<x a 

o 

•N 

to 

o 

rx 

0.1 

CQ 




CQ 


CQ 

CQ CQ 

to 

O 

to 

to 

o 

■ i 






tj - 


*4- 


•4- 

*4- 

*4- 

*4- 

<4- 

<4- 

■4- 




o 



«4- 

<T 



IX 


O 



CQ 

'Ll 


y 

CM 

O' 

IX O 

CM 

O 

CO Cl 

rx 

<1 

QQ O 

ci 

Q 

Cl Ci 

<4- 

*4- 

<4- «4- 

fx 

rx 

fx rx 




CQ 

O <X 
h- 

Z O 
h- 

z 


p 

tD 





c- 



to 

o? 






£ 


£ 

X. 


CM 

_J 




h- 



Xi 


>0 

U 



t D 

z 

to 


O 

CM 

CQ 

o 




<L 

LU 

Ul 

UJ 

•10 

Q 


In 

> 



_1 

£ 

Ci 

Cl 

<r 

in 

U 

xD 


CQ 


U 

UJ 


O 


>0 

O 


CC 



-J 

cc 

£ 

o 



II 

_J 


•X 

to 

LL 

Q 


y- 

II 

CL 


o 

O 



£ 

u 

-J 



O 

3 


1- 

o 

LL 

Q 


<X 

h- 

3 

X 

Cl 



h- 

Xi 

O 

LC 

£ 

_l 

P 


IX 

to 

<r 




CO 


X 

s 

H- 

LL 

i— 

to 

h— 

Q 

LU 

to 

to 

iX 

01 

O 

CQ 

<L 

y 

LU 

z 

X 

LU 

LU 

p 

LU 

QQ 

to 

a 

<x 

to 

<r 

o 

Cl 

IX 

CQ 

l- 


> 

h— 

UJ 

if) 


y— to 
<r to 

Cl <L 


to 

Ul 

CL 


<x 

o 

H- O 


(J 

to 

<1 


3 

to 

UJ 






CM 




H 




+ 


+ 

<x 

LU 

X 

to 


X 


X 

<r 

05 

c> 

to 





<r 

z 

«4- 

a 

<r 




Ci 



o to 



to 


o 

01 

<X 

£ QQ 

QQ 

<E QQ 

QQ 

>0 

£ 


X LU 
HI tO 

■a: — cc 
to - . <L 
CQ CQ <X tO 


I 

w 


I 

CO 


— - CCi LU lCi 

■» (N| - tO ~ 

CO Z <1 Cl <X 


_ _ CO x CJ 

toicciifflw <r 

ZOtflOtOv o 

M o . o . - to . 

C0ONONM5CQ<I 


<r . 

Cl <L • 

o to * 


O -H x 

+ to CO 

x z 00 

~ to 


<1 

<r 

Cl 


o — 

+ to 
X z 

HH H-. to - 


Hi ill <1 III - U) Cu d £CCiCCi<ECQ'^tOCCi<X 


ci <r >- 
oto . , 

£ CQ CQ <L CQ 


-J -J _J X _J X 

-J to _J h- _J u:> CQ U Cl I— to J to 

<iuj<rauj<iDQQ='00""- 


2g23g2£33g8£ggSg33g8S%S^Sg38Si^fc^g£3gS£35g3S£3gg£9353g£3gSS33g3 


to 

CQ 

to 

Cl 


0‘O^HCM(o^in>oh-oo 


CNO — CMCO«^in>ONOCiO- 

rr 1 ro 1 V 1 1 V 1 .Vi rt\ m rr, r.-, 


to 


UJ 

to 






CO 


<x 

CQ 


Cl 

CQ 






o 


LL 

to 


01 

01 






CQ 


5 

Cl 


a. 

CL 






01 


CL 

O' O 


CM CO M- 

in xj 

rx 

00 O' 

o 

_« 

CM CO 

«4- in 

Xj 

00 #o 

■> 

O-. 'O'. O - . 

O o. 

o 


o- 

o 

o 

o o 

o o 

O 

Xll xj 

Xj 

xj xj Xj 

xj O 

Xj 

xj Xj 

rx 

rx 

rx rx 

rx rx 

rx 

O O 

O 

O O O 

o o 

o 

o 

o 

o 

o 

o o 

o o 

o 


CC 

O 

LU 

CL 


»CSCO’tins5MXiO'O^CMCOtin*ONOOOO^ 
, ^ ^ CM CM CM CM CM CM CM CM <M CM CO CO 

.rvr^.r^r^r^r^rvr^r^r^r^r s -r^r^r^r^r^r^r^r^ 

>00000000000000000000 


rx 

QQ 

rx 

CO 


|X 



o 





o rx 



O 

rx 


o 






o 


rx 





«4‘ 

CO 


if) 



Ul 





LQ 

*4" 



UJ 

CQ 


lQ 

CO 


•N 



rx 


co 

O 

00 

o 

*4" 

P 

CM 

LU 

<4- 



in 


rx 





y 




rx 

a 


y 

o 


o 



rx 


UJ 

CO o 

o 

O 

Cl CQ 

Ci 

LU 

O'- 

Cl 

rx 

a 

o 

U 


O' 

Ci 

ci in 

rx 

Q 

Ci 

u 

Ci 


00 

CO 

00 

rx 

Ci 

u 

Ci 

•o 

go 

UJ 

CO 

to 

a 

o 

CO 

to 

to 

co 

«4- 

Ci 

O' 

CO 

to to 

a 

to 

to 

•=r 

a 

to 

co 

Cl 

8 

•> 


O' 

CM 

a 

CO 

to 

Ul 

CM 

u 

CM 

0^ 

O 

UJ 


co 

«4- 

rx 

00 

O'- 

to 

Q 

LU U 

o 

<4- 

rx 

CQ 

O' 

to 

u 

o 

•4- 

<« 

rx 

O'. 

<T 

CQ 

UJ 

u 

CM 

«4- 

Mj 

CO 

u 

u 

u 

o 

Q 

o 

o 

o 

o 

o 

O 

Q 

p 








CM 

IN 

•N 

CM CM 

CM 

CM 

CM 

•N 

CO 

CO 

CO 

CO 

CO 

CO 

CO 

<4- 

'4- 

<4- 

<4- 

<4- 

4- 

»4- 

*4- 



<4- 

•4- 

<4" 

■4 

•4- 

*4- 

*4 

<4" 

'4' 

«4- 

<4 

<4- 

<4" 

<4- 

<4- 

*4- 

<4- 

■4- 

«4’ 

<4- 

rx 

rx 

rx 

rx 

rx 

rx 

lx 

rx 

rx 

lx 

rx 

rx 

rx 

rx 

rx 

rx 

N 

rx 

rx 

rx 

rx 

lx 

rx 

rx 

rx 

rx 

fx 

IX 

IX 

fx 

|x 

rx 

rx 


in o o 

o o r- 
to ul h* Ci 

<c — ui 

UJOQinNQOQU' 


in o o in 00 

o o s 00 

CO ^ LUNQ« 3 -« 3 - UJ 

co-^ r^r^uio-H r^r^ 

'UJ^QinNQOQQ-HUJ«>QinNQiXiQ 


■ ■tiDNOjcaqQOH 


Number 47 

298 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 

















UJ 

UJ 



<r 




CL 

CL 
























z 

z 

X 


CL 




UJ 

2 


























OO 


z 




1—1 
















X 


cc 









X 




CL 


d 

o 

> X 




> 




CL 



CL 



l— 


1— 





X 

X 

X 

>- 

CL 


o 


1— 



z 

— X 








k- 



H- 



X 

X 

CO 





X 

X 



X 


z 


CO 


X 




OO 

X 



X 


X 

X 


X 



z 

X 

z 



o 




1— 

1— 

X 




z 

X 

X 


o o 


X 

X 

o 

X 

X 


z 

X 


z 




X 


>- 


o 


o 

o 

X 

X 

d 





X 

<L 

X 

J— 1— 


X 

<r 

h- 

OO 

UJ 



UJ 



> 



z 


CL 


X d 


J— 

1— 

CD 

X 



X 



1—1 

X 

X 



CL 

X 


X 

z 



Z 



CL 


X 


X 

CL 


\— 



X 



X 

X 

3 


X 

z 



CL CL 


i—i 


CL 

CL 



X 



X 

CL 


H 


J- 

<r 


d o 


X 

1- OO 



OO 


d 


1— 


z 

o 

X X 

> 

X 

o 

X 

X 



l- 



r- 

d 


>- 

> 

>- 

o 


— h- 


X 

X X 



d 

z 

X 

X 

> 


CL 

CL 

X X 


d 

CL 

X 

X 

>- 


> 

X 


> 

CJ 

>- 

X 


X 



Q 

z 

X 

X X 

X 

> 

X 




X 

X 

1—1 

X 

OO d 



X 

X 

d 


X 

x X 



X 




CO X 


X 

UJ 

X d 

Z5 

CL 

O CL 





o 

X 



X 

IN 

I 

X 

X 

IN 

z 


X 

X 


OO 

X 


X 

X 

X 

—I 

X 

ll 


I K— 

Q 

CD Q 

c n uj 

CD 

CD 

X 

1— 

CL 

X 

X 

X 



d X 

X 

X 


<n 

X 

_l 


OO X 

_l 


X 

no 

X 

z 

X o 

cc 

X 

o 

Z d 

o 

X X 

X X 

X 

X 

X 

=- 

X 

IN 

z 

X 

o 

z 

CL X 

rN 

d 

z 

CL 

X 

X 

o 

X z 

X 

o 

X 

X 

d 

CN 

x »— 

X 

X 

1— 

— a 

d 

rN d 

d d 

rN 

rN 

d 

X 

rN 


CN 

d 

h- 


K X 


X 


h- 

X 

X 

h- 

d CN 

X 

»- 

00 

X 

- 

- 

•* •• 

- 

•* 

- 

- - 

•* 


- - 



... 


.. 



... 

... 

... 


- 

- 

•» 

- 

- 

- 

- 

- 

•• 


.. 

.. 


CO 

— + — & 

X x X I 

X ~ X 

— <r — o <r ~ 

I--' —J * <. ■. X . 


I I h- X 

— — O — — 

x UJ X J - - X _| , 


CN CO 

~ t* 

_J | X 4 * X _J I 

Ihn | m X I— 

^ d O •-« 

. X .. _J .. -. - X. 


CN O — 

~ + + + «* 

—J x X > >- ' 

X M o Q H H H- 

^ d O - ~ • 

- - -. > > .. . jx. 


“DI<I<IUJI<I<IuLlJI<riU<lMQUJIUJQUJIUJIQlxJ<lLL<II<IUJQUJl<i<IliJDMi-,ijJi£liJIUJD 


—I UJ >- x 

X OUHH , 

— O - , ~ ~ <x • 


' CN 

t* — + — 

I _J x X 

_ _ H- X - X 

o <r — ^ o 


<r<ruj<r<riZiujx<r<rLiJX<r<i 


O Cl CJ CJ CJ OO X O CJ CJ DO CJ Q Cl CJ Cl Cl CJ CJ Ci CJ CJ 

^ 2 HyClZQuQaZuCdC|JuCC2CiQCZuZDa:QLCQZQQQ£CZQQDQQQQQiZDuQQQQQDQQiIZQQQ2QD 
• —I <X —I •—* —I <X —I -» M J O J Cl u. -> *—• —I —I JMjwJOJOjM«ijj-jMj<ijjj<ijj - ll —'XXXdXdXXdX“*—'XdXi—<Xd 


0 .' •> o — <N co ^ 10 no 'X' cr- o — cn co «*■ in no r*. co •> o — cn co <3- uo no co i> o —« cn co ■t in ^ n w o o ^ cn & **" no no ^ 00 c^- o — cn co «s- in no c* 00 o o 

IT 1 li"J •O «£i -O >0 >0 ■O •£! N N N N N I s - N N N N 05 CC' 0) CO CO 00 CO CO 00 CC 1 0^ ^ ^ O' iJ- ij' O-. (?•• i>. O ^ O O O O O O O O ^ •-i >-• »h th ^ h th h H N 

CO 00 CO CO 'X CO CO CO 'X> CO 'X' 'X' X' CO X' X X' X X X X' CO X' CO CO CO X CO CO CO X X X CO X X o:> go X X x CO CM O O-- O- O X O- O- •> X X X X X O’-- O X X X X 

OOOOO OOOOOO OO OOOOOO OOOO OO OOOOOOOOOOOOOOOOOO O 00000000000 00000000 


x o o 

<r x o — uj uj 10 

Q X OX IT) X UJ 

CO CO X Ci X CO UJ UJ X X CO UJ X D Q h 

UCNXQiniNXObT'HiNX^QQQ 


CN CO 

o o 

x ox x uj 00 uj o <r 

U0 O X O X O CO 

X CO X X X CO X CO X X O X Ci 00 X X X X CO l 


■ cn uo in ui q ^ q n x in - n x q in *h u. 


o o 

o 

CN o o — o O CO — CN 

o o o o • o o o o 

X o «-• X X X ^ O — X X X X O X X o 

X O CN — |J-| if) 04 O CN — X uj X O O X O 

0 X X Cl Cl Cl Cl W CO X X Q U Cl 1—1 X Q X X X CO X Cl X X X X 


•HNl/)HXXXQIf)XOITlH(NXQIf)NXO 


dCXXCNX^-lDXXdXOX^O-J^XXXdOXXXO CN lOXdXOClX'-'CNXXX x Ci X CN lj ~' x X X X 

ioioioioxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx X X X X X X X <X d d d d 

in in in in in uo in in in in no in in no in in in in in in in in in in in in in in in no in in in in in in in in in in in in in no uo uo in uo 

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXI^XXX 


UO X X X X X — X X X Cl X O — CN in X X X 
ddddddXXXXXXXCJCJCJCJCJCJO 
uo uo uo uo uo in uo uo in uo uo uo uo uo uo uo uo in in uo 
r^t^r^xxxxxxxxxxxxxxxxx 











X 

— X 








> 



Q OO 







CJ 

X 



O X 



X 




CJ 

d 



Z X 



d 



CJ 

X d 

X 



Q 






o 

d 

X 



X Cl 



CJ 



o 

X X 

X 

> 

X 

CO d 



X 


CD 

CO X II 

X o 

o 


X 



X 


d 

rN d 


X 



o - 



X 


X 

X CJ 

z z 

z 

o 

o 

1- CJ 




X 

X 

X X CJ 

XXX 


1— 

»- 



> 

h- 


X d 

X — — 

X 



d z 




X 

CJ 

X rN 

X OO OO 


X 

> 

— 


CN 

CO CD 

5 


X 



X 


d 



X 

X 

1— 

CJ X — 

IN X ^ 

X 



Ci X 

X 

X 

X rN 

X 

X 

d 

d CJ 


X 

X 

X 

zo 

10 


X 

OO 

l- x X 

l- X X 

l— 

X 

X 

I h- 

o 

o 

O X 


X 

XXX 

XXI 

X 

X 

X 

1- >- 

X 

X 

X Cl 

o 

X 

CO CJ OO 

0) CJ CJ 

X 

X 

X 

— CO 

CD 

X 

X X 



X 







X 

X 






d 





X 


X 

d 











h- 



H~ 






CJ 





z 


z 

X 



X 



X 






1— 





X 



X 






OO 


X 



H- 


>0 

X 

t- 




X 

X 

h~ 

X 

l— 


d 




X 




Cl 

X 

X 

CO 

X 


X 

X 

oS 

> 


OO 



O 


05 

d 

OO 



X 


I 

d 



z 

X 

X 

1— 

X 


X 

X 


CD 

X 

z 

X 

in 


I 

X 


X 


3 

d 


X 



d 


X 

h- 

o 

o 

O X 

X 

»- 

X 

rN 

d 

d 


X 

y- 



»- 


Ci 



_1 


X 

X 

X 

3 

d 


z 


X 

o 

X 

X 

o 

X 

1- 

l— 

X 

o 

1- 

X 

CL 

Ci 

Ci 

X 

5 

z 

CL 

l - 

X 

X 

X 

X 

o 

d 

3 

Cl 

I— 1 


d 

3 

X 

X 

X 

X 

X 

X 

X 

z 

X 

d 

z 

4C 

X 

"0 


^ _ CN — — 

U J X — — 

+ Z + + Z + + 

X M X X t-H X X 

M M X ~ M 

% O * « in .... -. 
OZO — dZ — r^f^iNl 


d x ■»#» x x x a* x 1 

dIXIX XI O X I X X 
d — Cu — CiICiOIZuO— X X 

-X - X - -ill ^ x _ — Cl -IX 

>- O >- O > X rN - X r-4 _ O > NO - 

— Z— Z — OZdOZdZ — C>rN 


X — — X 

X O — I— 

4 * y- + + x 

I I I CJ CJ > > X 

— 0 — 0 X— — 0 

IX — X. I O d - —• — 

CJ o - 0 >- X CJ> 

O Z d Z — 0X0 — oxx — 


OO XX X X X X I 

XXXXXXXX — XI 

cl o x or o —j o m ) cn x cc ' 


d X d X X 

xccxctrxxxxxiixxxxnocznxccxcrzxxxxi 

jojojoojoojojoourdojojccdjjdj. 


X 5 : H Z X Z X I z o 

in •ci n co a- o - n co ^ in n o) a- o ’H cn co «j- in -o n co o. o-NCO'tin-ONCo o. o — '.n co iii -o n ‘X> o - m o j <t in •£' Mi' o- o - in co <i uo -o x 

X '> O- &■ '> O O O O O O O O O O — — — — — — — — — — IN CN CN CN CN CN CN CN CN CN CO CO CO CO CO CO CO CO lO CO t «t UO UO IT■ UO UO UO UO UO 

r-v X X X X X X CO CO X X X X X X X X X X X X X X X X X X X CO X X X CO CO X X X X X X CO X X CO xxxxxxxxxxxxxxxxxx 

000000000000000000000000000000000000000000000000000000000000000 


|>. I>. cr-o-. OOOOOOOOO OO — — — — — — — — — — CN CN IN CN CN CN CN CN CN CN CO CO X CO CO CO CO CO CO CO 

h-r^r^r^r^xxxxxxijjxxxxxxxxxxxxxx x co x x x x x co co x x x x x x co x x co co x x x 
0000000000000000000000000000000000000000000000000 


000 o o o 

LU ^ LU LLI U W lL X 

CJ O CJ CJ O u u N CJ 

□ ODCiNOCiui!jfflQi> 

□ naaaiNaouua 0 


o o 

— uj — in — 

O «a- UJ UJ h- 

■o Pill Q a- 0 — 0 |> 

OuOU.uL.OQu 


ddd d <*- o — ■=*- 

u_ o — cn co 00 

— ci — n — >0 cn o uj o- x in — >0 in cj x o — uj o (Mjj>£i — 

IN CN CN CN CN X O — LU — — — CN O O O O — O CN O O O ^ ^ CN 

axaxxujoujujoujxoujxu.'0xujxau-'0'0u-aaaina 

lx. — U_ — U-U.CNXLl.CNX— U.U.CN — liJ — X — U. — UJO^U-U-U-Oli. 


CO N 1 }'. Q - IN t ©OUJU. CO 
XXXLxJXU_Ll.U_U-U.XO 


'tOO'dOuU.O CO 

oo o o o 00 — — 
in uo in u-i uo uo uo uo \r> 
rv-|v-r^rv.r^i^h-hvr^ 


<3- CO d X O *3- Nj X d CJ XOCNN5XdXQU_ — XM»dOQHNin«0 

— — — — CN CN IN IN IN IN CN CO X X CO CO CO X CO 't «t «t <t «t «t in UO UO 

UO ITI UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO UO m 

r^r^r^r^.r^t\r^r^r^r^r^r^r^h-r^h-i^-r^r^r^r^r^r^r^r^r^r^r^r--r^ 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

299 









<r co 
x co 

Cl. LU 
LU _l CC 

h- <TQ 

> LU Q 

CD h- CL <X 

0" > O 

h x ta ii. o 

x LU 2 

UJIKClh 
Z x D h 

I LU CL 

OhZhd 


: uj - Lu 

' Z - Oj E 

i o o uj <r 

. Q Z > (O 


> 

CL 

CL 3 

li. 

CO »- 

Cl. 

LL LU 


h 


X Z 

UJ 

UJ GO 

O 

z> o 

UJ 

O *-< 

Z 

CO Ci 

CO 


^ y- > 

CO LU O 

<1 CD Z 


O D CO O J 

Li- Z (f) CL CD 

Q m LU QQ 

<X XCLCL>- 
UXUJQOZ 
I LU X Q U. 

<x x <r uj 

<X d h 
o- > ui <i <i 

-ZH>UJ(- 
y Q U <1 J o 
CO CJ Z CO CJ CL 


X DO 

o U. X 

U. X* 

CC X > z 

lu i- cc cj 

X CO <T x uj 

►“ Z LU LU 

O = — X x> o 

Z CC CO z t- 

<X CJ <E 

= > y- <r 


CO LU X 

LU <X Z> 

CL h- z Z 

□ <1 1C M M 

QQlUh 

<r z q 

UJ Z O CC 

UJlHQO 
> J- O 3 

UJ 0- Cl 
— Ll. Z J— 

cc u_ o_ <r z 

l- Z» Z . — 

LU I— ID CL 

CC CO CO . CL 


On CO I 

• co . <i <r 0 . 

I X <X N Z 00 _i 

O - - CC _i r->i (J « Ox 

COudLLlUJZLUdUNCQLU 


H- Q — CC 

LU LU CC _J _J X Q CL fr-Xf- 

CD O 3 X Ll CC XOO 3 > J 0>0 

- •OQO—’O OL“ X I L. Z “ , m u I o Z 

uj o: uj uj cc <r z - <r 3Lu uj o - o - jjoLd o 

QQ.OQUJf-'Ifl. h- CD NNCNNONlIflCOONCJ 


^ Cl 

_i _j cj _j : 

N J X CQ X 


—I —J O O —I Cl. -J O O Q_ ►— (_j 

S?^5Si l ^^'? c !RA£ o -0? Q<Iz wc£oaa:iuLuc[: 

UOhQIOO -IJO-3 O-5_iOwQ-3Q.JO0t:Q-5 


—! _i _i _i _i_ __ _ _ . 

_ —J —J —i —i —t _) i —i y— _j co _j _j _j co cl cl o i— 

R^^*** 1 * 1 * 10 * 1 ^ CLLUCLCC‘:ICCIjCj<I<IQ.CC<rCCCCIDOOCjZCCX<EXLlJ 
JUOUJUUOJU O o O CC CJ jU0iIJ000101IiQ.Q.CLJw~iUJ(JLUCC 


(J “D "D CL Q. 0-I *- I 


«*• in o co 

co od co co co 

^ O' D O' 

o o o o o 


<1 Q <1 ~ CO CO 

Oi D ODD D D D D D D o O O O O O O O O O H H hJ H 1h ^ iN N OJ N 

0'0'O'tD'i>.i>. 0'0'0'0'0'00©00000000©©000000-N<"JoSoooo?> 
00000000000’HHrtrtH--*HWr<HHrt^HHHrtHH !l Ll 7l Ll !l 7| 


w V' U'. y. yv q q 

O' D D O' D D D D O- D O'- O O 
OOOOOOOOOOO-h^ 


G0 O' O —' CN 
IN CN CO 00 CO 
O O O O O 


co «*- in o oo o 

CO CO CO CO CO CO CO 

o o o o o o o 


o —• cn co tj- in -o 

N" «*■«*«*• <3- <*■ «*- 

o o o o o o o 


-O 'O *o <t 

r*v 

g O in D o O OCN LU fN LU ON 

£ £ ^ _ Ll O- * (N O CO O (N CN UJ CJ 

QQODQOQ-LUUJLUCOLUCDLUQCOQO^CD^COOjaD 
aONiHMOlU^NU.COlL(*)(OUN-H(N(JN£QOO-' 

(NyOODD <CULi.ODJrOinNDmQO^N«tin<iNCOD 
^•NGSCNCNCjOJCOCOCOCOCOCOCOCO'^-^^^c}-^-^^-^ 
>0>0>0>0^)^OmD«0'0'0«0'0>0'0'0'0>0'0'0'0'0'0'0>0 


<ro' 0 ' O'-Oso so o«x i> o O' <x o. o. 

or^r^ 

W lxJ 00 Ll O Q -O Q'O IU O UJ D h Offl-OQNDtU. in CN 

QO^O *t i> O' O' O' ■'—* CN CN - 00 Ll O<X*-»OO00LlLU CJ CO 

HQOfflQQQlUQ QQ UJOOUJOOQOOin-*QQUJCOQOOOOin^'^-HCOCOCOQCOO' 
rt (JOUJOUONOUL)U.UU.NO(NUJfNL)OLLN(JNHUJOUJN(NHiuOUJO 

mu^«tincocQuu.Minco<iQjQu.D4«5-incocQiiJocNinNi>c[caoQujo--tin 

l ^RR^K?R‘ J 2'0'0'0'p>p«p>ph-h ; r ^ , ^r>vr^oooo c o , X'OOoooooo , xicoO'0‘0'0' 

<JN5>0'0'0'0>0'0'0'0'0'0'0>0'0'0'0'0'0'0'0'0>0'0«OnO>0'C|'0'0'0'0'0'OND'0 

r^r^r^r^r^r^r^rvr^r^r^r^r^r^r^r^r^r^r^r^rv.i^i^r^r^r^r^r^r^-r^r^r^r^r^r^r^ 


o >o <x 
n nn 

'OQ'O LU 
O' O' CN 




lu <r y- lu 

y- co > 
o«ilj<x 

V— CD CL O') 



y- 





<r 




z 



CL 


X 




5 



<X 


LL 


>- 

UJ 

o 





_J 

LU 

GEL 

z 

o 



(S) 


<x 

z 

o 




LU 





ZL 

_J 

ii 


z 

y- 

UJ 

CL 

_J 

UJ 





<t 

p 

O 


z 

_l 

CJ 


_J 


<r 

Ll 

CL 


<r 

CO 

UJ 


co 

IX 


LU 

z 



z 

UJ 

GO 

CO 

CO 

u- 

o 

i— 



z 

UJ 


O) 


LL 

CL 


-J 

o 

CL 

O LU 

CO 

Ll 

<L 

CL 



a 

3 

CL 

LU 


CL 

<x 

CO 

CL 

CD 

1- 

Cl 


UJ 



CO 

O 

<r 


Cl 

CL 

l- 

Lx. 

CO 

UJ 

Ll 



<x 

I— 

> 



_l 


y— 

CL 


Z 

CO 


<x ~ co <r 
' - (J u. 

O<ICO<I<ILOOCC 11 


^ *- Ll. CL 

ipCUJUJ'-'ULKL^LUCjT CJ ^UJUOCcSlJ^ 

| u.uDJuaGQCQUJ<I(aUZ<IUJZ<lNCQIiO£0(JJt-IUJ<[ 


X 

CL CO O _| 
QQOXOZOCLi 
J J ll u. J <T J CO 1 


o <r <r p <r CD 


-J _J CO CL CL _l OO OClOWJJJ^ 

<itiDOQoirLCirzujira:LCzoujD<r<i<iJQQ 

0'OQ.CLJxiao;OHQ-jri-iMiiuDUOULi_I _l 


-« (N co in o fN. co i 

CN CN CN CN CN CN CN CN ■ 

O' O'- O' O-- O-- O' O- •>- I 

oooooooo 


I O' o —< CN 

<j- in in in 

• O' O' O' o 

o o o o 


in in IT, £ & I?; 9^ f 2 't >Q ^ O (M co ^ m >0 h' 0D O' O CN CO 

i, ^ 'i - i; J ?;• D D D O' D D D D D D D D O' O' O' O' O' O' O' O' O' O' CN O' O' 

00000 -_ 0'_-00000000000000000000000 


CO 00 »x« 

O CO CO 

N <r - IT) LlJ O U. CQ ill -M>. 

in -H CJ lx CO <1 <f O O Lx (J 


diJCJQUJO^iN't'CiN 
U U u (J CJ Q D Q Q Q Q 

in no uo in in in in ir.> in in in 

r^tN.tN.rN.r^r^rN.r^r^r^h' 


O O-- LU v0 *-* O' 

o o LU UJ 

•o □ u u in a ld 

O Ll Ll Ll O Ll Ll 


loiu^tinN 

Ci Cl Cl LU UJ UJ UJ 

in in in in in in in 

r-' h- r^- 


<x 0 -- O' o- <r '> o. (v j) 

N N N N N Nfs rCr^K. 

UJ LU CO ^ <1 LxJ CO t}- CO O ’-* -o «-• i_l O Cl O 

H '=' X jG ^ '=' -o o co — o u_ o » § S — 

-Hfifi°-WQin-iinLCQmooQOMi)n-'fflinQQQiniuiu 

HUUQO-OOQO-^OUWn-NfflNOUOOOOUW-N 

UJuJlilLiLLULLi^^ooOOOOOOOOO^HHHHWHHHCN 

u .■ in in ui 1 in in tn io i/o »o -o *-0 o -o o «o «o >o ■•o »o -o o •o *o >o >o -o 


Number 47 

300 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 














> 

M 

CO 


o 

3 

o: 


d 

G> 

o 


UJ 


o y— 


CL 

•8 

d u 


CO _J 


O UJ 


CL d 

Z 

_l <o 


O 

X 



y- uj 

o 

CL Z 


o > 

Ll 

o 


UJ d 

Z 

Ll O 


Oj X 


d 




CL UJ 


* Ll 


=j CL 



o 



LU ^ 

CO 

y— o 

>- 

2> UJ 


UJ z 

CL 

d UJ 

IL 

CO d 

O 

CO Oj 



t— 




o 




UJ 




CL 




Ll 

X 


UJ 

CO 


Q 

CO 


UJ 

O 

UJ 

o oo 

> 

d 

1- 

y- cm 



> 


►— 

z 

CQ 

h 

o 

3 


CL > 

d 

X 

* 

Ul o 
> 

X 

H 

1— 

z > 

UJ 

LU 

UJ 

O 1-4 

z 

O 

o 

CJ Q 

•* 

- 

.. 

- .. 


(J 



►- d 




LU 





CO 

UJ 


o z 



C^- 

Z 






Z 





1- 

o 





_l 

o 


cc cc 


C“ 




cc 



3 



O Cl 

UJ 

LU 

u 

y— 


o 


>- 

z 

o 


U Ll 

1— 

LU _J 


X 

Q 

y— 


cc 

o 

o 

1- 


> 

_J •- 

1— 

Z 

d 

CJ 


J— 


d 


Cl X 

CO 

HH LL 



CC 

Ul 


z 

1- 



C CJ 


U 




Oj 


LU 

u 

z 

LU 

CL 

h- 

Q 

_J 

o 





<L 

UJ 

> 

y- d 

d 

3 d 

-I 

UJ 

Q 

Q 

Q 

3 

CL 

I 

<r 

UJ Ul 

►— 

Ul LU 


X 

_l 

_J 

_| 

LU 

Ll 

f— 

CO 

CO 0-J 

0-J 

Z Q 

3 

CJ 

O 

O 

O 

Z 


*3- X Q 

I h- h- d 

>- ~ d Ul d O 

*-* CJ Q Z O _J 

-• Q. K O U - 

- 2 UJ u 2 N 

x-wawz 


i CM i- i 

' ** UJ U l 

+ u cd a : 

> z .hi 

| • LU GC I 

■ — _J Q CL i 



X 

i in 

o 

o 

UJ 

«3- ^4 

— _J 

+ 

z 

> + 

in o x 

X 

> 

d > 

— > o 

*—• 

d 

CO •-. 

+ d -< 


CO 


X CO - 


+ — U. — d (ft-> 

> £C 3 00 ^ 0 ‘J . ~ 

h h uj . . * rvi, 

I^QZiXi<I<IniNZ<I«I 


_J 00 CM 

OX I I I i# # 

> O UJ x x x I | 

d —< o <-*►-<<-< co cm -o 

CO - . ^ ^ > cs 

. UJ x .. « , d d - 

0QtHQU0(/)(/)il0UJ 


—i _i_i y- 

OQ<I<I<IUCUJ 
_J J u o o o cc 


—J —I _J _i _I _l _i _| _l _I rxj _J _J ^ 

5^*5^3^33333^333^3^ la ^g^^igaSSSSSSSB^i^SSSj^sisasliSg^ 


O ^ (N O'l 't in <1 N CO O O (N CO «f ID -O N CO I> 0 ^ (N C':' ^ -O N CO O O ^ IN CO 't li") -O N CO i)-. C r. in TO in .jl rv, m rv __ ni 

! !j Sii Li ^ ^ ^2 ^ ^ 1-! ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 11-1 u "' L "' 1 u_l u " ^ ^ ^ mj v0 <i 5 ^ ^ ^ 


o d oo d co 
u. h- 

•o «*■ d o co in 

M <i «i <t u u. 

Q >>40000 O 
U_ CM CJ O CJ CM (J 


N <1 Q O W 

J? J? S' tP i? Z* Z 4 L' L~ L' L’ L’ L ' 1" 1 ’ ' ' l 1 L' 1' L' i' l - ' J'' ? 2* 2* 2* 2* '■* ^u'U'UJH^B;uJU^UJU)SJ'O>U'iiHJ<i'Oi > .iNrsr , 'f\|\r^iIiC0CCi(DC00Liij0 

n n n s s n n r^r^r^r^r^r^r^i^.r^r^r-vr-r^r^r^r^r^r^r^-r^r^r^r-r^h-r^r^r^t\r-r^r-r--r-r^r^r^r^r^r^r^r^r^r^rv.r^h-r^r^r^r^rv.k 

SS$$$S$S^mSS$SM$S$$S$$SS$SSSSS$^^ 


00 uu O d O- d O O d OOO (J t>. d CN 0^ ll <> 00 O U- Ll O n m h 

rs-r^ in onnnnoonnnn onn o o o o 

CO d d Ll UJ ^ CM r^ «* UJ UJ CO CO CM >0 UJ CO d O —I r^ CO d d CO UJ U CN 0- UJ UJ *h O o. -Cl UJ ui □ -Ci cr 

St2?SC®y v NONlDQO^NNinU.O'O O CO ’-• O U_ O N O) CO O N —• o O r*. iVi ivi —• —. ip |p rf i—i i—i _ 

u u Q u H u !> u UJ Q u H u Q Q u Q ^ O u U. -C< iii ill O f ) O s fi'i n n Q l~i o'i n J iTi ji r. n — ! ivi ,—, ,— , ,—, ,—, a m hi n r •■ 

U(JN(J-OOU.(OU.UHOOU.U.OHL)OdOOCJO)(5)t;fflSHiruoOQnNQNlL«Q^QQQo2!S(OOH 


m -o O', (a uj - «t m o 1 - co uj *h «t n d o o co >o i> oo u. ^ co in .o co o- a o u. in yj n d a o u. «t in co <r o o. cj in co <r luii ii 

£ £ r* r £ £ £* £ £ £ £ £» co co co co «- ^ *- «- <*■ «- u~. in in uo in in in in in <> mj -o 5 io to $ ^ k £ £ K co co S oo oo oo oo 

r^r^r-r^f^r^r^r^r^^f^r^r^r^r^r^r^r^r^rv.r^r^r^r^r^r^r^r^r\r^r^r^r^r^r-.i^r^r^r^i\r^r^r^r^i^r-vr^r^r^r^r^r^r^ 


o d 

CD CL LU 
CC Q. V J- 
O CO >- 
Ll CC UJ CCi 

CL O 0C OO 
z> f- Zj 
h- z y- 

1 -xUJd 
uj uj t- 

O j Z CO (/) 


X d 

UJ o 

_i y- y- 

— d cc 

u x d 


o 

UJ V z 
z cj ~ cc o 
o co o CL co 


uo J ll h J Oj J LL h 
jQdOUJdjOduUJ 
Cl- ICJClOCOQ_I O CL lC 


Z UJ — I 

-< cc 

(5 d K « I 

UJ CO *-• i 

CQOh^i 

Z -I I 

co d uj : 

O >-N i 

O > CC >— i 

_I u J 

> z y- d ■ 

CC O u M I 


+ x + i ++a+^xii 

Ox UJ x 0- x x CC x >- O LU CD CL 

£ it ~ z u. o — o _j m 3 u -< co — o d _j 

CC 3 CO - .. _J —< ~- Z z d ~ ~ h- d ~ h- - , CL C 

*-< UJ - - n CC U x , _ X X _J X ll * «0CCL . CC U UJ x CC d 

OZCOddNdZOO*-»COOO-*—'Q_»—*(OUJQCLtOUJCLCOO*-<Q.Q. 


o in 

X Z I 
UJ u u. > 
z to y- m 
d Z Z ~ 
Z d - - 
dZN J 


-I —J _J X X -J . y -J _J_J_J fM 

-J -J u h u _j to co J y z u —1 _j_j _j ll oz 

ddOQUJUJUJuldljljQOdZ - jOdOQddOdOQO~'U: 
OUJJQiIQ-juCLQ _IJUMQQ.OJJOOJUCI_ ldQ“3 


UJ UJ O m 

Z > L_ ^ „ 

UJ h UJ Q J x ilO Cl O Zll d d 

J CC CC Z h h CL _I <E H-._J h- OO uio 

LUOddLLtO _J h-<c;i CL _| Z X —lO 01 d 

O d CL QC_J LU O O 

- - - - - - - ••. * •« LL CL Cl CL CL z - _J .* .. _J 

S ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ co ^ U_J ^ ^ ^ ^ 0 ^ ^ ^ S u ”' ^ ^ ^ cro 1:0 ^ u_l ^ 1:0 ^ ^ ^ 'co c>. 

^ ^ ^ ^ ^ ^ ^ ^ ^ i' ^ ^ N N N N N N N N CO w W a' CO CO CO CO CO CO o-. O'. O' 'M>. O'. O . O', o.. o O O O O O O O O O 

000000000000000000000000000000000000000000^*-<— 


n co a o ^ in o «r in .o n 
^ ^ in in in in in in in in 
00000000000 


«o o o 00 

^ CO d CN CM 

^y~ u. o ^ u u m uj o - o 

O 111 000000000 


'DNOjCQOQO-CO^N 
O- |> C- O- O'- O d d d d d 
>0'0'0'0'0'0^)'OM5'0'0 
r^r^r^r^r^-ixr^r^r^ixr^ 


0030 —< d d CO o O- d Ll O' O 

r^-r^o rx o^ r^oor^h'Oh-o 

d d CC' UJ d Ll mdUJCOCO-O — dUJ'OCNdUJ'O OOh'O 

CO CO O r-. CN <f UJ O «*■ CM *N II UJ O U" in CO O ll".' Q ’-<■'-<0 0 

OQ'L'QQOOOOOinQ'OQOQOOOOOOOOO-^^OOOC' 
OOOQCOOCOfNOOOOQtJi—i»-<OOOQOCJOtJO’-*Q'-<—-< 

CO CO UJ O CO in « 00 CO O UJ O CO M3 CO d O Ll CN in CO CO Ul --• IN in N O • 
dddCOQjCOCQCOCClCQCOiIlOOuuOOOOOQOOUJUJUJUlUJ 
>0'0'0'0>0'0'0'0'0'C''0'C'>0'0'0'0<i'0'0'0'0'0'0'OvO'0'0'0'C' 


CO CO CO CO 

NN Ml 
CO d O UJ 
Ll CO O <> 
O O d o 
O CJ O Ll 


in co co uj 

U- Ll Ll Ll 

vO -o -o >0 

r-- r^- 1 — 


Page 34 


Dr. Dobb s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

301 







o 


X >- O I UJ 

O ~ + CL Z 

~ x _l Ci 

- - x >- Q. lC 

j 3 


o x Q 

Cl »-h _J 

CL 3 00 — 

►-* UJ * , rg 

Q zcci c <r z 


x —< X _J i* t* 

z + ^ z a. i x i 

UJ X O LU - I 

_J O *-• + _l (JO —< Q Cl Cl 

^ ^ x .. - Cl * ~ _J _J 

x >- r-j « r>j x >- NE>xUJXQQ>x 

ChhZO^vZhmQZUHmQhJJHH 


O - f* X 

+ ~ I o 

X X O Cl —• LlJ 

O *-• + _J I Ci 

-* ~ >- _J ^ ~ 

.HX> WUJX 


o <r <i o z -• iu 
CL U U LL H Q LC 


O u Z J h 
□ QDZZ'XIUJ 

J J JmmQQiI; 


-j -1 XX 

-J -J (J 4— CJ OO CO (J (J 

(C<IQQU1Q;uUJI | DCCQQClQCZZLJ 

OUJjQ-OCQdinjJOlHMu 


Cl Cl u Z Cl ll 
CL CL O ODulCCOODQQ 
O - Cl u-1 <1 u 1 ll Q_I _I _J 


UOZ QCCuhx 
QOQZZ^DQQOZUlxCi 
j j jhhq j<r xmccuj j 


'ONCOOO’^tNO 
co co co m- m- m - 

CM CM CM CM CM CM CM M 


CL CL CL X 

UJ •-* ^ h (J ih M Cl i— 

Q CL UJ UJ CO Cl Cl CL _J X O 

O t -J CO 0 ‘J X _J _j _j Cl Z cl 

O CL <1 Q Q Cl X Q X 

- - Q- => - z _J _J _J o 3 5 

«*■ in *o oo O' o cm co «*• in -o r-- 00 o o cm co in -o oo O'- o cm co in -o r- co *> o hh cm co *3- in 

j i «t^^^»tioinioir | inirjinirMoio-o>o<i'0>0'0>o>0'0'ONNSNNstt.NN»Cco(oScDSa) 

^ ^ ^ ^ <VJ ^ ^ ^ *' s * ’' J , J CM CM CM CM CM CM CM CM CM CM CM CM CM CM C'J CM CM CM CM 


MlNODO. O^CMCO«tlO'ON(» 
05 CO 00 00 O- O- O O' O O O- O O' 
CM CM CM CM CM CM CM CM CM CM CM CM CM 


<X <T 

ix co in 

CO «*■ Ll 

ITiuQ'HCJOO- 
U(JUUO*hQ 


(JQO CO in 
h* CM CM CM CM CM 
00 00 00 00 00 00 00 
i-x. h- ix r- ix 


o o <r 

o o i"- 

O LU N CO CO CO 

*-• h- h- CM 04 U «* 

•OQQQQOQO' 
OIlOQIlhOU 


|J 3 <1 u O C 4 O'- 

CM CM CM CO CO CO CO CO 
Oil CO CO 00 CO CO 00 00 

pv.fv.r^r'-r^r^i'-r^ 


£ co o ^ o oou <r 

_ 3 OO o OOU -O 

<e <i co uj in in oo <c iu uj o- co co - q ^ h o cn q h h o uj n co o <i- o O' ^ 

UJ O X o UiUJ-ONQjOCMtM UOUIUI*-**-«QCJUIUJ^NNCMCMUU*-« CM 

M“i9S£^9SP£!i l P929 D 9 0 ® DQHa o®QO'< i aaDDo.<Qu.a«.».Q 

OOOQCON'JOiQli.NOlLQMQli.OCMHii.QHQHHQ.QOQlLDliHHQ.lolOQQ 

« 0 OCMin<COO^<[OUJONIOOO«giUlt^(O«N«OUIOCM^'O^OUJOCMinNCO^<[(Q 

i' ' C'i ^ eS- d- rd- td- cf- in in in h“i in in in in o"i .j*i >j*i .j"i ^ k k r-> r-^ rv^ i-i*i ri-i ii-i ^ n*i .* 1 *. 


<X Ul O CM in *o 00 O' CJ UJ O CM in 00 <1 CJ UJ U -« CO in N <1 CJ UJ O CM <*- O O- <J Ul O CM in N CO ■> <1 CCi 
v C'i ^-«^^«i-^«a-«^-«^<tir>inLnu - 'ir'inu-iin*o*LivO*L'>o*o*or^r-*r^r^r^rxr^oocooocociocoooco 
'XiOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOCOOOOOOOOOCOOOOOOOOO OO 00 00 00 00 CO QO CC 00 00 CO GO OO 
r s -r s *c^.h*-f s 'r > »fxf^r^r s *r^i v 'r > *^r^-r^^r^r^-S-ixf^rx.S-r s *S-r > «r^r^'ixt>,c«vC>»fx.f , s.|^ N .f^r>^r s ^r s -r^ 


u 



J— 


OO 

CJ 


LL 

oo 

UJ 

o 


> 

4— 

o® 

<r 

O 


oo 

UJ 



OO 

u 

u u 


4— 

LH o 

Q Ll 

* 

3 


UJ 

UJ 

UJ CL 

4- 

z 

4- ZO 



<x 

U 

4— 

Q h- 

3 

=■ 

CL UJ 


Cl 

Q OO 

oi 





> 








u 




z 




o 




X 




4 — 




UJ 




(J 


jlL 


4 - iL 




UJ 



4 - OO 



CO 

u 


OO 


<r x 

> 


o 




o 

Cl m 

LL 



Q 


Q 

z 

\ Z 

o 


II 





3 -• 

J- 



UJ 


UJ 

CL 


o 


4 - 

4 — 


r >4 

o 

U 1 — 

UJ 

UJ 

<r 

<r 




u <x 

u 

Z 4 - 

4 — 

Q 

>- 

_J 

oo 

z> 


<L *H 

OO 

LL 

CL 

<1 

UJ 

CQ Ci 

Q 

Z 


_ 1 

o 


> 

UJ 


Q 

UJ 


4 — 

4 — 


_J CL 

z 

4 - Z 


Q 

O 



_J o 


UJ « 

<X 

z 

UJ 

Z 

oo 

' 4 — 


CD U 

X 

<x 

CL 


<r 

U OO 


3 3 i + + oi<ta:i— k > 

UJ UICCXXHHH<IU<I<I 

Z 2 jr-- 4 -+QQZQW 

(J - N ll - . H. HH LU z N 

UJZQHJUZDQIU«vQ.(J) 3 hZ 


z UJ X 3 Z X >- O CM 

hQ(J COCOhh O •-* + LL 

•» H“ 4 — s X - ~ 00 —«*^x _I 

UIlCLlJ>nOx>x , > » , « x > Z > 

QUO - ZX*-HHHHOHHULl<r — —.1-HH-.HH 


CM Z o X< 

U M + CO OO CO OO 

-J - CO X - u o u o 

> Z > r-si x , M o -| .. CL UJ 

HHM(JZM<I v fflfflOI-OW 


<L X 

- C -4 

*- o 
uj o a- 
z + — 
O ■-* x - 
CL 

3 <1 — CO 


O O _| _I _j _I I— 

UUZQUJUUQQQQC<X<I<ILCUJ 

OOmJQT^jjjj(jqqq~iu 


<E <r U Q Q Q u 

O O -0 _J _l _l “j 


UJ —I _J _J XX r-i _j _| _| _| 

—J —J 4 — _J OO OO CJOZUCJ U _J _j <_j i | 

—* Q<X , 3 :UUI<IQQ_'LJZOQQQZZ“OOUIUOQQQ<XQ<XZ<I<IQQQ 

-J _JOOOUO_l_ICi_ 10 _— ~OLLO^al_J_J_JO_JO^OO_J_J_J 

<x 


S N N N N N N CO 0) CO CD CO ffl OJ 0) 05 i>. CM> i> i>- O’. i>. i>. O. O', O O O O O O O O O O h h h h h h h h h h (M (M CS M N N N CN W C4 r'"i ^ CO OO CO CO 

3 3 3 3 3 3 3 3 3 *"* ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ’I *-• CM CM CM 0-4 CM CM CM CM CM 0-4 CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM CM 'N CM <N CM CM CM CM CM 


QUJQUJ00CO<X00 

oooof^fx.r^h' 

•*o -o -£> lij cm oo oc* <r co co in 

oou o in in n n *>4 <r ^ ■_> u 
uO'tUJuOCOQQQQQuGQC'i>. 
lQ CO h h O IN h Q Q L L u U O u 'N O 

O-0)'t'iiM>CQllJH<tN^oO(0in 
o- i> i>- a- «>• cr- o - - . o i> <i <i <r <r <r co cq co 

f^h-0-NNNNO.NSSSNNNSN 


•oo oo oo <r o 

rx rx. ix m o 

oo <r Q h co <* Q 

Ll CO *>• CM O CO IT* 

Q Q <X Q UJ Q OO 

O (J (J II OO Ll h 

vOo-cju_oomi> 

LU Ll LLI O U U U 

i-^ i^. r^. rx r>. 


co co 

tx r*. 

coo- <x <x<x<x oo o co <r <x cx <x o o 

r^r^-h- n uj oo oo-r^ o- o—< 

in uj -o a- HHHincoinoiuNcocotH cuhOis<iqo<i ixco*h^c -4 

U ^ I/O CO CM CM Ul O Ul —* O- 04 CM Ll UJ UJ UJ O N -O CO O O'* ' r i <t o N o 

'hQl-iUJOQQQQUJQ-OQQQQOQQOQUJQ-^'QUJQOQQUJQ’H 
-•OOUOOQUQOUOUQQU — UOO-4QCOQOOOOOOOCOQO 

QUJ — ^->Or^<IliJCM*^vOOj<IQOcN^>Oaj.>. COQU_CMinijO<XClLiJ — c4-vOO 
(JOQQQQQQUIU1UJUJUJUJUUUUUUUU-UOOOOOO. -H-H—-• 

^^^^ r " ,v ' rvr ^ rvrv ' ,Nxr ^ rv ' rv ' rxrNr ' ,xrs ' rsrNrsrsCi: ' 0 C) , ^tt' o j | ^ | j0C |:, tt'0C' 


Number 47 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 







to 

o 

Uj 




o 



CL 


h- 

Ll 

V 

O 



_J 

A 

LL 


Z 

CL 


© 

o 

O 

>. 

Cl 


E 


Zj 

iL 


1— 

h- 


O 


Z 

Z 

h— 

<r 

lL 



LU 

CL 

O 

CL 

CL 

OO 

y— 

y- 

LL 

CL 


cr< x x cl 

z lu cl <r 

>- x <r o x 

Ci X H O CC 

_i o o z o 

Oh- *-• I— h— 

x ci x <r 

UJ M U U 2 

CL CD J l- Z H 

<r z <r <x e 

lu <r > I— h- CL 

_i x z o LU LU 

O O M CL O L- 


i <r 

Z I * 

*-H 0- — I 

X > — Q_ 

<1 I- + _J 

Z N U. > e 


Z . * 

— X -I ~ | 

tx x e cl 

+ O <X + _J 

> H X Z > CL 


><I>>h>UJQ . « > > > 
„ZHM^HaON^M|-W 


(JO Cl 

to CL - - 

Cl Ll — — Ci 

X Li_ O’) ^ LU 

LU O —« CO 

I— CO CO + + CO ZO 

- - Ll O > > liC 

> O O h-. IX OO 

lu 


X X s 

Q O <C O O A O 

OZOZs Z x Z 

-or -cl - x x 

oq.oq.oo.ocl 


I O > UJ > O I 

- .zoaihi: 

UJ J O - O LU Cl 
r*NiQXOr>iXOOi 


h- Q- -J 

> _l X 

CO Ci 

O IX LU 

CC 3 <X Q 


O 

CL LL CL Q Z I 
~D O ”5 _J *-< ■ 


: Q. CL Ci Z IX O LU 
' O O J HH LL CC 


u u <1 u u D LL 


_l -J 

UdOCLDdUlI 
_JO_J~JO_l~ 


<X Q_ LU X 
O O CL LU 


I _J _J 

<E LL IX <C IX ■ 
' O O "5 O —J I 


tN co -sr in >o 

>o >o «o -Ci 

CO CO CO CO CO 


CL. Zt— X h— X X X z Z 

T 1 X! LU r! <c X X X LU O X _| OO 

£*- XO^QC > _J Z O O'-L— Ci QO 

x ►-< x lu cx or 

*— Z Q o —1 X •• CD 3 3 

Ch °^ c ' Jco ^uo^r^C'XO^'NO^'^Ln'Or^x(>-o^tNco«3-in>or^coxo^tNCO'cj- 
v 1 ^ « i' « ^ t t ^ N N N ^ 05 ^ ^ 1:0 1:0 111 ^ 05 a ' ^ ^^ Cl- ^ ^ O O O O O O O C O O H H H TM H H H H rt (N N ('I N CS 

CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO «a- *a- «*- «a- «3- «a- <3- <3- «a- «3- «a- 5 «*- «a- «a- «*• «a- *a- «3- *3- «*■ «a- <4- 




o o o 

MLUNNCOUJ'HlONCO-CiQNNCOCJ^ 
(NiNONiNLUIULUNN^OONCNLLU 
OIi UJ iXiuuCOQQuQQLlJQOQQCOQ^ 
CNXCMXX—*XXXXOX(NXX-nXO 


oa 

h- 

<r x <r u iu d 

IT; N N O O 

— <r o o — <x 

lN -O CO O N N (O 

D *-• D LU Q Q fO 

X O O O X X o 


<X <X <X <X 

tv fx rx 

uCOdOJOCOUJCO 
O 04 O CM <N CM CO CM 
UJ □ UJ CO LU Q IU OO 
OCJOCJOOOCJ 


S0 O 

*-« CM 

Q LU CO CQ 
O X O LU 


or^ fx rx rx rx 

O^Hffl>0Q<ri><tiIiX 

o to u. <x —< o o co u_ <r lu 

•HQOJQQlilCOQOjQCONfflO' 
NUCMUUXINOCMOh Q LU O 


—< — -Hr-irtrHCMCMM(MCM(MCNCOCOCOCOCO 
X XXX X X X 0 s - X X X X- X- X X XXX 


<nu^«t-ox.o 

CO O'! «t «t 

X X- X- X- X- X- X- 
x x X X X X X 


X-^^'OXCQXO 

no in in in in in *o 

X- X- X- X- X X X- X- 

rxtxrxrxrxrxrxrx 


CO'OOOXdQOCMinCOdOU.’Ht'ONOO 
vO'O'O'O'Ci'OXr^NNhvXSCOCOCOCCiCO 
X X- X X X X- X X X X X X-- X X X X X X 
rxixrxrxrxrxrxixixrxrxrxrxrxrxfxrxrx 





L—1 






y- 

<X <X 

CL 


z> 


Q 


z 


z 


CL 




_i 

Q 

O 

Ll 



Z 



Q 

E 

OO 

O 

CL 



ZD 

CL 

l - 


CL 


E 

CL 


Z 

O 

o 

Ll 

Q 



E 

^ LU 

o 


O 


<J 

y— 

h- 

_< 




Q 




OO Ll 

LU 


Ll 



O 


o 

o 

Q 

Cl 

<X 


CL 

CL 

Q X 

OO 

CL 



O 

OO 


Ll 

y— 

O 

_' 



O 

O 



y- 


CL 

y— 


Q 





CL 

Q 

h- 

Ll 

Cl Cl 

CL 


O 

O 


h- 

<X 

t— 

y~ 

z 

1— 

LU 

<X 



E E 

E 

Q 

LU 

CL 

y— 

X 

LU 


LU 

M 

LU 

Ll 

CL 

LU 

OO 

zo zo 

Z< 

Z 

I 

CL 

LU 

Z 

CL 

z 

CL 

OO 

OO 

X 

y- 

OO 

OO 

LU 

Q Q 

Q 

<x 

O 

LU 

CL 

.* 

.. 

.. 

.. 

—i 

.. 

- 

.. 

.. 

CL 

- 


.. 


- 

.. 


to —< cm co <r 

u. -« -« —- —' 

E + + + -h 

LU >- >- >- > 

h M M tO M CO M |J) 

> -. - ID -CL -LU 

MUflUfflOhOO) 


+ ^ O CM + 

>_ X — Z — > 

—■ O + *- + ►- 

OO >- - >- 

- - HH (J . 

<x <r ~ z ~ <x 


z + + -. z i 
— 

rx - .hhh-i . r^. . i 

dCMUd- - CNU I 


>>-- .m>^lu£K>>| 

HHDjd^HlQCL MH| 


_i _l X h- _l _J h- 

1 <ICIXLU<IC 1 <XQLU 

ooiuirujojic 


O ( 

i Z LL CL Q I 
I —< O "O _l ► 


I li. h- Oh¬ 
io LU LU UJ LU 

Cl CC Q CC _J 


X JM _J I , 

_ to O Z J CL OH . 

Q =j Q Q Q Z “I Q <T O Zi ' 

—JO-I —I J w O J O Q. Q. i 


X O -H M CO «t in -O N CO X O IN (0 «t m O N CO X O ^ (M CO <t in -O N O) X O ^ CN CO <»■ m sJ N 00 X O CM CO «t in >0 N CO X O H N (O «t in vO N 00 X O H 

i>oooooooooo^ : -i-'^ rtrt ^^^^(MN^NNN^NNCJcococo^cocococococo<t«t«t<t<t<i-«t«t<t«tinininiMnininininin>o-ci 

CM CO CO CO CO CO CO OO OO '00 CO CO OO CO OO CO OO CO OO CO OO OO oo CO CO CO CO CO CO CO CO CO CO CO CO CO CO CO OO OO CO CO CO CO CO CO CO CO OO CO CO CO CO CO CO CO CO CO CO CO CO CO OO 


LU LU <X <X X - <X X Q 

o © n n s n 

■tlUNO <t O LU LU 

co «*■ oo *3- in qoll 

QQQQXXQ-hQ—'X- 

LlLluUQUO-OCOO 


U_ CM in GO CQ O Q O CO -O X 
CO X X X XXX<X<X<I<I 
CO CO OO OO CO CO CO <00 CO 00 CO 


<XQO<XQ<XLU<X 

in © o r-. o o r-» 

UJ >10 Q UJ <X UJ N 
04 <3- -3- CO «*■ OO CO 

Q Q Q Q Q Q Q OO 

U. U_ Ll O U- O U. o 

<X U h <t N <x Q o 

<X<XQQQQQ<J 
CO <00 CC< 00 OO <00 CO <00 
r^r^r-vr^r-'-r'-rv.i^ 


QQOUJ Q LU Q <X X Ll 

ooo© ooo © 

UJ O N CO <f LU Qinn^MUQOOfflX in 

N CO N O fO «OOfONN <tOUQ 00 

Q'OQOQQOLUOOLUQQQLiJOO-r-iQ—-XQX 
LlOU.COLlLlOOU_OOCOLlLlU.LlCO’-''U<J<JLlCJ 

C0'0C0QQOC0«a-'000<XQOC0inr^<XQlULLCM 

OOOOOQQQQQQiZiLULUlULUlULULULUli. 

OOCOOOOOOOOOCOOOOOOOOOCOCOCOOOCOCOOOOOCOOO 


<X —< Q X <X 

in o rv r^. 

*-• in <x o n co x <t lu m << q 

CM LU O CM N I'M Ll. O O LU LU —< O 

QQvOUJQQO — QQQQLU 
LlLl©C0LlIl»-''-'OIlIlCJU. 

CONXQQOCM«^S<XOIU*-| 
IlLlLlLlLlOOOOOOO'-i 
OO 00 00 00 CO X X X X X X X X 


Page 36 


Dr. Dobb s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 










<r 


x x ~ x 

<r <x z h- o 

x 3 <r uj 

o 0 x 4 - 
r - 2 

►“ • 'v x •—« 

UJ O Cl X O X 

CD < O < L_ X 


lu ix <r cj x 

ZUJO# UJ CO 

O > 4- X to 

I H IJ UJ <X 

' ix u i cc l <r 

UJDWhx UJ 

> Ci 4- 

1 w h K h I- <1 h 

lC UJ UJ UJ UJ UJ iX 

Q CO CO to CO IX 3 


+ >< 0- 2 ~ 4- I 

>- 2 0 X X >- 4- 

O — X I uj x 

w ' NO - N- «^h-Z\ 

- < -• ~ X X X CM h'l X - X O —< 

<X '- 04 >. ruQXXv 2 I UJ Q. Q 


O X 
-O - 2 _J 
O - - X X O 
X X O X CO X 


O X ■> *> '■ ^ 
X , CO N x . ■. 

co n 2 co <r o 


4- > CJ V X 

ID 2 4- X X X X* X 

OH^ujaoihXQh 
ZZZI4— 4— 4— 4— <£►-< 
O O OOUJUJUJUJUJX 
O O O X CO CO CO CO X 3 


_ CO O O _J 

QXXXXI'QZXXZQ^XXX 
X O X CJ “• u_l*-*0X>*-,_J0X*0^ 


_ X _J X O I 

Q <X X O <L O Z I 

_J O — _l O X ►- i 


CO _J 2 X »— ►- 

X* Q Q <1 -J O UJ 

Q_I X O Q X X UJ 


<TXXXXQQQ 
OO — OXIX-J-J 


UJ x 

OZhX(OCOiO(OZZ 
Z M CO Z > O X Ll O O 
XCQQOXXXZ'QX 
XX^IOCOI— CDX3 


O^CMOtin'ONOOOO^MO') 
I O- O'. O' O'- O'- O'- O'- O- o- xo o o o 

m- m- m- <*- m- m- m- m in in in 


«t in -o m» cn o 
oooooo — 
in in in in in in in 


•h cs co ^ in -o noo ck o ^ w n -a- in >o n ijd o', o ^ >n co «t in >o s co O' o ^ cn n -t in -c n co i>- o 

—, —4 —. r -1 —I ^ *-« ,-H CM CM CM CM (N CM iN CM CM CM CO CO CO' CO' CO CO CO CO CO C r ' «t <t ^ t li'i 

in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in 


<X O- O" <x 

o rv fs fv j>>, 

UJ X X CM CM O' vO UI —< o~i ->0 iYj r.-j i'-j 

£ in cm - >o co o xocoo x o cm cm x 
i-i x x x oj in c: co x o x x x x o x x oj x x *- x x o-. 

ll.U.OlLNXM(MU.iNNinijHi i .N|fiO-i<toxu.HiNO 


O O CO CG 
O CM CM X 
in -o x x o -• 0 -. 
o o o o — «o o 


tti uj o co in >o i> c o x x o c*) in n O' >i x x o i t i ^ -o n O'- <i x x x «n in 
xxxxxxxxxxxxxxxxxxxxooo o o o O O O O 

O'- O'- O'- O'- O' O'- O' O O- O' O'- O' O' O- O O' O- O- O'- O'- ^ <C <X <X <X <C <1 5 <1 d “I <1 c 

r^r^-r^r^r^r^r^r^r^i— r^r^-r^r^r^r^r-r--r^r-r— r-~r-r^i— r- n n n s n n n 


<r x x 

o- r- o. 

oq co co o j in x co 

CM O o —< o X 04 

LJX<CXO—«XX 
CJ X CJ X CM CO CO <4- 


o o- xxocMins 

—I -H , CM 04 04 04 
<X<I<I<X<X<X<I<E 


xxxxxxxxxx 
O'O.O'O-r^rvO'O'O'r^ 
(J i>. <1 d' III - x >4- o <x 

O o o —« ^ 04 — 04 CM 04 

co co co x co co co co co co 

CJCJCJCJOCJCJCJCJCJ 


X X X <3- O' <X X o CO 
04 04 04 X CO CO CO CO «T 
<X<X<X<X<X<X<X<X<X<X 

o>rvr^o-r^o-h-o-r^r^ 





4— 




X 

X 



X 




-J 

o 




4- 



-1 (ft 

2 

111 


I 4- 






2 


O CD 

4- 


CD 

4— 



<r 

X 

2 <t 

CD 


X 

-J 

Q 

X 


<Z I 


<x 

fvl 


3 

> 


X X 

X 


X 

4- 4- 

z 

4- 

<x 

<z <r 


2 

X 

1- 4- 

4- 


-J 

o o 

Z> 

X 

CJ 

X X 

CL 

X 


... 












CO 




s 

X 




CM OO 

I 




'• X 

(J 




4- 




X 

' <X 

in 



o 

X 2 

in 



X 

I HH 

CM 


X 


I 



Q 


> X 

o 

4— 


o 

CD X 

4— 

X 

X 

¥ 

4- 


4— 

X 

O 

X 

X 

X 

CJ 

4- N 

ZD 

X 



< 



4- 


Q ' 

h- 

CO 

2 

>- 

X 

Z 

X 

X 


4— » 

X 

CO 

X 


2 4- 

X 

ZD 


> 

*-• 2 



I Q I X 

X o Q o V 

<x <x o o- CJ 

QICDIQICDn z 
’ - Cl t-< .. o- , « (z 
OCO(J^(J«tO(J(i.d 


a 

o 

O I 

I CD X 

O O - X 

co — o o 


XXX X I O' 

- X - X XXX - 

<XX<X<X<X<X<X<XX<XO<X 


?;fi=<'9fA ; era.Sei«oLi“a_a:“cLui 

0^0 J O J CJ .1 _J CJ x x CO O ~ <0 o X 


Q U Q Q K 

QQQQXDX 
<X <X <X <X O _J X 


XI X 

X 0>OUOOXXCiQ<XCJ<X 
Q<XQOXXXX<XOZCI<XQ<XX 
XOXXXXXXOX<X<XQ<XQO 


*-< IX X 

X (ft CO 0_I X 4- 

4- D J O <1 u UJ 

(ft X X X O X X 


in -o n oo O' o -i 

CM CM CM 04 CM CO CO 

<3- <3- «3- <3- <3- «*- 


X > z 

3 ca -< 

4- 4— CO 

X XX 

X XX 


cm co m- in >0 

CO CO CO CO CO CO 

<3- <3- <3- <3- <3- <3- 


O O' O ^ CM CO 

CO CO M" <t ^ ^ 
^ *=*■ ^ <3- <3- *3- 


<t in -c o 'X O'© cm n <t in -o n co o-o *-< 'N o j <t u~i n ijo oo ^ cm n «t in -o o co oo -h (N co <t in <' o 
<^M-*^^M-M-ir.'U-jinininininininin- 0 'jD'« 0 ' 0 ' 0 ' 0 ' 0 ^-< l O 0 ~ 0 si^r^r^ 0 'O-r^ 0 ' 0 'C& 03 X' 0 jC 0 C 0 «'o co 
<3-«3-«3-<^«3'<3-«3-«3-<3-<3-<3-<3-«3-M-«3-«3-M-«3''3-<3-'3-<3-«3-<3-<*<3-<3-«3-«3-<3-«3-<3-<3-«3-«3-«3'«3"«3-<3-«3-«3-«3'«3-«3- 


Ou<Ili-<<rNNL0j o X 04 Mi. 

!•■•! <-• ;.o <_• ^ o t O co 04 CO o O o x 

K J ^Ri UJ ^R. LtJ 2?f JJ 9S l =t! ,::::iU - CK -oujco Suio- 

XCOXCOXCOXCOOO<XOQXCO QU.O 

0 ill Q li W ID N D-. CQ U li O iN <t rr, er 
S' Sf S V ’i o- O' » O' O'- ■>- ■! “I <r « « s 
NNONN^rvONNNOOOO jCfCh' 


CO ' J Q 111 li. O <H 

<x <x <r <x <r q q 

O' O' O' O'- 0^ O'- o^ 

r^- O' O' O' 0- 


0- X X X X M- XO O O' 

q o o o o o o O'- <4- in 

<XQiXiir'QQQQQ-H'0'0O'X0'iX' 
O' CJ O' X CJ CJ CJ CJ CJ X UJ CJ 04 CJ CM *-< 

cM(0'OM»xoiiJon<t'OfflO'-£ao 

QCQCUCQQlXlujCuCJOOOOOCJCJ 

O'- O' O'- O'- O' O' O' O'- O'- O'- O' O- O'- 0-- O' O' 

o-O'O-o-O'O'O'O'O'O'O'O'r^r^o-o- 


in —• 0-. 

X X Q X 

QinQQQO- 
X Q X O X CJ 


X O -< CO MJ CO 
O Q Q O Q Q 

O■ O'- O' O'- O'- O'- 

O' O' 


Number 47 


Dr. Dobb’s Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 













< 



< 

< 



< 








Cl 

< 


z 

if) 

> 


ir 


UJ 

h- 


Cl 

> 

y- 


if) 

UJ 

NW 

> 

X 

Cl 

<r 


Cl 

<r 

UJ 


O- 


z 

H 

Cl 

UI 


-i 

<f) 


rvi 

0 



CL 

1 —< 

2 

u 

* 

Ci 

_J 





<r 

CL 

CL 

CL 

CL 


UJ 

UJ 

UJ 

UJ 

h- 

E 

y— 

h— 

1— 


z 

z 

2 

2 

2 

UJ 

UJ 

UJ 

UJ 



s 

\ 

\ 




u 




CL 





UI 

2 




U 





U 

UJ 




_• 

5 




Ci 

2 





Cl 

X 



> 


© 



CL 

> 

04 



h- 

CL 




2 

O 

X 

© 


UJ 

1- 

© 




O 

CM 

© 

UJ 


LU 



CL 

Uj 

CL 

X 


UI 



© 


X 

2 

Cl 

04 

X 




* 

© 

2 



X 

04 




© 


O 



04 

X 

UJ 





2 



X 

04 




0 


CL 



04 

X 





© 

I— 



X 

04 

<L 



© 


_l 



04 

X 





© 

2 



X 

04 

<L 



O 


CL 

X 

X 

04 

X 

1— 


O 


© 



00 

*•« 

04 

CL 


a 

c 

© 


•c 

s: 

I 


^ X >- X _J 

o , - - <r . - - - 

u_ © uj uj >00 0)00 Oj tf) Z O > CO 

CUNlIljjCQZLLUdlllLLlIlijjZLLZill 


>- X >- X 


X 

X 

X 

X 

X X 

X 

X 

X 

X 

X 

X 

X 

CO 

04 

© 

■4- 

04 

-u 

<T 

Cij 

04 

O 




0 


T-. © 

© 

© 





© 

0 

O 

04 

U 

2 

UJ 

Uj 

2 

O 

04 

U 

2 


2 

2 

04 

04 

04 © © 


O 

04 

04 

04 

04 

© 

© © © 


z: 

u_ 

2 

Cl 


UJ 

_J 

Cl 

<r 


33333333333333333333 

UUUUUUUUUUUUUUUUUUUU 

22222222222222222222 

uuuuuuuuuuuuuQuuuuQu 


Oj CL O'i 

cl u z: 
X u M 

2 =' Z 


Uj vCi 

i?-. a-, o- a-- o-- O' 

in uj u"j in if) in 


co o- o y- 04 co in >o o> oj a-. © —• 04 co in >g ix co o- © —« 04 
oooqopoc’qoc'o^ — — ^ — oj m oj 

U.'UJ>y'U'4j'<jv{.i'<.<'*.i'Ci'0'0'£i'Ci'0'0'Ci'0'0'0'Ci>0'0'0>Ci 


CO 

2 

2 

© 

© 

in 2 2 

© 

2 


© 


2 

© 

<£ 


2 

© 

© 

*4" 

2 

2 


Uj 

O- 

O 


© 

© © 

© 

Uj 

u- 


04 

•N 

<3- Uj 

04 

'i- 

uj 

04 



04 in 




04 

m 


Uj 


<3- 


IT' 

04 


04 

04 04 

© 

Uj 

© 

Uj 

•N 

2 

•5T © Uj 

04 

0 

2 

*x 


Uj 

04 CO 

CO 


Uj 

04 

2 



O' 

O' 

<L 

CO 

O' 


© 

© © 

© 


04 


in 

04 

U j 04 

Uj 


04 

CO 


*3- 

in u j 

in 


* 3 - 

Uj 

cj- 


04 

<3- 


in 

'N 

CM 


CM 

04 04 

© 

04 

<r 

© in 

U 

O' <x © 

in 

O' 

2 

© 


© 

Uj © 

Q 

2 

O 

in 

04 


<L 

© 

■r 

O' 

© 2 


© 

© © 


in 

co 

04 

■t 

'J- 

U j CO 04 

•T 

'3- 

*3" 

Uj 


04 

^ 04 

u- 

ir« 

04 

< 3 - 

Uj 


CO 

04 

in 


04 



04 

04 04 

© 


•‘•j 

© 

«r 

2 

04 CO © 

'T 

■0 


o- 

2 

© 

^ oj 

in 


O 

'J- 

04 

© 

«N 

O 

O' 

0 

U 

U 

2 


© © 



in 

04 

U^' 

«3- 

«*■ ITi 04 

in 



in 

in 

04 

Uj 04 


04 

04 

Uj 


04 

in 

04 



CO 

04 

in 

© 

04 04 

04 


<X <X 

in -G <L 04 

Cl Ci UJ u 

O' O' Cl Ci 


<X 

2 

-0 

2 

2 

CM 

u 

2 

© 

2 

in 

2 

'Ll 

04 

u 

2 


2 

© 

2 



© 

© 


0 4 

'.'4 

04 

© 

© 


© 

04 

CM 

04 

04 

© 

© 

O 

O 

O 


O 


2 

CO 

04 

© 

© 


04 

•c 

‘X 

CO 

04 

© 

© 

'T 

© 

3 

O 

© 

° 

© 

© 

© 



© 

© 

© 

© 

© 

© 



© 

O 

© 

© 

‘X 

O 

2 

© 

04 

<3- 

*G 

00 

<x 


2 

© 

•N 

cj- 

<• 

CO 

<T 

i—• 

2 

© 

u 

U 

U 


© 

© 

© 

© 

© 

© 

0 









04 

2 

2 

2 

0 

O 

O 

O 

0 

0 

0 

i‘ ‘i 

0 

O 

0 

O 

O 

O 

O 

O 

O 

O' 

O' 

O- 

O' 

o> 

O' 


0 - 


O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 





2 

Uj 

Oj 

2 







z 


H 


if) 

3 









X- CL 


2 

2 








-J 

O 1— 


CL 

<1 






CL 

y- 

2 

2 u j 

CL 

O 

> 


CD 




2 

X 

> 

x 2 

O 

2 



2 



CL 

I— 

Z 

2 

2 *- 

2 

<X 

2 


CL 



2 

2 


-J 




Oj 

CL 


O 

O 

y- 


u 


O 2 

>• 

1— 

2 

O 


2 

2 

z 

s 

0 

2 

h- 

<X 

z 

X 

h- 

Cl 

CL 

CL 

*-• 

0 



i <r 

UJ 
' CL 


X X I 
UJ UJ 
ci Ci : 


o <r 
u h- 

<E if) 


<x *-• 
; cl y- 
• c> <1 

« HH <t O (_• 

hltO 
x >- if) Cl -1 


-.0 

2 

<r 


o 

CD 

O 


<X X 

2 O- 

cl o 

CL O 


o o 
; 6 © 

x x 
■> o 

88 


O 

h 

CJ 


z 

<1 

CL 


XXX 

u o o 
u o o 

O iN 04 


CL 

2 

H 

2 


i Ci CO 

. u u 

I UJ UJ 
i Ci Ci 


I Cl 3 3 
U U U 
UJ UJ UJ 
i Ci Ci Ci 


*“« 04 
CL CL 

CO CO 

2 2 


CL CL 
if) CO 
2 2 


if) if) : 

Q. uj i 

ui i 
\- >- : 

if) CO . 

2 2 i 


—• 04 CO «t in -Ci O © O’- O ^ 04 CO ^ 111 >0 O 00 O'- O ^ 04 CO *t in <i O CO O'. 

in no in in in in in in in 'O -o 'O >o »o sD >o >o -0 -o t*^ O' O' O' o» o- r-' 

in in in in in in in in in in in in in in in in in in in uo in in in in uo in in in in 


CL 

i—i 

(X 

UJ 

X 


<x © o o 

O' © O © 
O' o o © 
04 O © © 
CO O- O O- 
uuuu 


<r © 
© © 

— © © © 
© © © © 


04 04 
© © 

© © © © U. © © 

© © © © u o © 


U © Ll -t c:i U. CO <> 2 2 © 2 2 O' UI UI UJ UI llO Uj UO O UJ © CO llO 04 UJ © 04 <3- 

^ 04 04 UO llO ^ ^ 04 04 UO 'N 04 IT' 04 04 ^ 04 *3- UO UO 'T t UO 'N 't UO ^ 04 IT' ^T 

in O- Q © UI © © UI Ul © UJ UI © UJ © © UJ O II U. UI O 00 CO CO U. UJ UO 04 ’H 

UO 04 ^ Uj UO 04 04 04 04 04 04 04 04 UO 04 04 ^ ^ UO «*■ UO UO «*• «tf- UO U“< UO <«■ 

04 -h o. uo *-• -h uj co uj co uj uj uj ui uj co ui co o uj -g ^ i> uo ^ h 04 u. t co © uo ^ © 

in ^ CO ^ ^ UO 't 04 UO *0 04 04 Uj 04 04 UO 04 ^ <3" ^ ^ UO <3- UO 04 UO 04 04 ^ UO 04 

^ Cl CO 'O 04 © 04 © UI UI © UI UI © Ul Ul © LG © -O © © UJ 'U © CO 04 ^ Cl CO © © > 3 - rn < 3 - 

*=0 UO CO UO UO 04 04 «*■ 04 04 04 04 04 04 04 04 U0 04 04 «4- 04 UO IT) *3- 04 04 UO UO UO 


O' U U. 04 

< 3 - <4- in 
<r <x <x <x 

rv O' O' 


O' CO O CQ 

uo uo uo uo 

<E <L <X <X 
NOON 


QUJIlOh 04 «4- 
UO IT' UO 'O 'Ll 'Ll 'Ll 

<x <r <x <x <x <r <x 

s s s N s s s 


Cl 

(J 

<T 


Page 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

305 












be 

ft. 

K 

O 


© 

Cn 

© 

CO 

CO 

LlJ 


Cl 

2 

5 


LU 

K 

> 

LU 


*C 

c 

a 


UJ 

z: 


o_ <x <r 
Q cn X 
2 0 0. 


h- 


_J 



> 

> 









UJ 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

-J 

_J 

CC 

o: 

o: 

X 

X 

>- 

X 

<x a 

cn 

cj <r 

<E 

Cl 


Cl 

Of 


CJ 

CO 

CO 



l> 

in 

Q 

CO 


co 


<3- 

o 


o 

CO 

O' 


© 

a 

CN 

CO 

■-.j 

5 

© 

CN 


3 

0k 

CN 

© 



o 


© 


CO 

I-— 

CO 

© 

1— 

i=i 

CJ 

o 

CC 2 

o 

1=11- 

Cl 

X 

CO 

o 

cc> 

CJ 


-o 

rx 

CO 

CO 

<r 

p 

© 

**- 


Cl 

aii 

00 

co 

O' 

CO 



<E 

CO 

CO 

u 

CJ 

1=1 

1=1 

CO 

rx 

•x> 

0 

O 

rx 

u 

N- 

o 


•DO 

o- 

X 

<x 

CO 

_J 

LC 

05 

_J 

1=1 


O <X 

UJ 

<X CO 

_J 

O 

CO 


•3- 

in 

c 

co 

© 

CO 

o 

o 

o 

€ 

<X 

<r 

<L 

i—i 

Cl 

i—i 

1=1 

1—1 

UJ 

UJ 



o 

in 

in 

in 

IT' 

a 

<L 

p 

p 

p 

CN 

o- 

UJ 






0. 

0. 

0. 

0. 

0. 

0. 

0. 

0. 

0. 0_ 

Cl 

0. CL 

0. 

0. 

LL 


o 

© 

o 

o 

© 

o 

o 

o 

o 

o 

© 

o 


o 

© 

o 

•=- 

© 







CN 

•N 

iN 

CN 

CN 

CO 

CO 

CO 

CO 

CO 

CO 


•3- 

*3- 

N- 


3 

UJ 

3 

3 

2 

3 

3 

3 

3 

2 

3 3 

3 

3 3 

3 

3 

3 

<x 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 3 

3 

3 

3 

3 

3 3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

u 

-1 

u 

LL 

u 

u 

u 

u 

u 

u 

u u 

u 

u u 

u 

u 

u 


u 

ll 

u 

u 

IL 

u 

u 

u 

IL 

u 

u 

u 

u 

u 

u 

Ll 

U U 

Ll 

li 

Ll 

Ll 

U U 

u 

u 

u. 

IL 

u 

u 

u 

U 

U 

u 

U 

Ll 

U 



UJ 

CO 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

Ul 

UJ 

UJ UJ 

Ul 

UJ UJ 

UJ 

UJ 

UJ 

(J 

UJ 

Ul 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ UJ 

UJ 

UJ 

Ul 

UJ 

UJ UJ 

UJ 

UJ 

Ul 

UJ 

Ul 

UJ 

UJ 

UJ 

Ul 

UJ 

LU 

UJ 

Ul 

UJ 

UJ 


<x 

a 

a 

a 

Cl 

Cl 

Cl 

Cl 

1—1 

1=1 Cl 

o 

a ci 

a 

Cl 

UJ 

*-« 

o 

L—1 

Q 

1=1 

Cl 

a 

1=1 

Cl 

Cl 

a 

Cl 

UJ 

Ul 

Ul 

Ul 

Ul 

a ui 



Ul 

Cl 

Cl Cl 

Cl 

o 

1=1 

Cl 

o 

1=1 

Ul 

Cj 

Cl 

a 

a 

Cl 

Cl 

a 

Ci 


O. 

X 

o 

—> 


c B 

t- 

2 


1=1 

1=1 

o 


IT.' <1 N 01' OO N 'Tj in -O CO |?0 ^ CN CO 'fio <1 N Cu O -H CN CO «3- |f) N5 »x 05 & C' 

.. 


... ... - . .. . - ... _ . „ . _ ... _ . .. _ _ • cn co in >o rx co o -* cn co n- in ->0 rx © o-. o ^ cn co id <• 

CO COCCI CO CO |M> O' (>• aIMM>. o O O O O O O O ° O ^ H H H H H H H H H CN CN CN CN CN CN CN 04 <N CN CO CO CO CO CO CO CO CO CO CO -t «f 

'£*'-o-c«'-o-o-o-o-0'0'-o-o-0'0-0'-or^r-~r--r--r— r^r--r--r^r^r^-r^r^-r--i— r--r— — r-.r~.r^.r^r^-r^r^r^r^r--i— o-r--r~. 


in 

co 

CO 

CO 

CO 

co 

co 

co 

co 

«!■ 

«4- 

«*■ 



n- 

•t 

N- 

uo 

'Ll 

00 

co 

00 

O' 

O' 

Ok 


<L 

<x 

<r 

LU 

ui 

Ul 

a ci 

Ul 

Ul 

o 

o 

o in 

in 

IT- 

in 

O' 

<i 

o 

o 

o 

C-4 

O' 

Ul 


-4 

-H 


rx 

|x 

rx 

|X 

rx 

rx 

rx 

rx 







r^ 


O 

o 

o 

Q 

p 

o 

p 

o 

p 

o 

p 

p 

p 

o 


O 

o o 


o 





N 

N 

CN 

CnI 

M 

Of 

« 

I-'-' 

CO 

•:o 

co 

N- 



N- 

a 

00 

o 

<1 

N- 


O (J 

Ci 

cn in 

00 

C0 LU 


co 

o 

CO 


p 

« 

CO 



o- 


CJ 

CO 

Of 

co 

CO 

<3- 

o 

so o 


o 

Of 

co 

O'- 

CN 

CO 

>X< 

o- 

o 

CN 


CO 

o 

IN 

O 



o 


o 

in 

co 


rx 

00 


lO 

CJ 

Cl 

•t 

in 

>o 

r- <x 

LU 

o 


00 

o 

>0 

Mj 

r^- 

lO 

CO 

<r 

o 

o 

N- 

o 

a 

CO 

•DO 

oo 

O' co 



<L 

co 

co 

u 

o 

i=i 

Cl 

CO 

N 

co 

O' 

O'- 


u 

N- 

O 


00 O' 

o 

00 

<L 

o 

Ul 

o 

CN 

•3- 

o 

CO 

<r 

CJ 

UJ o 

CN 


o 

00 

<L 

CJ 

UJ 

o 

CN 

N- 

-o 

CO 

<r 

CJ 

Ul 

o 

•N 

'S’ 

>0 

CO <L 

CJ 

Ul 

o 

IN 


•4} 

CO 

<r 

CJ 

UJ 

O 

CN 


v0 

05 

<x 

o 

UJ 

o 

CN 


00 

00 

CO 

00 

CO 

o 

a 

o 

&■ 

o 

O'- 

a- 

O' <x 

<r 

<r 

<r 

<x 

<L 

<r 

X 

LU 

LU 

LU 

LU LU 

LU 

CO 

CO 

o 

CJ 

CJ 


Q 

CJ 

o 

Ul 

LU 

cn 

1=1 

Ul 

Cl 

Cl 

Ci 

UJ 

UJ 

UJ 

LU 

UJ 

UJ 

UJ 

LU 

u 

U 

u 

cj 

a 

o 

o 

CJ 

p 

O 

CJ 

o 

CJ o 

o 

CJ CJ 

a 

o 

o 

CJ 

O 

CJ 

u 

CJ 

1 

CJ 

CJ o 

CJ 

CJ 

CJ 

o 

CJ 

o 

c_* 

O CJ 

o 

CJ 

CJ 

(J 

CJ 

•J 

CJ 

CJ 

CJ 

o 

O 

CJ 

o 

CJ 

o 

o 

CJ 

CJ 

o 

■_< 

o 

rx 

rx 

rx 

fx 

rx 

rx 

rx 

r^- 


1^ 


hv 




i^. 

6- 

I s - 

r^. 




h- 






r^. 

r^- 


h' 

h- hv 

r- 



r^- 



l-v 

r-v 

f'v 

rv 



f'V 


r>. 

r^. 

r^. 

h- 



h*. 


to 

_i 

3 

<r 


>- X > X x x > _J 

. . - . - - - <r 

O O 01 iO O W O iO (5 E O > iO 

U-0.Cuuj0.C0u.L0a.X0.2L0 
NN<T<IN<Xr>J<lN*-HN>-<<I 


J O (Tj u 0) U G 

llX>>(JuZIiJ 

COCuCOCOCOCOCOCu 


O !J M H > > Q l=| 

JOJJLUJ2JLU 

CJ CO O CO CJ O if, 


iX 
O 

3 


X 

X 

X 

X 

X 

X 

X 

X 

X 

X 

X X 


X 

X 

X 

X 

X 

X 



•a. 

CO 

CN 

o 

N" 

>L> 

LU 

o 

<1 

o 

^ >0 


N5 

UJ 

LU 

•N 

UJ 

CN 


O 

o 

o 




o 

O 


o 

o 

o o 

Ul 

IN 


CN 

Ui 

o 




•o 

CN 

U. 

LU 

UJ 

LU 

CN 

CO 

NJ 

<J 

Ul CO 

-1 

o 

o 

O 

O 


—4 

CN 


•N 

CN 

CN 

CN 

O 

o 

CN 

CN 

IN 

o 

o o o 

CO 

cx> 

00 

<3- 

<3- 

o 

o 

O 

O 














<X 






















y- 









Ul 






















co 






















UJ 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

co 

3 

3 

3 

3 

3 

3 

3 

3 


U 

U 

u 

U 

U 

U 

U 

U 

U 

U 

U 

U 

<L 

U 

U 

U 

U. 

U 

Ll 

U 

Ll 

X. 

UJ 

UJ 

LU 

LU 

UJ 

LU 

UJ 

LU 

LU 

LU 

LU 

LU 

X 

UJ 

UJ 

UJ 

UJ 

UJ 

UJ 

LU 

LU 


Cl 

Cl 

Ul 

LU 

LU 

a 

Ul 

UJ 

Cl 

ul 

a 

Ci 


a 

a 

a 

a 

Ci 

a 

a 

a 

Ill 













X 






















CJ 













_J 









2 

-j 








(0 




Ui 





-J 




<L 

UJ 

















UJ 




cn 













X 





►- 




05 









Ll 


Q 

£ 

o. 


Of 








»-• 















LU 

X 

X 

X 

X 

X 

X 

X 

-J 















Ul 

in 


Cl 

O' 


© O' 

in 

LL 

0. 

0. 

<x 

<r 

>- 

>- 

>- 

X 

<X 

X 

X 

0. 

cn 

X 


Po 

CO 

CO 

LO 

•t 

O CO 

Ul 

X 

X 

-J 

X 

_j 

IU 

<L 

2 

2 

X 

«a 

UJ 

O 

a 

X 

O 





o 

o CO 

ou 


0. 

LL 

0. 



1— 



1- 

h- 


2 




o 

o 

o 

o 


o o 

© 


LL 

a. 

CL 

LL 

LL 

LL 

LL 

LL 

LL 

LL 

0. 

0. 

<r 

Cl. 


33332222 

U.U.U.U.U.U.U.U. 

©©©©©©©© 

QQuQOOQQ 


00 

f— 

o 
_J 
. u. 


3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

3 

UJ 

3 

3 

3 

3 

3 

3 

3 

3 

3 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

Ll 

-J 

Ll 

Ll 

Ll 

U 

Ll 

IL 

Ll 

Ll 

Ll 

U Ul 

LU 

Ul 

LU 

LU 

LU 

LU 

LU 

LU 

LU 

UJ 

© 

UJ 

LU 

Ul 

Ul 

UJ 

UJ 

UJ 

LU 

LU 

Ul 

Cl 

Ci 

Ci Ci 

© 

Ci 

Q 

Cl 

Cl 

Cl 

© 

<x 

© 

Q 

© 

© 

Q 

Q 

© 

© 

© 


5? 

CO 


in 

X' 

rx 

© 

O' 

© 


CN 

co 


in 

'O 

rx 

© 

O' 

© 


CN 

Of 

•t 

in 

>0 

rx 

© 

O- © 


CN 

Of 

•=r 

in -o 

rx 

© 

o- 

© 


CN 

05 

^ in 

N5 

rx oo 

o- 

© 


CN 

Of 

•t 

in 

o 

rx 

© 

O'- 

© 


CN 

CO 



0-4 

CN 

CN 

04 

CN 

CN 

CN 

CO 

Of 

Of 

CO 

CO 

CO 

CO 

Of Of 

C'.i 

N- 

N- 

•t 

<r 

N- 

•t 



N" 

n- m> 

ir.« 

in 

in 

in 

in in 

in 

in 

in 


>0 

>0 

•6 

>0 'Ll 

*o 

'O 'Ll 

o 

rx 

rx 

IX 

rx rx 

IX 

rx 

rx 

fx 

IX 

CD 

© 

CO 

© 

© 


Nj 

*0 

~L' 

<• 

>0 

O 

>0 


<> 

<j 

'O 

>0 

>0 

o 

'Ll 

N5 

O 

>0 


o 

<i 

n0 

>0 

'O 

N5 

o 

•o 

>0 

-0 

-u 

<> 

>o >o 

'Ll 

o 

'Ll 


'O 

-O 

'Cl 

'O N5 

N5 

>o o 

-u 

o 


'O 

'O 

N5 

<1 

'O 

'O 

'0 

'O 

N5 

-0 

'0 

'0 

'Ll 

& 

C 





























































<• 

C--4 

U 

© 

UJ 

© 

CN 

© 

o 

o 

UJ 

© 

ffi 




© 

© 

© 

© 



CN 

CN 






«*- 


© 

© © 

© 




CN 

CN 

CN 

CN CN 

CN 

CN CN 

CN 

CN 

CN 

CN 




in 

in 

in 

in 

in 

in 

in 

in 

in 

w 

CN 

0-4 

CN 

CN 

© 

© 

•N 

CN 

CN 

p 

o 

o 

© 




Qj 

© 


«5- 

© 

© 

© 

© 




© 

© 

p 

© 


© © 

© 




rx 

rx 

rx 

rx rx 

rx 

ix rx 

rx 

rx 

rx 

(x 




rx 

rx 

rx 

rx 

IX 

rx 

rx 

rx 

|X 

V 

<E 

CO 

CN 

© 


-0 

a 

© 

<L 

o 


© 

<1 




vO 

© 

© 

CN 

© 

CN 

CN 

>0 




in 


© 

o. 


© O' 

u-i 




© 

in 


CO ^ 

rx 

Of o 


© 

<L 

© 




<i 

© 

'U 

o 

CN 

rx 


rx 

© 

i 

© 

© 



© 

© 

© 


© 

© 

© 

© 

© 




CN 


CN 

Of 

© 


CN 





Of 

© 

05 

© 


© Of 

© 




rx 

<i 

rx 

O'- uo 

o 

^r co 

Cl 

© 


N5 




'C 

-0 

rx 

IX 

© 

© 

O' 

<x 

O 

■c 

e 

•N 

N" 

'Ll 

CD 

«i 

CJ 

UJ 

© 

CN 


o 

© 

<r 




CJ 

ixl 

© 

CN 


O 

© 





u 

© 

© 

CN 

N- 

<> © 

<x 




o 

© 

© 

CN 


© <r 

CJ 

© 

© 

CN 




*3- 

-4D 

© 

<r 

CJ 

© 

© 

CN 

•t 

o 

CN 

0-4 

•N 

CN 

CN 

CN 

«N 

« 

CO 

w 

Of 

Of 

CO 




W 

CO 



N- 

•t 

N- 

N- 




N- 


in 

in 

UO 

in in 

in 




in 

Bl 

«o 

'O 'Ll 

'Ll 

O 'Ll 

9 

'Ll 

rx 

lx 




rx 

rx 

rx 

rx 

rx 

rx 

CO 

CO 

CO 


O 

o 

O 

CJ 

u 

CJ 

O 

o 

o 

o 

CJ 

CJ 

U 




CJ 

CJ 

O 

CJ 

CJ 

CJ 

o 

O 




o 

CJ 

CJ 

u 

CJ 

CJ CJ 

CJ 




CJ 

o 

CJ 

O CJ 

o 

O CJ 

p 

CJ 

CJ 

CJ 




o 

CJ 

o 

U CJ 

CJ 

CJ 

o 

CJ 


lx 

lx 

lx 

rx 

rx 

rx 

fx 

rx 

rx 

rx 

rx 

fx 

rx 




rx 

IX 

rx 

rx 

rx 

rx 

rx 

lx 




rx 

rx 

rx 

rx 

rx 

rx rx 

rx 




rx 

rx 

rx 

rx rx 

rx 

rx rx 

rx 

rx 

rx 

rx 




|X 

rx 

rx 

rx 

IX 

IX 

fx 

rx 

|x 


Page 40 

306 


Dr. Dobb s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 



















0001 ; LOADER 

TO 

ALLOW ZX65 TO EXECUTE UNDER CP/M 



0002 ; 



>0020 


0003 SIZE 

EOU 

32 ; # K 3 y 3iEH MEMURv 

>8000 


0004 TOP 

EQIJ 

RES. SIZE*1024 

„>6F 00 


0005 BASE 

EQU 

RES TOP-1100H , BASE OF ZX65 

>0F 00 


0006 LNGTH 

EQIJ 

OFOOH LN6TH OF SYSTEM 



0007 ; 



>0100 


0008 

IjRfji 

100H ■ FOR CP/’M 

0100 

211001 

0009 

LD 

ML. - TEMP 

0103 

11006F 

0010 

LD 

DE.BASE 

U1( 

t) 10i K >F 

0011 

l D 

Eh i LNGTH 

0109 

E0B0 

0012 

LDIF 

i SYSTEM TO HIGH MEM 

010B 

C3006F 

0013 

JP 

BASE i GO EXECUTE II THERE 

01 OF. 

00 

0014 

NOP 


01 OF 

00 

0015 

NOP 


0110 

00 

0016 TEM D 

DEFE 

o 



0017 , 





0018 

END 



ti R R U R -I* — ij 00 0 

"ZXLD" .. . Auxiliary loader required to boot main program from CP/M. 


THE END 



Page 42 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

307 









RULES NOT ALWA YS MADE TO BE BROKEN 

Dear Editor: 

If any of your readers are thinking about hanging a dot¬ 
matrix line printer onto their microcomputer system, I have a 
friendly warning to pass on to them. “Pay close attention to 
your manufacturer’s recommendations, or know the risk 
you’re taking if you ignore them.” 

For example, North Star recommends the Anadex DP-8000 
connected to the parallel interface of their Horizon. But com¬ 
paring printer specs, I chose to save a few bucks by building a 
Heath H14 line printer for the serial interface. 

I saved some money at $625.00 plus shipping, plus an 
additional $82.98 at Heathkit Electronic Center in Seattle 
when the H14 flunked its initial power-on tests. They replaced 
two defective CMOS IC’s and repaired three open foil breaks 
in the five volt supply on the PC board at no charge, but they 
detected erroneous installation of seven transistors. (Consider¬ 
ing the obvious textual errors in the documentation, which 
would you believe—the text, or the pictorials? I guessed wrong 
and followed the pictorial. Customer error!) 

My WH14 printer tested perfectly at 4800 baud under 
HDOS in Seattle. It went ape at 4800 baud on the Horizon 
after I got it home. A quick phone call to my friendly Horizon 
dealer divulged the fact that North Star DOS does not test 
for handshaking signals! (The Heath manual advises to run 
no faster than 110 baud without handshaking.) 

So now I have a 110 baud line printer dawdling along 
while the 4MHZ Z-80A and I are twiddling our respective 
thumbs! Does anybody out there want to trade an in-warranty 
Anadex DP-8000 printer for an in-warranty Heath WH14 plus 
some extra cash? 

Sincerely, 4807 Fifteenth Ave. S.E. 

John R. Dye Lacey, WA 98503 


GROWING PAINS IN THE SOFTWARE MARKET 

Dear Suzanne; 

On seeing my letter published in the April, 1980 issue, 
I realize that my expression of my frustration at the marketing 
methods of the CP/M products could easily be misconstrued 
as condemning these products or their marketer. This was not 
my intent and I would like to publically retract the poorly 
written letter. 

I have every reason to believe that the packages offered 
by Lifeboat Associates are very valuable items. I believe that 
Lifeboat does a skilled job developing some of these pro¬ 
ducts for wider use. 

My problem is that as a relative newcomer to data proces¬ 
sing with a great perceived need for business systems not yet 
available, I have devoted at least half my working efforts for 
several years in this direction. I find that to implement a new 
complex package that I need more support than I am able to 


obtain by telephone during limited daytime hours from New 
York City. I have scoured the dealers of the Northwestern 
United States and occasionally elsewhere and can find virtually 
no one who can demonstrate the CP/M software packages 
in operation. When I have inquired why this obviously de¬ 
sirable material is not offered, they tell me that they have to 
purchase these from Lifeboat at list price and that they can 
not afford to do this. Hence they stick with the sytems which 
are promoted through dealerships. 

I believe that both the CP/M producers and Lifeboat 
Associates have the full right to market their product anyway 
they please. However, for this product to serve the needs to a 
person like myself who is capable and willing to pay for them, 
they have to offer some type of distributed customer service 
perhaps comparable to Sears or Penneys. Both of these latter 
companies have customer service departments in my city. I 
can go and get almost any type of assistance in operating or 
implementing any product ordered through the catalog. Soft¬ 
ware packages are complex items especially when run on exist¬ 
ing machinery. 

The purpose of my comment was to alert the marketers 
to the fact that their valuable material was not serviceable 
in the hands of a remote user. 

Most sincerely, 

Robert C. Luckey, M.D. Richland, WA 


Dr. Luckey is entirely correct in his claim that many soft¬ 
ware products-as well as hardware products-are not a- 
dequately serviced once they are bought. It was once ex¬ 
cusable because of the “newness” of the micro industry; 
however, that excuse no longer rings true. Vendors of both 
hardware and software products can and must increase the 
way they respond to the buyer after the product is sold. If 
not, they will simply go under. Only the best deserve to 
survive in this market; and that is not only a function of those 
who sell the best product, but of those who maintain their 
product and serve the customer after the product is sold. 
Automobile manufacturers who had no warranties or follow- 
through, once the auto was sold, would quickly go out of 
business because nobody would buy their products. It should 
be this way with software and hardware. Dr. Dobb’s en¬ 
courages you to send both your praise and horror stories to 
us. - SR 



Number 47 

308 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 








ANIMAL 


Dear Suzanne, 

Regarding Charles Wetherell’s ‘famous programs’ in DDJ 
#42, the smallest program that will run the longest time is 
something like 

HERE JUMP HERE 


which will run for as long as you let it, besides being portable 
to any computer I know of. 

As far as ‘virus’ programs, I know of one story: a large 
development center of a large computer manufacturer (I 
won’t tell you which) had a game called ‘Animal’ in which 
one had to guess which animal the program was talking about 
by making questions to the program and analyzing the answers. 
What the player did not know, however, was that while the 
game was being played, the program accessed the user’s di¬ 
rectory and copied itself into every file (in this machine files 
are composed of elements, so one can have multiple elements 
in a file) it could get hold of. In a while, virtually every file 
of that computer had its own copy of ‘Animal,’ and I was 
told that the management held several secret meetings to 
find a way of getting rid of the ‘animal’ without ever acknow¬ 
ledging that it existed! 

Albertus Caesar Chalfont St. Peter 

22 The Paddock Bucks SL9 QJQ 

England 


CORRECTION 

Dear Suzanne Rodriguez, 

I’m afraid I made a few mistakes in the letter published in 
DDJ #45. The BASIC demonstration program should have 
read — 

145 PRINT 

150 PRINT “X” = ”;CY,C\256 
160 PRINT “Y = ”;CY,C MOD 256 

Also, in the article on page 36 there is a reference to a routine 
on track zero to initialize the 16 ports at 0CF00H. This routine 
is on the disks from OSI, it is not on the disks referred to in 
the article. The problem then is not that the ports are over¬ 
written, it is that they are never initialized to begin with. 

A late but happy Easter. 

Yours truly, 

L. Barker 


MORE ON KEYPLUS 

Dear DDJ: 

We would like to thank Lt. Ronald Nicol for his favorable 
review of our Keyplus Integrated Utility Package for the 
TRS-80 in DDJ #45. However, there are two points that need 
clarification. 

Lt. Nicol states “The documentation that comes with the 
software is excellent with the exception that the chart of 
graphic symbols is inaccurate.” Not true; we triple-checked 
and the chart is 100% accurate. 

Later on Lt. Nicol remarks that all utilities, even ones not 
being used, must be resident in memory. The Lt. believes this 
to be a drawback. In all fairness, it should be pointed out that 
the tape loads in just 20 seconds and requires less than 800 
bytes of space; furthermore, utilities may be enabled or dis¬ 


abled in just two key strokes! Isn’t this better than fooling 
around with several tapes each with a separate utility on it? 

One final point, a disk-based version of Keyplus is avail¬ 
able for $19.95. Disk Keyplus contains several enhancements. 

Sincerely, SJW, Inc. 

Steven Wexler P.O. Box 438 

Huntingdon Valley, PA 19006 

TINY-C ON PHIDECK 

Dear DDJ: 

The May Special Issue — The C Programming Language- 
struck a responsive cord at this location. A few of your readers 
might be interested to know that I have recently been licensed 
by Mr. Gibson to market an implementation of tiny-c (TM) 
for Digital Group Phideck systems. For the sum of $25 I will 
supply a tape and documentation. No overlays are used, so 
any version of Phimon can use tiny-c. A minimum of 26K, 
including the 2K set aside for Phimon, is necessary. The cas¬ 
sette tape has been prepared with a Phideck readable copy of 
tiny-c on one side and an audio copy on the flip side in case 
the Phideck version cannot be loaded. I also include several 
tiny-c utilities which I have developed. All of this, following 
Mr. Gibson’s lead in the tiny-c Owners Manual, is accom¬ 
panied by many pages of documentation. 

Any prospective user is urged to purchase the Owners 
Manual from tiny-c associates. Anyone wishing to know more 
details can write to me. 

Yours truly, DIGITAL GROUP Phideck Version 

Charles Hemminger 20 Harrison Ave. 

Northampton, MA 01060 



A DIFFERENT ERROR 


10 REM ** THIS PROGRAM IS TO POINT OUT A PROBLEM ** 
20 PRINT “COMPUTERS NEVER MAKE MISTAKES” 

30 LET X = X + 1 
40 IF X = 10 THEN 60 
50 GOTO 10 

60 REM ** LETS STOP PRINTNG THIS JUNK ** 

70 END 

I thought the problems with this program were: 

1. LETS should be LET’S 

2. X was never initialized 

not that transfers were made to REM statements in two places. 

Sincerely, 400 N. River Rd., #904 

Mark D. Senn West Lafayette, IN 47906 


Chicago, II. 


Dear Dr. Dobb s: 

Bruce Thomson’s program in DDJ #45: 


Page 44 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 47 

309 




Dr. DoBB'S JoURNALof 

COMPUTER 

(Calisthenics Orthodontia 

Running Light Without Overbyte 


Number 48 


September 1980 


Volume 5, Issue 8 


A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 


A Runtime Library for the Small c Compiler 

Ron Cain 

Hardcopy Device Driver Programs for CP/M 

Steve Willoughby 

A Note on 6502 Indirect Addressing 

W.D. Maurer 

The Love Program 

Gary Gaugler 


311 






RUNTIME LIBRARY 

BY RON CAIN 

811 Eleventh Ave. 

Redwood City, Ca. 94063 



COMPILER 


The May 1980 issue of Dr. Dobb’s Journal (DDJ #45), highlighting the C Programming Language, was one of 
the most popular issues ever. Foremost in popularity among the articles was “A Small C Compiler for the 8080's, 
by Ron Cain. Due to popular demand, we are now publishing Cain’s “Runtime Library for the Small C Compiler. ’ 


Page 4 

312 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 










The small C compiler for 8080’s published in DDJ #45, 
made reference to a runtime library. Although the listing of 
that runtime library did not appear in that issue due to the 
sheer mass of code of the compiler itself, there has been suffi¬ 
cient demand (and there is now sufficient room) for it. 

Actually, the library consists of two distinct modules of 
code. It contains: (1) the arithmetic and logical routines 
which are called from the code generated by the compiler, and 
(2) the I/O routines likely to be called by the user. 

The two modules are largely independent of one another, 
and it is conceivable you might choose to put them in separate 
files. Such a split would be exceedingly easy to accomplish. 
All the routines from “ccgchar” to “cccmpbcde” are the 
arithmetic and logical routines. All the routines after that are 
related to I/O. 

Perhaps it would be helpful to discuss how the compiler 
generates code to use the arithmetic and logical routines 
within the library. Suppose you have the following piece of 
code: 

int ram word; 

char rambyte; 

samp (value) int value; (return (ramword / value - rambyte);) 

The compiler would generate the following code: 
samp: 

LHLD ramword 
PUSH H 
LXI H, 4 
DAD SP 
CALL ccgint 
POP D 
CALL ccdiv 
PUSH H 
LDA rambyte 
CALL ccsxt 
POP D 
CALL ccsub 
RET 

ramword: DS 2 
rambyte: DS 1 

You will notice that, as I mentioned in the previous article, 
the compiler is very cautious in its use of registers. For all 
the binary operators, it always gets the first operand into the 
primary register (HL), puts it on the stack, gets the second 
operand (also into HL), pops the first operand off the stack 
into the secondary register (DE), and then does the operation. 

In the example above, it first evaluates “ramword” into 
HL with a simple 16-bit load. Seeing the “ / ”, it pushes 
HL onto the stack, and evaluates “value” into HL. Since 
“value” is defined as an argument passed to this routine, 
the compiler has to generate the address of where “value” 
is on the stack. At the time of the call to “samp”, the stack 
would have looked like: 

SP + 0 —> LSB of return address 
SP + 1 -> MSB of return address 
SP + 2 -> LSB of ‘Value” 

SP + 3 -> MSB of ‘Value” 

However, after pushing “ramword”, the stack would have 
looked like: 

SP + 0 — > LSB of ramword 
SP + 1 — > MSB of ramword 
SP + 2 — > LSB of return address 
SP + 3 — > MSB of return address 
SP + 4 -> LSB of‘Value” 

SP + 5 -> MSB of ‘Value” 

Therefore, the pair of lines of code: 


LXI H, 4 
DAD SP 

would generate the address of “value” in HL. To get the con¬ 
tents of ‘Value”, the compiler generates a call into the runtime 
library to the routine “ccgint”. Looking at the listing of 
“ccgint” (the third routine in the library), you’ll see it loads 
the HL register with the 16-bit integer pointed to by HL. 
Therefore, upon return from “ccgint”, the compiler knows HL 
contains the contents of “value”. Since it now has both 
operands for the operation, it pops into DE the operand for 
“ramword” it previously put on the stack, and calls another 
library routine “CCdiv” to perform the divide. The routine 
“ccdiv” returns the quotient in HL, which the compiler 
dutifully puts on the stack upon seeing the “ — ”. Since 
“rambyte” is defined as an 8- bit entity, the compiler evalu¬ 
ates it with a simple 8-bit load intruciton. Since it also 
assumes all operands to be 16 bits, it sign extends “rambyte” 
into a full 16-bit value in HL by calling the library routine 
“ccsxt”. Nearly done then, the compiler pops the previously 
evaluated quotient off the stack, calls another routine to do 
the subtract, and exits. Any routine calling the routine “samp” 
would then have the results expected in the HL register. 

It’s really not very complicated, and after looking at it 
for a moment you can see why the compiler can be so simple. 
All binary operators work in the same fashion. The few 
utility routines (like “ccgchar”and “ccgint”) work in a very 
predictable way, and inevitably return a 16-bit value in HL. 
In fact, the routine “ccgint” is the compiler’s universal routine 
for indirect references, which you see in code like: 

int * ptr; 

samp () return ***** ptr; 
which would generate: 


CALL ccgint 
CALL ccgint 
CALL ccgint 
CALL ccgint 
CALL ccgint 
RET 

ptr: DS 2 

Naturally, I would expect that many people would like to 
improve and expand their own runtime libraries. One simple 
improvement noticed by Walt Bilofsky (and since implemen¬ 
ted in my own version of the compiler), lies in the fact that all 
the binary library routines (ccdiv, ccsub, ccxor, etc.) are 
always invoked from the generated code by: 

POP D 

CALL ccxxxx 

The obvious move is to modify the compiler to not gener¬ 
ate the “POP D” instruction, and to modify the library 
routines to contain their own “POP D” instruction. Let’s 
trace such a modification down as an exercise: 

In the case of the divide operator, look at the listing of the 
compiler in the other issue. In the C routine “heir 9( )”, 
you’ll see where it parses the “/” character and performs the 
division. Where you see the two lines of code: 

pop(); 

div(); 

simply remove the “pop()”, and the compiler will no longer 
output the “POP D” instruction prior to the “CALL ccdiv”. 
Then, in the routine “ccdiv”in the library, simply insert the 
three lines of code: 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

313 



POP B lunstack return address 

POP D ;unstack operand into DE 

PUSH B prestack return address 

at the beginning, and you will have improved your version of 
the compiler. The number of “POP Destructions generated 
is considerable, and the compiled code will be made smaller 
by this simple modification, However, shorter code is not 
necessarily faster code. The extra “POP B” and “PUSH B” 
instructions in the library routine represent 32-bits worth 
of memory reference, and memory reference instructions are 
the slowest. So you can make your own version “optimized” 
(I use the term loosely) either for speed or for space. 

Another improvement to the compiler can be made to the 
routine “ccpchar”. If you’ll glance at the routine “putstk” 
in the compiler listing, you’ll notice it has the line of code: 

if (typeobj==cchar) call (“ccpchar”); 
else call (“ccpint”); 

Anytime the compiler wishes to store a single character 
at the address contained in DE, it calls “ccpchar”. Looking 
at the routine “ccpchar” in the runtime library, you’ll notice 
it consists of the code: 

ccpchar: MOV A, L 

STAX D 
RET 

Those familiar with the 8080 will realize the call instruction 
takes more room than the routine itself. Therefore, an obvious 
improvement for both code compaction as well as speed 
would be to make the compiler drop this code inline. Changing 
that one line of code in “putstk” to: 

if (typeobj==cchar) ol (“MOV A, L”): ol (“STAX D”) ; } 
else call (“ccpint”); 

would accomplish this with a minimum of effort. 

In fact, any or all of the routines in the library could be 
executed inline if desired simply by finding where the com¬ 
piler generates the instruction “call(“ccxxxx”)” and replacing 
that with calls to the routine “ol” for all the necessary instruc¬ 
tions. The compiler began life putting the code inline, and 
only after it became obvious which way the wind was blowing 
(toward another 8K memory board) did I change it to generate 
this threaded code. 

Other mods to the runtime library might include the addi¬ 
tion of floating-point routines. I am in the process of adding 
Charles Falconer’s floating-point routines to my own library. 
In time, either he or I will probably make the compiler smart 
enough to generate calls to these routines to handle floating¬ 
point numbers. Until then, I will simply call them as external 
routines from the program I write. Perhaps you have math 
routines in ROM, or an AMD 9511 chip, or some other favor¬ 
ite set of math routines. The runtime library is as good a place 
as any to put them if you expect to use them frequently. 
String comparers, string movers, random number generators; 
these are all good candidates for the libarary. 

Apart from the arithmetic and logical routines, I mentioned 
the runtime libarary also contains the I/O routines. My version 
supports Polymorphic’s 8810/8813 disk operating system. 
I know this is not the most popular choice, and I can hear the 
grousing already about the need to convert to CP/M. But 
console yourself with the fact that I probably would not have 
gone to the effort of writing the compiler if I’d been able 
to buy one of the already-existing CP/M C compilers. 

The I/O routines I chose to support are by no means 
the most efficient or universal set, but they run under UNIX, 
and as I’ll explain later, there were reasons. 

For your own system, there are only a few routines you 
will need to support. The runtime library listed here has 


considerably more than these, but I use the other routines 
only at times when it becomes necessary to step outside the 
normal UNIX interface. The routines which the compiler 
needs (and which do obey UNIX conventions) are as follows: 

1. fopen (sname, mode) char *sname, *mode; 

This routine will attempt to open the filename pointed to 
by “sname” according to the character pointed to by “mode”. 
If “mode” points to an ASCII ‘r’, it will attempt to open for 
reading. If it points to an ASCII ‘w’, it will attempt to open 
for writing. If the routine can successfully open the file for 
the specified mode, it will return a nonzero integer value, 
otherwise it will return a zero. The filename obeys the con¬ 
vention for strings by ending in a null byte (a zero), but other 
than that is free to look like a filename specific to the oper¬ 
ating system. For example, I might attempt “fopen(“<l> 
file.tx”, “w”);” where a CP/M user might try “fopen (“B:file. 
txt”, “w”);”. On my system, I enforce that no more than one 
file be open for output on a given drive at a time. A CP/M 
user would probably not need this precaution. 

The integer returned by this routine will reflect the “chan¬ 
nel number” for this particular file. Subsequent reads and 
writes will all refer to this number. You may choose to im¬ 
plement it either as a simple integer (from 1 to N depending 
on the number of channels you’ll allow) or an an address of 
some form of file control block. UNIX returns a pointer to a 
file structure. 

2. fclose (iochannel) int iochannel; 

This routine will close the file specified by “iochannel”, 
which is the channel number returned from fopen(). If that 
requires flushing internal system buffers to complete the 
file (say, if characters had been buffered in memory instead 
of on disk), then this is done. There is no success or failure 
indication returned from this routine. 

3. getc( iochannel) int iochannel; 

This routine will return the next sequential character from 
the file specified by “iochannel” (which, once again, is the 
channel number returned by the fopen() for this file. If an 
error occurs or an end of file is encountered, a — 1 is returned. 
A zero character is legal. 

4. putc(c,iochannel) char c;int iochannel; 

This routine will write the given character “c” to the file 
specified by “iochannel”. The character itself is returned if 
the write was successful, otherwise a — 1 is returned. 

5. gets (buff) char *buff; 

This routine inputs characters from the keyboard and 
stores them in the buffer pointed to by “buff”. The carriage- 
return or newline character terminating the string is replaced 
by a null. My version allows simple editing with deletes and 
control-X’s, but you can make yours do whatever you like. 

6. getchar( ) 

This routine returns the next available character from the 
keyboard. If no character is available, it will wait until there 
is. 

7. putchar(c) char c; 

This routine will print the character “c” onto the user’s 
terminal. 

The routines given above are probably the minimum num¬ 
ber you will want to support. They are all the compiler needs, 
so for starters, they are probably enough. Adding routines 
later is not difficult. In fact, you may have noticed the final 
part of the runtime library was written in C to provide a front- 
end for some I/O routines I already had. I wrote the necessary 
routines compiled them and appended the compiled code to 
the library. Total time: maybe 15 minutes. 

There are many ways to improve and expand this runtime 
library. I already mentioned a few relating to the arithmetic 
operators, but I’d like to make a few suggestions about the 
I/O routines. 

Though many alternatives exist, two which seem immedi- 


Page 6 

314 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



ately obvious are (1) make it smaller or (2) make it bigger. 

An example of the former was sent to me by Gene Cotton 
of Fountain Valley who wanted to put together a minimal 
configuration for his system. His approach is straight-forward 
and surprisingly lucid. He deleted all my I/O routines, and 
added an innocuous routine: 


bdos: 


CP/M SUPPORT ROUTINE 
bdos (DE,C) 
char *DE; int C; 
returns H=B, L=A per CPM manual 


POP 

POP 

POP 

PUSH 

PUSH 

PUSH 

JMP 


H 

B 

D 

D 

B 

H 

5 


Jiold return address 
get bdos function number 
get DE register argument 
; now put them 
back on 
the stack 
;now off the CPM bdos 


As CP/M users can see, this is merely a front end for the 
call to location 5 which they have come to know and love. 
It takes two arguments which it puts into DE and C respective¬ 
ly. Hence, a routine to get a character from the keyboard 
becomes: 


getcharf) (return bdos (1, 1);) 

To print a character becomes: 
putchar(c) char c; bdos (c, 2); return c; | 

In addition to making a tiny runtime library, Gene 
further surrounded the code with a “#ASM . .. #ENDASM” 
construct (as described in the compiler article), called it “C. 
LIB”, and begins his C programs with: 

^include C.LIB 


This means the runtime library is inserted right into the 
file being generated. A nice touch. The only penalty (if you 
want to call it that) lies in the need for the user’s program to 
do its own bdos() calls to open files, read files, and close files. 
If you’re already familiar with the way your own operating 
system works and would prefer to continue to work with it, 
I would suggest a similar approach. The Code Works (who 
are now distributing the little compiler for CP/M) independ¬ 
ently invented a nearly identical routine to simplify the inter¬ 
face. 

However, if you want to make your I/O libarary independ¬ 
ent of your operating system, and add some bells and whistles 
in the process, I would like to lay out some guidelines for 
expansion. 

From the very beginning, since C does not inherently pos¬ 
sess a knowledge of an operating system, people have been 
writing their own I/O interfaces to their system. Seeing this as 
a serious threat to the portability of the language, the users 
eventually came up with a “standard” I/O package. 

Rather than reliving this learning experience in the hobby 
field, I suggest all implementations and improvements aim to¬ 
ward this standard. For those who don’t know it, I’ll sum¬ 
marize the important routines as described in an article called 
“A New Input-Output Package” by D. M. Ritchie. 

Programs expecting to do I/O usually begin with the line 
of code: 


#include <stdio.h> 

This file contains many vital I/O definitions and para¬ 
meters. Among them (and worth including in all implementa¬ 
tions) are: 


#define stdin some-unique-value 
#define stdout some-unique-value 
# define stderr some-unique-value 


#define EOF -1 
#define NULL 0 
#defineBUFSIZ512 

These definitions provide system-wide agreement regarding 
certain terms, and you will see these in UNIX programs. 

The definitions stdin, stdout, and stderr are the first 
glimpse of one of the powers of UNIX. They are essentially 
default “channel numbers” for the keyboard, the console 
screen, and the error device, respectively. They do not need 
to be opened with an “fopen( )”, and they can be used in 
place of a channel number. Therefore the instruction “getc 
(stdin)” would return a single character from the keyboard, 
while “putc (c, stdout)” would print the character “c” on the 
console. This is not an unusual convention, but the power lies 
in the ability of a user at the keyboard to redirect these de¬ 
fault channel numbers to disk files (or any other peripheral). 
Hence, if a program is written to input from stdin and output 
to stdout, it will interact with the user terminal in its normal 
mode of operation. However, if the user invokes that program 
with some syntax like “%foobar > output < input arg arg arg 
.. . arg”, he will effectively have opened the file “output” 
to receive all writes to stdout, and the file “input” to provide 
bytes to reads from stdin. Without modifying the program, it 
has been changed to accept input from and send output to 
disk files. The channel for stderr cnanot be redirected, how¬ 
ever, and writing to it will always send the output to the user’s 
terminal. 

The definitions “NULL” and “EOF” provide names for 
some common values (zero and —1, respectively) likely to be 
returned by routines. BUFSIZ is merely the size of single 
I/O block (a disk sector in practice) and lets the user setup 
buffers of the appropriate size if needed. For floppy disk 
sytems, BUFSIZ should be defined as 256. 

The routines which follow are the most important of the 
I/O library. Most are mentioned in the book The C Program¬ 
ming Language by Brian Kernighand and Dennis Ritchie. 
To anyone considering using the C language and especially 
those writing their own I/O libraries, I would suggest this 
book. For those routines too detailed to discuss here, I will 
make references to it. 

1. fopen (filename, type) char * filename, *type; 

As described above, this routine opens a file for I/O 
and returns either a nonzero integer for success or the value 
NULL for failure. In addition to ‘r’ for “read” and ‘w’ for 
“write”, the argument “type” may point to an ASCII ‘a’ 
for “append”. My version does not support ‘a’. 

2. freopen (Filename, type, iochannel) char *filename, 
*type; int iochannel; 

This routine closes the file specified by iochannel, and 
then reopens it according to the new specifications of file¬ 
name and type. The value returned is either the new channel 
number of NULL. 

3. getc (iochannel) int iochannel: 

This routine, as described above, returns the next sequen¬ 
tial byte from the specified file. An EOF is returned for an 
end of file or error. 

4. fgetc (iochannel). 

Just like getc (iochannel). 

5. putc (c, iochannel) char c; int iochannel; 

This routine, as described above, writes the byte “c” 
to the given file. The character is returned if successful, other¬ 
wise EOF is returned. 

6. fputc(c, iochannel). 

Just like putc (c, iochannel). 

7. fclose (iochannel) int iochannel; 

This routine closes the given file. No specific value is 
returned. 

8. fflush(iochannel) 

This routine empties any system-buffered characters to 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 

315 





the file. It guarantees they are transferred to the output 
device. 

9. exit (errcode) int errocode: 

This routine cleans up whatever is needed, and exits 
to the operating system, returning the value in “errcode”. 

10. feof (iochannel) 

This routine returns a nonzero value if the given file 
is at the end of file. 

11. ferror (iochannel) 

This routine returns a nonzero value if an error has oc¬ 
curred while accessing the given file. 

12. getchar() 

This routine is effectively “return getc(stdin);”. 

13. putchar(c) char c: 

This routine is effectively “return putc (c, stdout);”. 

14. gets (buffer) char ‘buffer; 

This routine inputs a string from stdin. The newline (or 
carriage return) character is replaced by a null. It is the user’s 
responsiblity to guarantee the buffer is big enough. It re¬ 
turns either its argument (address of buffer) for success or 
NULL for an end of file. 

15. fgets (buffer, count, iochannel) char ‘buffer; int count, 
iochannel; 

This routine reads up to “count” characters into the 
given buffer from the specified file. A newline (or carriage 
return) character terminates the string and automatically 
is followed by a null. It returns either the address of the buffer 
for success of NULL if an error occurs. 

16. puts (buffer)char ‘buffer; 

Writes the null-terminated string from the buffer to 
stdout. A newline (or carriage return) is appended. 

17. fputs (buffer, iochannel) char ‘buffer; int iochannel; 

This routine writes the null-terminated string to the 
specified file. No newline is appended. No value is returned. 

18. ungetc(c, iochannel) char c; int iochannel; 

This routine offends my sense of fair play. It “pushes” 
the given character back out the given input file so the next 
read will accept it. Only one character may be pushed back. 

19. rewind (iochannel) int iochannel; 

This routine causes the specified file to be rewound to 
the beginning. It is usually used only on input files, since 
rewinding an output file essentially discards all previous out¬ 
put. 

20 . 


printf(format, al, a2,... an) 

fprintf (format, al, a2, ... an) 

scanf (format, al, a2, ... an) 

fscanf (format, al, a2, ... an) 

fread (ptr, size, n, iochannel) 

fwrite (ptr, size, n, iochannel) 

system (string) 

atof (string) 

cfree (ptr) 

calloc (n, size) 

strcat (sl,s2) 

strcmp (si, s2) 

strcpy (si, s2) 

strlen (s) 

isalpha (c) 

isupper(c) 

islower (c) 

isdigit (c) 

isspace (c) 

toupper (c) 

tolower (c) 

All these are described in the manual. They are all nice to 
have but are more suited to a set of utility programs (maybe 
kept in a separate file) than they are to a runtime library. 

There are a few other routines not mentioned, but not all 
of them are supported even on UNIX systems, so they have 


been omitted. Not all of the routines above need to be sup¬ 
ported, but at least you have an idea of what a full implemen¬ 
tation would entail 

As I mentioned, my version supports only the minimum 
number of these routines, and it does not know about stdin, 
stdout, or stderr. Actually, the version I am currently working 
on in my spare time will be very close to everything I have 
described above. As I mentioned before, it will contain Charles 
Falconer’s floating point routines. 

To make C programs run in an environment more similar 
to UNIX, I am making the compiler (via the routine header 
()) begin all programs by generating a call to a routine named 
“enter” which will do all necessary system housekeeping, 
will pull arguments off my system command line into a con¬ 
struct like the ARGV, ARGC from UNIX (which I won’t 
describe here, but which is described in detail in the manual) 
and will call “main ( )”. When “main ()” returns, it will 
return control to the routine “exit” which will close all files 
left open before returning to my operating system. 

In time, I may not even return to the operating system. 
Consider a small UNIX-style shell (command line interpreter) 
which takes the place of the operating system (but which uses 
all the hooks available). With a powerful I/O library and the 
ablity to redirect stdin and stdout, it seems obvious that the 
notion of a micro-UNIX is not far fetched. 

Interested? Well, at the moment, you have all the tools 
available that I do: (1) A compiler, (2) a standard I/O library, 
and (3) an already existing operating system to use as an 
example. For starters, that ain’t half bad. 


LISTING 


;••••••«.............. 

1 

; Runtiae Library tor Saall C Ccspiler 

; 

? by Ron Cain 

i 

} 

; 

> 

;Petch a single byte froa the address in HL and 
i sign extend into HL 
ccgchar: MOV A/M 

;Put the accua into HL anc sign extena through H• 
CCSXt: MOV L/A 

RLC 

SBB A 

MOV H/A 

RET 

;Petch a full 16-bit integer froa the address in HL 
;lnto HL 

ccglnt: MOV A,M 

INX H 

MOV U/M 

MOV L/A 

RET 


jStore a single 
ccpchar: MOV 
STAX 
RET 

;Store a 16-bit 
ccplnt: MOV 
STAX 
IMX 
MOV 
STAX 
RET 

;Inclusive "or" 
ccor: MOV 

ORA 
MOV 
MOV 
ORA 
MOV 
RET 


byte froa HL at the address in 0E 
A/L 
0 

integer in HL at the address in CE 
A/L 
0 
0 

D 

HL and DE into HL 

A/L 

E 

L/A 

D 

H/A 


;Excluslve "or** 
ccxor: MOV 
XRA 
MOV 
MOV 
XRA 
MOV 
RET 


HL and DE into HL 

A/L 

E 

L/A 

A/H 

D 

H/A 


;"And" HL and DE into HL 
ccand: MOV A/L 

ANA E 

MOV L/A 


Page 8 

316 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 








11 the lollowlng coapare routines/ HL Is set to 1 12 the 
ltlon la true/ otherwise it is set to 0 (zero). 

if HL « DE 

CALL cccap 

RZ 

DCX H 

RET 

If DE 1= HL 
CALL cccap 

RNZ 

DCX H 

RET 

If DE > HL (signed) 

XCHC 

CALL cccap 

RC 

DCX H 

RET 

If DE <=* HL (signed) 

CALL cccap 

RZ 

RC 

DCX H 

RET 

If DE >= HL (signed) 

CALL cccap 

RNC 

DCX H 

RET 

If DE < HL (signed) 

CALL cccap 

RC 

OCX H 

RET 


; of DE and BL 

>Thls routine pertoras DE - HL and sets the conditions: 

) Carry reflects sign of difference (set aeans DE < HL) 

) Zero/non-zero set according to equality. 


;Subtract HL froa DE and return In HL 
ccsub: MOV A,E 

SUB L 

NOV L/A 

MOV A/D 

SBB H 

MOV H,A 

RET 

>Pora the tuo's coapleaent of HL 
ccneg: CALL cccoa 

INX H 

RET 

)Pora the one's coapleaent of HL 
cccoa: MOV A,H 

CMA 

MOV H,A 

MOV A,L 

CMA 

MOV L/A 

RET 

;Multlply DE by HL and return in HL 




H 

ccault: MOV 

E/H 


MOV 

C/L 

HL (signed) 

LXI 

h/C 

cccap 

ccaultl: MOV 

A/C 


RRC 



JNC 

cciult2 

H 

CAC 

C 


ccault2: XRA 

A 

HL (signed) 

MOV 

A/B 

cccap 

RAR 



MOV 

B/A 

H 

MOV 

A/C 


RAR 


iL (signed) 

MOV 

C/A 

cccap 

CRA 

B 


RZ 


H 

XRA 

A 


MOV 

A/E 


RA 


i to perfora a signed coapare 

MOV 

E/A 


MOV 

A,D 




*mmA 


MOV 

A/B 



SUB 

L 



MOV 

E/A 



MOV 

A/D 



SBB 

H 



LXI 

H/l 

/preset true 

condition 

JM 

cccapl 



ORA 

E 

2 "OR" resets 

carry 

RET 




ORA 

E 



STC 


;set carry to 

signal alnus 

RET 





;Test If DE >- HL (unsigned) 
ccuge: CALL ccucap 

RNC 

DCX H 

RET 

; 

;Test If DE < HL (unsigned) 
ccult: CALL ccucap 

RC 

DCX H 

RET 

; 

;Test if DE > HL (unsigned) 
ccugt: XCHC 

CALL ccucap 

RC 

DCX H 

RET 

; 

;Test if DE <= HL (unsigned) 
ccule: CALL ccucap 

RZ 
RC 

DCX K 

RET 

; 

;Coaaon routine to perfore unsigned cocpare 
;carry set 11 DE < HL 
;zero/nonzero set accordingly 


ccrdel 
ccclv2 
cccapbcde 
ccdlv2 
A/L 
1 

L/A 

A/E 

C 

E/A 

A/D 


ccucap: MOV 
CMP 
JNZ 
MOV 
CMP 

ccucapl: LX1 
RET 


A/0 

E 

ccucapl 

A/E 

L 

h/1 


;Shlft DE arithaetlcally right by HL and return in HL 
ccasr: XCHG 

MOV A/H 


MOV L/A 

OCR E 

JNZ ccasrei 

RET 

;Shift DE arithaetlcally left by HL ana return In HL 

ccasl: XCHG 

DAD H 

DCR E 

JNZ ccaslel 

RET 


;Divlde CE by bL and return quotient in HL/ reaalnder In CE 
;(slgned divide) 
ccdlv: MOV E/H 

NOV C,L 

MOV A/0 

XRA fa 

PUSH PSfa 

MOV A/D 

ORA A 

CM ccdeneg 

MOV A/B 

CRA A 

CM ccbcneg 

MVI A/16 

PUSH PSfa 

XCHG 

LXI C/C 

ccdivl: DAD H 

CALL ccrdel 

JZ ccolv2 

CALL cccapbcde 

JM ccdiv2 

MOV A/L 

OR 1 1 

MOV L/A 

MOV A/E 

SUB C 

MOV E/A 

MOV A/D 

SBB B 

MOV D/A 

ccdlv2: POP PS fa 

DCR A 

JZ ccdlv3 

PUSH PSfa 

JMP ccdivl 

ccdlv3: POP PSfa 

RP 

CALL ccdeneq 

XCHG 

CALL ccdeneg 

XCHG 

RET 

;Negate the Integer in DE 
;(internal routine) 
ccdeneg: MOV A/C 

CMA 

MOV D/A 

MOV A/E 

CMA 

MOV E/A 

INX D 

RET 

;Negate the integer in PC 
;(internal routine) 
ccbcneg: MOV A/B 

CMA 

MOV fa/A 

MOV A/C 

CMA 

MOV C/A 

INX B 

RET 

>Rotate DE left one bit 
)(internal routine) 
ccrdel: MOV A/E 

RAL 

MOV E/A 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

317 



MOV 

A/C 

RAL 


MOV 

D/A 

ORA 

E 

RET 


/Coapare BC to 

DE 

/(internal routine) 

cccapbcde: MGV 

A/E 

SUB 

C 

MOV 

A/D 

SBB 

E 

RET 



/ 

;I/0 subroutines 

; 

;lnput a character into HL 
getchar: CALL *H0 ;Get one 

JMP ccsxt /Sign extend 

; 

/Output a character (putchar(char)) 
putchar: LXI h/2 

DAD SP /index past return 

POV A/P ;get char 

CALL AH1 

JMP ccsxt 

/ 

;Test for a character(return in HL if tound/but con't dequeue) 
CHRDY: LHLO KB1G 

LDA KBIP 

SUB L 

JZ chrhyi 

PGV A,P 

CHRDYl: JPP ccsxt 

? 

;Disle file I/O 

; 

FDENUP EQU 4 /Number files supportec at once 

FDESIZE tQU 310 /Number tytes required tor each file 

) 

/Offsets into unit tables 

FDISKADD EQU 45 

FSECTCNT EQU 4? 

FBYTEOFF F.QU 49 

FBUFF EQU 50 

; 

;Open a tile 

;Call: F OPFN(oirection/un it/size/naaeptr) 

; direction = 1 to read/ 2 to urite 

; unit = 1/ i, 3/ ...(# units avail) 

; size = iax size (ignored) 

; naseptr = addr of asciz filenaae 

;Returns: 0=good opwi/ -l = open failure 

; 

FOPEN: LX l h/2 

LAD SP ;ptr to arg list 

LX 1 C/FOPARGS 

PVI C/8 

FOP1: POV A,P 

STAX C 

1 NX h 

1 NX C 

OCR C 

JNZ F0P1 /transfer args to usable area 

CALL FOPFDE ;gtt unit's tlock 

JC FOPERR 

MOV A/M ; icle? 

GRA A 

JNZ FOPERR 

XR A A 

STA NFL IR /force directory load 

LHLD FILERAMF 

XCHG 

LXI H/FF1LE 

M VI C/CFFH 

FOPENl: LDAX C /Get fllenate 

MOV P/A 

INX h 

I NX D 

IN R C 

GRA A 


JNZ 

FOPENl 


MOV 

A/C 


ORA 

A 


JZ 

FOPERR 

/Null 

DCX 

H 


MV1 

M/ODH 

/append <CR> 

LHLD 

FDE 


INX 

H 


XCHG 


/DE = FDE addr 

LXI 

H/FFILE 


LXI 

B/ *T X ' 


MV I 

A/ 60 H 


CALL 

Qvrto 


DB 

•Gfid* 


PUSH 

PSb 


LDA 

PTYPE 


DCR 

A 



JNZ FOPNRITE 


LXI B/FDESIZfc 

MV I A/(FUENUM AND OFFH) 

FOPNRTl: PUSH PSh 

POV A/P 

CPI 2 

JNZ FOPWRT2 

INX H 

MOV A/P 

DCX H 

ANI 3 

CMP D /any other writes on this drive? 


JNZ 

PQPNRT2 

INN 

E 

FOPWRT2: DAD 

B 

POP 

PSh 

DCR 

A 

JNZ 

FOPNRT1 

MOV 

A/E 

ORA 

A 

JNZ 

/File looks ok 

FOPERR /yes...fail 

FQPOK: LHLD 

FDE 

INX 

H 

INX 

h 

POV 

A/P 

1NR 

A 

INR 

A 

1NR 

A 

ANI 

01FH 

MOV 

C/A 

MVI 

B/0 

DAD 

E 

XCHG 

;Ct = 0FDA 

LHLD 

FDE 

LXI 

B/FDISKADD 

DAD 

B 

MVI 

C/4 

FOPOKl: LDAX 

D 

MOV 

M/A /copy FDA A DN! 

INX 

H 

INX 

C 

DCR 

C 

JNZ 

FOPOKl 

XR A 

A 

POV 

P/A /clear byte of: 

FOPQK2: INX 

H 

PVI 

P/0 

LCR 

A 

JNZ 

FOPOK2 /clear butter 

LHLD 

FDE 

LXI 

B/FDISK ADC 

DAD 

B 

MOV 

E/P 

INX 

H 

MOV 

XCHG 

D/P 

LXI 

0/350 

MOV 

A/H 

CMP 

D 

JNZ 

F0P0K3 

MOV 

A/L 

CMP 

E 

POPOK3: JNC 

FOPERR /At end of dls! 

LHLD 

FDE 

LDA 

FTVPE 

MOV 

M/A /declare open 

LXI 

RET 

H,C 

FOPERR: LXI 

RET 

H/-I /open error 

/ 

/Find the unit 

block for unit in FUNIT 

/carry set on 

error 

FOPFDE: LDA 

FUNIT 

MVI 

8/(FDENDM AND OFFH) 

LXI 

C/PDESIZE 

LXI 

H/FDEBUFF 

FOPFDE1: DCR 

A 

JZ 

FOPFDE2 

0 AD 

C 

DCR 

B 

JNZ 

FOPFDE1 

STC 

RET 

/error 


FOPFDE2: SHLD FDE 


STC 

CMC 

RET 

; 

/Close a file 
/Call: FCLGSE(unit) 

/no returned value 
rCLOSE: LXI H/2 

DAD SP 

MOV A/M /get unit 

STA FUNIT 

CALL FOPFDE 

RC 



Page 10 

318 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



CALL 

JNC 

* LXI 
DAO 
MOV 
IN X 
MOV 
DCX 
MOV 
ORA 
STC 
CMC 
RZ 

PUSH 

LHLD 

INX 

INX 

MOV 

INR 

INR 

INR 

ANI 

MOV 

M V1 

CAD 

INX 

INX 

POP 

MOV 

INX 

MOV 

LHLC 

INX 

MVI 

CALL 

DB 

RET 

froir a 


FHRTB ;eapty systen buffer 
FCLSUT 
LHLD FDE 
B/FSECTCNT 
B 

E/M 
H 

C/M 
fa 

*/E 

C 


C 

FDE 

H 

H 

A/M 

A 

A 

A 

01FH 

C/A 

b/0 

B 

fa 

fa 

c 

M/E 

fa 

P/C 

FDE 

H 

A/1 

Cvrto 

'Gfid' 


;nothing written 
;dns 


;put in FDE 


jRead 
;caii: freadob 

; .oenaadr 

; fcytes = 

/Returns: -1 = 

; else 

/ 


FREAD: 


/Main 

PREAD1 


(ie C = 
CALL 
LXI 
SHLD 
CALL 
JC 
MOV 
OCR 
JNZ 

read lcop 
LHLC 
MOV 
CRA 
JZ 
MOV 
ORA 
JNZ 

;less than 256 


;Mor e 
FREAD3 


file 

emaodt/oyteS/unit) \ 

= beginning addr of user butter 
positive nunter cf bytes to read 
error in read 

returns nuater of bytes successful 
end of file) 



FDE 

B/FDISKADC 

B 

A/E 

M 

M/A 

H 

A,C 


M/A 

H 

A,M 

E 

M/A 

H 

A/M 

C 

M/A 

FMEM 

B/E 

C,C 

B 

FMEM 

FXFER 

e 

FXFER 

A,B 


e,» 

a,c jSmwK. 


;tunp ahead disk addr 


;count off # sectors 

/Bake n bytes 
;tump ahead net addr 

V bytes read 


i-t? 

FCNT '/ 




FCNT /count down A bytes 
FREAD1 ;loop 


;Read a single byte into user's aenory 
)carry set if error 


F X ARCS 

h /0 

FXFER 

FOPFuE 

FXFERR 

A/M 

A 

FXFERR 

FCNT 

A/H 

L 

FXCK 

A/h 

A 

FREAD3 


■ / l-C-.. v 


FREADB: LHLD 
LXI 
DAD 
MOV 
ORA 
JNZ 


FDE 

B/FBYTEOFF 

B 

A/M 

A 

FHCBYT 


;nothing in system buffer 


;preset xter cnt 


; done 


CALL 

FREADP 

;read a byte 

JC 

FXFERR 


JMP 

FREAD1 

;ar.d loop till done 

than 256 

leans we 

go direct to user nevory 

1: LHLD 

FDE 


LXI 

B/FBYTtOFF 

DAD 

B 


MOV 

A/M 


CRA 

A 


JZ 

FREAC5 


CALL 

FREADB 

;ye have some in systes cuff first 

JC 

FXFERR 


JMP 

FR EADI 


LHLD 

FDE 


LXI 

B/FSECTCNT 

DAD 

B 


MQV 

E/M 


INX 

1! 


MOV 

C/M 

;0E = g sectors left 

LOA 

F CNT *1 

;get »sb A bytes 

MVI 

h/0 

;HL = A sectors requesteo 

MOV 

A/h 


CMP 

D 


JNZ 

FREAD6 


MOV 

A/L 


CMP 

E 


>: JC 

FREAD7 


XCHG 


;user wants too nany 

MOV 

A,H 


CRA 

L 


JZ 

FXQK 

;if zero*..done 

PUSH 

H 

;save A to read 

MOV 

A/L 

/(A < 256) 

PUSH 

PSh 


LHLD 

FDE 


INX 

H 


MOV 

A/M 


ANI 

3 


MUV 

C/A 

;unit 

MVI 

B/l 

;read end 

LXI 

D/FD1SKADD-1 

CAD 

D 


MOV 

E/M 


INX 

H 


MOV 

D/M 

;CE = disk addr 

LHLD 

XCHG 

FMEM 

/HL = mem addr 

POP 

FSb 


CALL 

Dio 

; read 

POP 

B 

/A attempted 

JC 

read 

FXFERR 


XCHG 


;DE = # sectors read 

CO 

s 


Dr. Dobb's Journal of Computer Calisthenics 


DCX 

H 


MOV 

A/M 


DCX 

H 


ORA 

M 

/ an; 

JZ 

FRDBX 

; no 

DCX 

fa 


MOV 

C/M 


DCX 

fa 


MQV 

E/M 

;DE 

PUSH 

C 


LHLD 

FDE 


INX 

fa 


MOV 

A/M 


ANI 

3 


MOV 

C/A 

;un 

MVI 

B/l 

; r e 

LXI 

C/FRUFF 

-1 

DAD 

XCHG 

C 

/ in 

PUP 

h 


MVI 

A/l 

; i 

CALL 

Cio 


RC 


;er 

LHLC 

FDE 


LXI 

B/FD iSKADC 

DAD 

E 


INR 

M 


INX 

h 


JNZ 

FPCB< 


INR 

F 

;bu 

INX 

H 


MOV 

A/M 


ORA 

A 


JNZ 

FRC9 J 


CCR 

M 

;ce 

INX 

fa 


DCR 

M 


XRA 

A 



;buirp disk addr 


cecrement sector court 


;accufl< = offset to next byte 
FDE 

B/FBLFF 


LHLC 

LXI 

DAD 

MOV 

MVI 

DAD 

MOV 

LHLD 

MOV 

INX 

SHLC 

LHLD 

INX 

SHLD 

LHLD 

DCX 

SHLD 

LHLD 

LXI 

DAD 

INR 

STC 

CMC 

RET 


C/A 
B/0 
B 

A/M 
FMEM 
M/A 

H 

FMEM 

FXFF.K 

fa 

FXFER 

FCNT 

h 

FCnT 

FDE 

B/FBVTEPFF 

B 


;get byte 

;put in user memory 


;fcunp offset (C aeans empty) 


;Read/w 

rite okay 


FXOK: 

LHLD FXFER 

;get A bytes 


REI 


FXFERR: 

LXI C/-1 

;ecror exit 


RET 




; 


/Transfer the 

arguments 

from the stack 

FXARCS: LXI 

H/4 


DAD 

SP 


LXI 

D/FXALIST 

MVI 

C/6 


FIALP: MOV 

X/N 


STAX 

D 


INX 

H 


INX 

C 


DCR 

C 


JNZ 

FX ALP 


RET 

; 



; 

;Mrlte to a rile 
/Call: FnRITE( memadar/l 

tytes/unit) , . 

; (see FREAD 
; 

for explanation. ..they are same) 

ransfiff 

FNHITl: CALL 

FXARGS 


LXI 

SHLD 

H/0 

FXFEP 


CALL 

foppnr 

JC 

FtfFEFP 


NOV 

A/N 


CPI 

2 


JNZ 

F XFFRR 


/Main writing 

loop 

.V jf»». . 

FMRITEl: 

LHLD 

'«« i? WP 

MOV 

A/H 

CRA 

L 


JZ 

FXGK 

/cone 

MOV 

A/H 


ORA 

A 


JNZ 

FNRITE3 


/less than 25 

6 


FNRITE2: 

CALL 

FNRTB /write a byte 

JC 

FXPERP 


JMP 

FWRITE1 


/more than 25 

6 means it 

goes direct to user 

FMRITE 3: 

LHLD 

FDE 

LXI 

B/PBYTEOFF 

CAD 

e 


NOV 

A/M 


JNZ 

FWRITE2 

/empty internal buffer first 

LHLD 

FDE 


LXI 

B/FDISKAOD 

DAD 

d 


NOV 

E/M 


INX 

H 


MOV 

D/M 


MOV 

A/E 


CMA 



MOV 

E/X 


MOV 

X/C 


CMA 



MOV 

D/X 


INX 

D 

/-FDA 

LXI 

Hz 349 


DAD 

XCHG 

C 

/349-PDA = X sectors till end 

LDA 

FCNTM 


MOV 

L/X 


MVI 

H/0 

/make HL = # requested 

MOV 

A/H 


CMP 

D 


JNZ 

fWRITE4 


MOV 

X/L 


CMP 

E 


FMRITE4: 

JC 

FNFITE5 

XCHG 


/can't do this many 

FWRITE5: 

MOV 

A/H 

ORA 

L 


JZ 

FXUK 

/no room at all 

PUSH 

H 


MOV 

X/L 


PUSH 

PSN 


LHLD 

FDE 


INX 

H 


MOV 

X/M 


ANI 

3 


MOV 

C/X 

/unit 

MVI 

B/0 

/write cmd 

LXI 

C/FD ISK ADC-1 

DAD 

MOV 

D 

E/M 

rar 

INX 

MOV 

H 

0/M 

LHLD 

FNEM 

XCHG 

POP 

CALL 

POP 

JC 

PSm 

Clo 

C 

FXFERP 

/good write 


LHLD 

FDE 

LXI 

B/FD ISKADD 

DAD 

B 


MOV 

A/E 


ADD 

M 


MOV 

M/A 


INX 

H 


MOV 

A/D 


ADC 

M 


MOV 

P/X 


INX 

H 


MOV 

X/E 


AUD 

M 


MOV 

N/X 


INX 

H 


MOV 

X/C 


ADC 

M 


MOV 

N/X 


LHLD 

FNEM 


MOV 

B/E 


MVI 

C/0 

/make fi bytes 

DAD 

6 



SHLC F HfcM 

LHLC FXFF.R 

CAC B 

SHLD FXFER 

► Q V A/t 

C W A 

►UV B/A 

nuv A/ c 

CMA 

MOV C/A 

1 NX H 

LHLO FCNT 

CAB e 

SHLD FCNT 

LHLC FDt 

LX I B/FDISKACO 

BAD b 

HCV £,#- 

1 NX h 

NOV C/M 

X CHC 

LX1 C/JSC 

NOV A/H 

CNP L 

JNZ FNRITF6 

NOV A/L 

CMP fc 

PNRITEto: JC FNRITE1 /still room on disk 

BMP PICK ;cisk full/ but no more/ please 

; 

/Write a single byte from user memory 
;carry set it error 
FWRTB: LHLD FOE 

LX1 E/FBYTECFP 

CAD B 

PUSH H 

MOV C/M 

I NX h 

MVI B/0 

DAD B ;lndex to place to put it 

XCHG 

LHLD F MEM 

MOV A,N 

STAX D /copy to system buffer 

IN X H 

SHLD FNEM 

LHLD FXFE(< 

1NX H 

SHLD PIFER 

LHLD FCNT 

OCX H 

SHLD FCNT 

POP H 

1 NR M ;bump oflset 

JZ FNRTBl ;opps/ filled buffer 

PWRTBX: STC 
CMC 
RET 

;Need to write system butter to oisk 
FNRTBl: 1 NX H 

PUSH H ;Rbuff 

LHLC FOE 

1 NX h 

MOV A/M 

ANI 3 

MOV C/A ;unlt 

MVI B,0 ;write c«a 

LX1 D/FD1SKADC-1 

0 AO 0 

MOV A,N 

INX H 

MOV H/M 

MOV L/A /get the disk addr 

POP D ;DE = mem addr/ HL = disk addr 

MVI A/1 

CALL Dio 

RC ;error 

LHLC FOE 

LX 1 B/FD1SKAU0 

DAO B 

I NR M ;bump ND A 

INX H 

JNZ FMRTE3 

INF N 

FNRTB3: INX H 

INR M /A TINS 

INX h 

JNZ FNRTB4 

INR M 

FWRTB4: INX H 

INX H ;HL = § buff 

XRA A 

FNRTB5: MVI M/C 

INX H 

INR A 

JNZ FMRTR5 ;clear buffer after every write 

LHLD FDE 

LX I B/FDISKADC 

0 AD B 

NOV E/M 

INX h 

NOV D/M 

XCHG 

LXI C/350 

Mil V A/H 

CMP C 

JNZ *«RTfc6 

NOV A/L 

CMP t 

FNRTB6: JC FMRTcX ;still room 

LXI H/C 

SHLD FCNT /tull...ro more can be done 

LHLC FDE 

LXI B/FBYTLOFF 

DAD B 

h vI M/C ;and declare butter empty 


Page 12 

320 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



?File I/C storage area 
;Followlng are the argurents 
PQPARGS: 


FILENAME: DS 2 
FNUHd: OS 2 

fxalist: 

FUNIT: OS 2 

FCNT: 

FTYPE: DS 2 

FHEN*. os 2 

jStart ol local storage 
FDE: DS 2 

FXFERS DS 2 

ffile: ds 40 

fzero: OS 1 

; 

;Unit block foraats: 

; *0 = type of op 

; *1 = Poly FDE b 

; *45 = FDA (also 

; »47 = DNS sector 

; +49 = offset to 

; ♦50 = internal b 

fdebuff: cs 


;Addr file nane 
;Size on open (unused) 


direction of transfer 
;Current rerory address 

;Acdr of current unit block 
;ft bytes done 
;fllenaae buffer 
;known null wcrd tor closing 


type of open (0 = tree/ 1 = reac, 2 = write) 

Poly FDE block (aax 44 bytes) 

FDA (also NDA) next disk addr fcr xfer 
DNS sector count (reads decreaerts/ write inc's) 
offset to next byte in Internal fcuifer 
internal buffer (256 bytes) 

CS FEESIZE • FDENUN 


DS 10 ;tudge factor 

) 

/Following are scae routires written in C to provide a UNIX coapatible 
/front-eno tor the already existing I/O routines. 

; 

;saall-c coapiler rev 1.0 

;/• •/ 

;/* Patch to poly I/U routines •/ 

;/• */ 

;fdeflne NULL 0 
;fdefine eol 13 
;fopen(snaae/aode) 
fopen: 




y-.-V 


v:?' 


char *snaae/*aode; 
int xferaoae/unit; 

PUSH b 
PUSH B 

11(*iodi*='v')xferaode=2; 

LXI H/6 

DAD SP 

CALL ccgint 

CALL ccgchar 

PUSH H 

LXI H/115 

POP D 

CALL cceg 

MOV A/h 

ORA L 

JZ CClOOOl 
LXI H,2 
DAD SP 
PUSH H 
LXI H/2 
POP C 

CALL ccpint 

else xferacde=l; 
JMP cc10002 

LXI h/2 
DAD SP 
PUSH H 
LXI H/l 
POP D 

CALL ccpint 


unit=0; 

LXI h,D 
DAD SP 
PUSH H 
LXI H/0 
POP 0 

CALL ccpint 
while(unit<4) 

LXI h/0 
DAD SP 
CALL ccgint 
PUSH H 
LXI H/4 
POP C 
CALL celt 
NOV A,H 
ORA L 

JZ ccl0004 . v 

if (FLFtN(xferaode/^urit/-l/snaiie) = = 0) 

LXi H/2 
DAD SP 
CALL ccgint 
PUSH H 
LXI H/2 
DAD SP 
PUSH H 
CALL ccgint 
1 NX h 
POP C 

CALL ccpint 
PUSH H 
LXI H/l 
CALL ccneg 
PUSH H 
LXI h/14 
DAD SP 
CALL ccgint 
PUSH H 
CALL FOPEN 
XCHG 
LXI H/o 
DAO SP 


SPHL 
XCHG 
PUSH H 
LXI H/0 
POP C 
CALL cceq 
MOV A,H 
OR A L 

JZ CC10005 

; return unit; 

LXI H/0 
DAD SP 
CALL ccgint 
POP B 
POP B 
RET 

; return NULL; 

CC10005: 

jmp ccioooa 

cciooo4: 

LXI H,0 
POP B 
POP B 
RET 

; > 

;fclose(unit) 
fclose: 

; int unit; 

>C return FCLOSE(unit); 

LXI H/2 
DAD SP 
CALL ccgint 
PUSH H 
CALL FCLCSE 
POP B 
RET 

>> 

;getc(unit) 

gate: 

; int unit; 

;( char buttCll/int flag; 

OCX SP 
PUSH B 

; tlag=FREAD(buff/l/unit); 

LXI h,0 
DAD SP 
PUSH H 
LXI H,4 
DAD SP 
PUSH H 
LXI H,1 
PUSH H 
LXI H,11 
DAD SP 
CALL ccgint 
PUSH H 
CALL FREAD 
POP B 
POP B 
POP b 
POP C 

CALL ccpint 

; 11 ((tlag = = C)|(tlag = =-l))return -1; 

LXI H/0 
DAD SP 
CALL ccgint 
PUSh H 
LXI H/0 
POP c 
CALL cceq 
PUSH H 
LAI H,2 
DAD SP 
CALL ccgint 
PUSh H 
LXI H/l 
CALL ccneg 
PLP C 
CALL cceq 
POP D 
CALL ccor 
MOV A/H 
ORA L 

JZ ccl0006 
LXI H/l 
CALL ccneg 
I NX SP 
POP B 
RET 

; return(buffC0]L255); 

cclOOOb: 

LXI H/2 
DAD SP 
PUSH H 
LXI H/0 
PUP C 
DAO 0 

CALL ccgchar 
PUSH H 
LXI H/255 
POP C 

CALL ccand 
I NX SP 
PUP B 
RET 

; ) 

;putc(c/unit) 
putc: 

; char c;int unit; 

;( char buffC13;int flag; 

DCX SP 
PUSH B 

; buffC03=c; 

LXI b/2 
DAD SP 
PUSH H 
LXI H,0 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 13 

321 



PGP D 
DAO C 
PUSH H 
LXI h/9 
LAD SP 

CALL ccgchar 
POP D 

CALL ccpchar 

flag=P»RITE(buff/1/unit); 

LXI h/Q 
CAD SP 
PUSH H 
LXI H/4 
DAD SP 
PUSH H 
LXI H/1 
PUSH H 
LXI H/ 11 
DAD SP 
CALL ccgint 
PUSH H 
CALL FtaRITE 
PGP c 
POP E 
PUP E 
PGP C 

CALL ccplnt 

if((flag==C)l(flag==-l>>return 

LXI H/0 

DAD SP 

CALL ccgint 

PUSH H 

uXl h/0 

PGP C 

CALL cceg 

PUSH H 

LXI h t i. 

DAD SP 
CALL ccgint 
PUSH K 
LXI h/1 
CALL ccneg 
POP D 
CALL cceq 
PGP C 
CALL ccor 
MOV A/H 
CRA L 

JZ ccl0007 
LXI h/1 
CALL ccneg 
IN X SP 
POP fc 
RET 

else return(c&255); 
jmp ccioooe 


LXI h/7 
LAD SP 

CALL ccgchar 
PUSH H 
LXI H/^5S 
POP L 

CALL ccand 
I NX SP 
POP k 
PET 









> 


cclOOOB: 

; 

1 NX SP 
POP h 
hET 

;gets(butt ) 
gets: 


chat buttC); 



PUSH H 
LXI h/24 
POP C 
CALL cceg 
NOW A/H 
CRA L 

JZ cclOOll 
LXI H/0 
DAD SP 
PUSH H 
LXI H,0 
POP C 

CALL ccpint 
LXI h,24 
PUSH H 
CALL putchar 
POP B 

else 

JMP ccl0012 

LXI H/4 
DAD SP 
CALL ccgint 
PUSH H 
LXI H/ /. 

DAD SP 
CALL ccgint 
FOP C 
CAD C 

CALL ccgchar 
PUSH K 
LXI b,121 
POP C 
CALL cceg 
NOW A/H 
OKA L 

JZ ccl0013 

LXI E/0 
DAD SP 
CALL ccgint 
PUSH H 
LXI H,0 
PUP L 
CALL ccgt 
MOV A/H 
Ch A L 

JZ ccl0014 

LXI P/O 
DAD SP 
PUSH H 
LXI H/ 2 
DAD SP 
CALL ccgint 
PUSH F 
LXI H,1 
FOP C 

CALL ccsth 
PGP C 

CALL ccgint 

LXI H,127 
PUSH H 

CALL putchar 
PGP b 


cclOOlA: 


mm 


cclOOl3: 

; 


else 
JMP cclOC15 


int <; 

PUSH 3 

* = 0 ; 

LXI r/0 
CAD SP 
PUSH H 
LXI h,0 
POP C 

CALL ccpint 

while((biflCPl=getchar())!=eol) 

LXI h/4 
LAC SP 
CALL ccgint 
PUSH H 
LXI h/ 2 
CAD SP 
CALL ccgint 
POP C 
DAD D 
PUSh H 

CALL getchar 
POP C 

CALL ccpchar 
PUSh H 
LXI H/13 
FOP C 
CALL ccne 
MOV A/b 
ORA L 

JZ ccl0010 
( 

it(buffCk3--24)(k-0;putchar(24);) 

LXI h/4 
DAD SP 
CALL ccgint 
PUSH H 
LXI b/2 
DAD SP 
CALL ccgint 
POP C 
DAD C 

CALL ccgchar 


LXI H/4 
CAD SP 
CALL ccgint 
PUSH H 
LXI H/2 
0 AD SP 
CALL ccgint 
FOP C 
CAD C 

CALL ccgchar 
PUSH H 

CALL putchar 
POP B 

LXI h/U 
CAD SP 
PUSH H 
LXI H/2 
DAD SP 
CALL ccgint 
PUSH H 
LXI h,l 
POP C 
CAD C 
PGP C 

CALL ccpint 


cc10015: 
ccl0012: 


JPF ccICC09 

buffCkJ=C; 
LXI H/4 
DAC SP 
CALL ccgint 
PUSh H 
LXI H/2 
CAD SP 
CALL ccgint 
PUP C 
DAD 0 
POSH H 
LXI h/0 
POP C 


if(buffCkJ==127) 


( iX(k >0 ) 


(K=k-1; 


putchar(127); 


) 


) 


( 

putchar(tut fck 1); 


k = k*l; 


Page 14 

322 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



CALL ccpchar 
putchar(eol); 
LXI h/13 
PUSH H 
CALL putchar 
POP E 

return buff; 
LXI H/4 
DAD SP 
CALL ccgint 
POP E 
PET 


;0 errors in compilation. 
; >>>>> end of run 


& 

.vr-. AH-; A 


>>>>> er.d of runtime library <<<« 


ENDING 






F 


fi.tigi 

fi£. 

•svi' .J rs-C/‘. if5^i 


Wif^j4>V%4 


®8SSI@ 


Jffel 

ar 


rawsftir 

mm* 


M. 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 15 

323 



^ Thoughts on Small Systems and Monitors 


(mostly the SYM-l) 



BY H. T. GORDON 
College of Natural Resources 
University of California 
Berkeley CA 94720 

I define a “small” system as one that is 
owned and used by only one person. 
This still allows more than a ten-fold 
range in cost and complexity, but the 
common ground is the man/machine 
interaction that can be (for the human 
being) a profound educational experience. 
My first system was a KIM-1, the crea¬ 
tion of Don McLaughlin while he was at 
MOS Technology. This early SBC launch¬ 
ed the new 6502 (in the dim and distant 
past of 1976!) and, together with bril¬ 
liant descriptive manuals, played a major 
role in its popularization. It was—belat¬ 
edly— emulated by the makers of other 
microprocessors, and of course surpassed 
by more complex systems of the multi- 
board type. As a learning tool it still has 
few (perhaps no) equals. All of my 
previous communications, in DDJ and 
elsewhere, were worked out on my KIM. 

One of its invaluable assets is the com¬ 
plete and quite well-commented listing of 
the code of its 2K ROM monitor, a 
simple “operating system”, rich in 
information on how to program. Like 
other users I soon became aware that 
many of its routines were callable by 
new programs, although this had not been 
clearly foreseen by whoever wrote the 
monitor programs. By now, this ought 
to be recognized as one of the major 
functions of every monitor: to provide 
a “library” of efficiently-coded routines 
accessible to newly-created main pro¬ 
grams. In a ROM, the need to squeeze 
many operations into a limited space 
will often cause brevity of code to be 
given priority over maximum speed of 
execution. Also, subprograms will tend to 
be special-purpose instead of general- 


purpose. You can’t have everything! 

However, one service that ought to 
be included with the documentation of a 
monitor listing is a list of user-accessible 
subroutines, so that users need not waste 
time searching them out. Such a list may 
be longer than the number of RTS in¬ 
structions in the monitor, since a sub¬ 
routine may have several useful entry 
points (including some undreamed of 
by the person who wrote it!) The use of 
more than one exit point, which can 
sometimes enhance both code efficiency 
and timing, is often stigmatized as “un¬ 
structured.” That’s a word I have come to 
dislike. Everything has structure. The 
distinction that matters is intelligibility , 
and this is not necessarily lost by using 
two (or even more) exit points. What 
must be avoided is excess of any kind, 
including excessive rigidity and com¬ 
plexity. 

The Upgrading/Customization Prob¬ 
lem. Everyone must sooner or later out¬ 
grow a system as confining as an SBC, 
and the question becomes: upgrade to 
what? More crucial still, for what? 
Perusing the articles and ads in micro¬ 
computer journals is bewildering. So 
many competing systems, add-on peri¬ 
pherals, interfaces, languages, complex 
softwares, and above all uses! I long 
deferred any upgrading decision, in the 
hope that major innovations would soon 
appear. My concept of my own needs 
gradually crystallized: a system that 
could sense, measure, analyze, and act on 
the outside in a way similar-but super¬ 
ior-to the way I do and so do my work 
for me. 

While “dedicated” microprocessors are 
already automating a variety of instru¬ 
ments, that’s not quite what I want. 
There’s a colossal wastage built in to the 
scientific (and doubtless also the busi¬ 
ness) world, caused by non-standardiza¬ 


tion, deliberate avoidance of modularity/ 
interchangeability, and planned obsoles¬ 
cence. 

Except at the leading edge, where 
state-of-the-art can only be had by 
custom design, “packaged” systems domi¬ 
nate scientific laboratories. Each has its 
built-in electronics, recorders, etc., so 
tied together that if one element obso- 
lesces, the whole thing must be thrown 
away, brushed-aluminum chassis and all. 
These genies simultaneously serve and 
enslave their users, who become button- 
pushers with no comprehension of or 
power to modify the mechanisms. 

The concept that has always appealed 
to me is more that of the “hi-fi” enthu¬ 
siasts, where a system consists of several 
interacting but independently-replaceable 
components, from many competing 
sources. True competition, however ab¬ 
horrent to industrial giants, makes pos¬ 
sible a maximum of progressive change 
at the minimum cost to society. This 
eccentric, unbundled-components point 
of view enabled me to resist the lure of 
the increasingly powerful packaged sys¬ 
tems that have entered the market in 
recent years. However flexible, they must 
be designed for some least-common-de- 
nominator purpose and tend to allocate 
large resources to things like BASIC 
interpreters (for me a turn-off). They 
are like low-cost smoothly-paved roads 
leading to where everyone else wants to 
go. 

My first upgrade was a Synertek SYM- 
1. It is even more flexible and I/O- 
oriented than the KIM. Even future- 
oriented, since major ICs are socketed 
and one hopes that upgrading from the 
6502 to the 6516 will be easy. The SYM 
is a masterwork, complex and not free 
from flaws, that encourages and even 
compels its user to explore unbeaten 
paths. It works best only for someone 
willing to make the effort to under- 


Page 16 

324 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



stand it. 

One thing the SYM can do is inter¬ 
face with a TTY or CRT terminal, via 
RS-232 at baud rates from 110 to 4800 
(well below the potential of a 6502 
CPU). It is obvious that a CRT—not a 
TTY—is the primary upgrading element 
of an expanded system. The Commodore 
PET built one in, while the Apple II, 
TRS-80, etc., built in only an ASCII 
keyboard and allow (really require) 
interfacing to a TV monitor. These sys¬ 
tems tend to have less than the 24 x 80 
character display of stand-alone CRT 
terminals, but to some extent compen¬ 
sate this by providing graphics, and 
sometimes color. Many of their limita¬ 
tions will soon be transcended (probably 
first by the Apple III). Conventional CRT 
terminals will soon face superior price/ 
performance competition, and their too- 
high price is already falling. I therefore 
decided to buy one, the Televideo 920-B, 
that seemed a fair value at its current 
near-$800 mail-order price. It lacks the 
graphics capability of the 920-C, but 
I don’t mind that since my mind is a 
symbol-oriented algebraic, not a geo¬ 
metric one. Of course, so-called “printer 
graphics” of the TTY type are possible. 
The 920-B is an “intelligent” terminal 
controlled by an Intel 8035 micro-pro¬ 
cessor, with a 32K ROM and sockets 
for 8 high-speed 2114 static RAMs 
(allowing storage of an “alternate” 24 x 
80 character page). Competitive pressure 
has now made all intelligent terminals 
so good that I have no idea whether the 
920-B is one of the “best,” but it is 
very satisfactory. I like its eleven “func¬ 
tion” keys, that send a 3-character mes¬ 
sage to the computer: 01-XX-OD, where 
XX ranges from 40 to 4A with the F 
keys alone, and from 60 to 6A if the shift 
key is also depressed, for a total of 22 
different commands. The user decides 
how the computer shall interpret them. 
It also has its own RS-232 interface to 
a printer, so that the user can print ex¬ 
actly what he sees on the screen. 

When I connected the 920-B to the 
SYM-1, the log-in command (S, J, 1, 
CR) from the STM’s onboard keyboard 
did not work. A study of the monitor 
listing led me to modify the vector in the 
monitor RAM at $A622 from its set 
value of $A7 to $71. This worked, prov¬ 
ing that having a listing—and being able 
to read it —is a good thing, and also that 
the redundancy of dual control has 
merit. 

The slowness of 4800-baud serial 
transmission (that seems to fill the screen 
at about 80 characters/second) is a shade 
annoying to a lover of speed. The 920-B 
can work at 9600 baud (very good 
for serial), but the SYM designers were 
not thinking in those terms. Although 
I’ve known the theory of communication 
from books, this first real-life encounter 


with it has been educational. One sym¬ 
pathizes with the problems ot the 
pioneers trying to drive messages through 
long transmission lines—losses, noise, 
errors and the like—and sees the why of 
parity and checksums. The SYM monitor 
recognizes the low probability of trans¬ 
mission errors by just ignoring parity. 
The 920-B doesn’t (unless the user so 
desires) since it might anytime get hooked 
to a telephone line! It could easily con¬ 
nect via a modem to a timeshared system 
such as MicroNet. 

Comments on the SYM monitor 
program. Like many other KIM-trained 
machine-code programmers, I am keenly 
aware of the beauty of both code¬ 
efficiency and time-efficiency. Also of 
higher virtues of clarity, simplicity, 
modularity, and generality. Hardly ever 
are all of these wholly compatible. 

The writers of the SYM monitor 
were required to pack as much power 
and versatility as possible into a 4K- 
byte space (in a socketed 2332 ROM). 
The coding gives priority to byte-saving 
devices, sacrificing timing. They had to 
complete the task quickly, at the cost of 
incomplete testing. Version 1.0 had an 
error in its KIM-format audio-cassette 
program, corrected in a new version 1.1 
ROM (that nonetheless had the log-in- 
to-CRT flaw mentioned above). Its 
high-speed audio-cassette interface 
worked (in my hands) only with Micro- 
sette or Data Sound data tape. 

The SYM monitor has a command 
language, similar in kind to that of KIM 
but far more complex, and designed to 
be easily user-expansible. I explored the 
possibility of re-interpreting the key¬ 
board-command keys of the KIM in my 
EDITHA program (DDJ #25; although 
there are only 4 keys, anything one 
may desire can be done by implementing 
key sequences. However, the SYM ex¬ 
pects to interact with an ASCII key¬ 
board, so that a very large number of 
single-key commands could be implemen¬ 
ted. Those that are recognized by the 
monitor in its command-entry mode are: 
B, C, D, E, F, G, LI, L2, LP, M, R, SI, 
S2, SD, SP, V, and W. Six of the 2- 
character commands (all but SD) deal 
with loading and storing of programs with 
audio cassette or paper tape. The others 
are useful in program-writing, viewing, 
running, and debugging (too esoteric 
to go into detail). A command is ac¬ 
knowledged by displaying it and printing 
a space. The monitor then shifts to a 
hex-digit entry mode, that can accept 
(and print) up to 3 sets of 4 hex digits, 
delimited by a comma (or hyphen), 
to serve as numerical parameters for the 
command. Pressing the CR (carriage 
return) key then causes execution if the 
command is valid, i.e., interpretable by 
the monitor. Only the M command is de¬ 
fined for all 4 parameter possibilities (0, 


1, 2, or 3). If an undefined number of 
parameters has been keyed-in, control 
shifts to an “unrecognized syntax” 
vector. An unrecognized command char¬ 
acter shifts control to a vector for that. 

The computer elite (and some not- 
so-elite) will naturally view a mere 
command language as an antiquated 
anachronism, when so many wondrous 
high-level languages exist! I do some 
reading in the HLL domain but see 
nothing irresistably great there. A langu¬ 
age can imprison the mind. True, you 
can encode complex logic in symbols that 
may seem simple, and shift the arduous 
task of programming and antibugging 
machine code to an abler mind than your 
own. But errors are instructive, tutelage 
can dim vision, and few gains are not 
balanced by (often unseen) losses. 

A Preliminary Monitor-Enhancement 
Program. The “unrecognized command” 
mode is free-wheeling and congenial 
for machine-linguists. In its command- 
entry state, the SYM monitor is sent 
any ASCII character it will not recognize. 
It echoes this, and a space, then awaits 1, 

2, or 3 four-digit hex parameters (more 
could be had, but I prefer to limit com¬ 
plexity). I reserve the last one keyed 
in for the address of the program to be 
run. Therefore it is akin to the monitor’s 
own G (for GO) command, except that 
the user can provide parameters for the 
program to use. The unrecognized- 
command vector is reset to the address 
of a simple 23-byte interpreter (INPRET, 
cf. listings) that copies the second keyed- 
in parameter to zero-page to serve as 
an indirect address for program instruc¬ 
tions, then jumps-indirect to the last 
meter to shift control to the program, 
whose address is the real command. 
The program in the listings is moderately 
complex but not optimized (as much 
of my earlier work was). It is an exer¬ 
cise in interaction between the SYM-1 
and the 920-B, a sketch of something 
useful that may become even more so, 
perhaps even worth putting into an E- 
PROM. I was driven to write it because 
the SYM monitor expects to work with 
“dumb” peripherals (or even with only 
its own keyboard and hex display, in a 
quite ingenious way). There is no provi¬ 
sion for teamwork with an intelligent 
terminal, and its TTY-style programs for 
displaying, modifying, and moving 
memory are restrictive. 

My new programs implement only 
some of the possible intercommunication 
between the SYM and the 920-B. While 
this specific system may now be a unique 
one, it may arouse some interest in the 
teamwork concept, that is feasible for 
any SBC working with any intelligent 
terminal. The main program, DISPAG 
(at $0C00 in the listings), is implemented 
by the command sequence: T XYY, 

ZZZZ, COO CR (where CR is the Carriage- 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 

325 



return key). Any unrecognized character 
other than T works as well, since it will 
shift control to the vector preset in 
SA66D-E, that in the example is the 
address of INPRET ($0D00). ZZZZ is the 
starting address of the block of memory 
to be displayed, e.g., COO will display the 
program itself (note that leading zeroes 
need not be keyed in.) YY is the hex 
number of lines to be displayed, that 
must range from 1 to $18. Any other 
value will yield an error message and re¬ 
turn to monitor control. X controls the 
display format, and need not be keyed 
in if the “unispace” format is desired; 
any hex digit from 1 to F will command 
the “lister” format. This operation is 
controlled by subroutined LNFORM, 
that could be modified to allow other 
formats. 

The display will therefore be from 1 to 
24 lines of bytes (as hex-digit pairs) of 
memory. The first four (packed) hex 
digits are the address of the first byte in 
the line, separated by one space from the 
byte sequence . In the unispace format, 
each byte is followed by one space and 
each line has exactly 16 bytes. In the 
lister format, every opcode is preceded by 
an extra space, so that the instruction 
sequence is more legible. This is useful 
only for programs, and is meaningless for 
data tables. To avoid splitting one in¬ 
struction between two successive lines, 
the lister format allows up to 18 bytes on 
one line. It uses my old BYTCNT pro¬ 
gram, all-too-familiar to DDJ readers! 
Parenthetically, I note that one more 
6502 byte-count program, not very 
efficient, has been published (BYTE, May 
1980, p. 190). 

When all the lines are displayed, 
control shifts to the NEXCHR program. 
This frees the 920-B keyboard for any 
of its own programmed operations. To 
return to the SYM monitor, the CR key 
must be pressed twice in succession. 
In this mode the display can be edited in 
any way desired. Wholly new progams 
can be created on the CRT screen. 
NEXCHR merely echoes everything the 
920-B sends to it, a mode that persists 
unless a double-CR or a RUBOUT 
signal is received. This last is a bit 
dangerous, since it shifts control to a 
progam sequence (starting at LNREAD) 
that can wreck the SYM memory if used 
carelessly. Its purpose is to transfer a 
sequence of hex-bytes from the CRT 
screen (really the 920-B memory) to a 
specified region of the SYM memory. It 
uses most of the code in the listings, and 
was the trickiest to write. 

For the 920-B to SYM transfer to 
work correctly, the revised (or brand- 
new) program on the screen must obey 
the following restrictions: 

1. Each line must start with 4 characters, 
followed by a space. These will be read 
but not used in any way. The reason for 


this is to make it unnecessary to alter the 
address information that DISPAG has 
written, when an existing program is 
being revised (or just moved to another 
memory location.) It is an inconvenience 
when a new program is being constructed, 
unless the user wishes to keep track of 
addresses, but at this early stage I prefer 
not to augment the program complexity. 

2. The lowest program line must be 
followed by a completely blank line 
(unless it is at the very bottom of the 
screen display, in which case a blank line 
will be automatically created by the 
read operation). This is needed to termi¬ 
nate the transfer. 

3. The line just above the first program 
line must also start with 4 characters and 
a space (again read but not used), and 
then must have exactly 4 hex characters 
that specify the SYM RAM address to 
which the program is to be moved. 
E.g., 0200 will cause transfer to start at 
that location in the SYM RAM. The cursor 
must be to the right of that address on 
the screen when the RUBOUT key is 
pressed. Since the top line provides the 
only address information, this must be 
correct! 

It would be possible—perhaps desir¬ 
able—to include various anti-goof guards 
(such as a requirement that the RUBOUT 
key be pressed twice in succession to 
initiate the transfer) but only use-ex¬ 
perience can truly dictate how a program 
of this type ought to be refined. A few 
guards do exist. Either a non-hex char¬ 
acter or an incomplete hex byte (only 
one digit) will cause return to monitor 
control. 

The program lines need not be limited 
to 16 bytes, or be written in any parti¬ 
cular format, though the lister format 
is the most legible. When the transfer has 
been completed, control shifts to the 
VERIF program, that will use the DIS¬ 
PAG logic to display the revised or new 
program that is now in the SYM memory, 
and again shift to the NEXCHR mode. 
This allows further revision, and another 
transfer. This can be kept up until the 
user is satisfied that the program is ready 
to be tested. In my experience, it has 
proved desirable to test tricky logic in the 
form of subroutines, even when it will 
ultimately be coded in-line to optimize 
time-and code- efficiency. Debugging a 
complex in-line program can be dif¬ 
ficult! There are times when I wonder 
whether really adequate testing is even 
possible. And is a poorly-tested program 
really debugged? 

The Game of ROM-Creation. Even 
the minority of programmers who have 
read the ROMs created by someone 
else do not fully appreciate the problem 
until they toy with the idea of creating 
their own. It’s the chasm between critic 
an artist, or rather between a builder of 
sand-castles and a sculptor in marble. 


My coding would surely seem very 
sand-castly to the writer(s) of the SYM 
monitor, who make heavy use of the 
stack and hardly touch zero-page—while 
I haven’t even one overt stack-save, and 
transfer information freely via the on- 
chip registers, and use zero-page with 
wild abandon. The last is possible because 
the monitor graciously cedes zero-page 
to users, using instead its own half-page 
of RAM staring at $A600. The only 
zero-page locations it uses are the eight 

of RAM starting at $A600. The only 
zero-page locations it uses are the eight 
from F8-FF. Its stack usage is compel¬ 
led by a seemingly iron rule that regi¬ 
sters must be saved and restored by all 
subroutines, except when information is 
to be returned in the accumulator, the 
status register, or both. The 6502 in¬ 
struction set allows a 6-byte code se¬ 
quence for stack-saving (16 cycles) 
and for restoring (20 cycles) its four 
major registers PAXY. However, the 
SYM monitor frequently saves bytes 
by using a JSR SAVER (3 bytes but 103 
cycles!) as the first instruction of a sub¬ 
routine. SAVER is an intricate 48- 
byte program that rearranges the stack 
so that, when it has returned, PAXY is 
left on the stack. The subroutine that has 
used SAVER exits by a JMP to one of 
three entry-points of a program that will 
restore all registers (29 cycles), only 
AXY (41 cycles), or only XY (55 cycles) 
before its RTS termination. This allows 
three options with only six more bytes 
added to the subroutine, but the timing 
penalty is high (I think it’s why serial 
transmission can’t exceed 4800 baud.) 
The philosophic contrast shows in my 
62 bytes of code from $0D2F in the 
listings, that contain 13 different entry 
points to a single RTS (and 2 others, 
ESCOUT and TWOCHR, that are poten¬ 
tial entry points), averaging less than 
5 code bytes per subroutine. This econo¬ 
my is possible only because nothing 
is saved. Panegyrists of discipline might 
also frown on the anarchy of my sub¬ 
routine LNFORM, that uses the Y 
index for “parameter-passing” and PAX 
in a self-centered way. Its calls to the 
monitor subroutines OUTBYT and 
SPACE, on the other hand, involve no 
fewer than 28 stack save/restore in¬ 
structions, plus the musical-chairs stack 
manipulation of the monitor’s SAVER 
subroutine, for a total of 39 stack opera¬ 
tions! Since LNFORM only needs to pro¬ 
tect the X and Y registers from altera¬ 
tion by OUTBYT, OUTBYT does a lot 
of work to svae LNFORM the 8 bytes it 
would need to do it itself. The entire 
KIM-1 monitor has only ten stack pull/ 
push opcodes, but does more saving 
in zero-page—simpler but with the pos¬ 
sibility of conflict, that is of course a 
powerful argument for using the stack. 


Page 18 

326 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



One thing is for sure. ROMs tend to time—much like one of the human lan- to be workable.” This means that some- 

use a lot of subroutines. The KIM moni- guages—so there’ll be touches of awk- one must guess right the probability of 

tor has 115 JSRs, and it’s the dominant ardness if one shifts to a less familiar set future events! Wow! In the saying per 

opcode. The SYM monitor has 269 (or language), recognizable by a “native aspera ad astra, only the aspera are 

JSRs (in twice the ROM space). Knowers speaker.” There’s also the “personal certainties, 

of the 6502 will expect that the LDA style” factor, but some styles command 

will be a close second (as it is in the KIM admiration even though they differ A Brief Afterthought on FORTH, 
and probably in the SYM, that does not from one’s own. To me, FORTH has been the most tan- 

have a static analysis of opcode usage A ROM also has an “architecture,” as talizing of the existing HLLs. Perhaps the 
frequency). That is a powerful argument a CPU does, and this may be true of word is infuriating, since the FORTH 

for speeding up subroutine calls, as the any program (even my rough sketch enthsiasts—like the Rosicrucians or the 

lonely genius who designed the Signetics in the listings). The SYM ROM is basic- initiates to the ancient Eleusynian mys- 

2650 years ago foresaw. I have no idea ally a comm and-language interpreter, tery — won’t tell you what it is. In com- 

who he was (though I am sure the gender Having read the low-level “instruction,” parison, my own much more miniscule 

is right), but I hope the story of the it first branches to one of the four “legal” programs come with a surfeit of ex- 

2650 will someday be written, since fore- parameter-blocks (0, 1, 2, or 3 para- planatory comment (tinseled with allu- 

sight is to me the most miraculous of meters). Each of these checks the “legal” sions). When I glanced at a listing of 

all human qualities. I hardly need to command-characters and, if one is found, FORTH, its most striking quality was 

expatiate, for readers of DDJ, on the shifts control to the proper execution the virtual absence of comment. Adam 

virtues of subroutines: easy debugging, coding. If not, control shifts to the Osborne recently observed (InfoWorld 

easy rewriting, and above all availability “unrecognized-command” vector, that 2(8):7, 1980) that the success of an 

to any program. defaults to an error-message (very simple HLL depends less on its intrinsic merit 

Re-reading my main program (from and clever). This is something more than thn on hhow hard it’s pushed. Whatever 

$0C00 to 0C73), I see that I created a set of isolated routines filed so they the demerits of BASIC—and they are 

seven subroutines, without quite knowing can be retrieved by keying the right legion-being unexplained is not one 

why. All are used exactly once and could code, since the ensemble serves a com- of them. Dozens of books expound it 

have been coded in-line. Why not? mon purpose. Perhaps the only compo- in great detail, and some are brilliant. 

LNFORM CVHEX, and RNOSCP are nent of my new program that merits Where is the book that describes how 

complex enough so that the need for addition to a monitor is the old BYTCNT FORTH works, from the ground up, 

tailorability was perhaps subconsciously routine; all else is system-dependent, in a painstakingly detailed, translucent 

obvious. The others are moronic drud- I am reminded of a brief—but highly an vivid way? 
gery, and may just indicate something didactic —exposition of the principles of 

like battle-fatigue. It’s wrong to assume system design (chapters 1 and 3 in the 

that everything constructed by a frail book Systems Concepts, edited by R. F. 

human being is a gem of purest ray Miles, Wiley-Interscience, 1973). A “sys- 

serene! We get tired, we get fed-up, we tern” is defined as a large, complex, 

don’t feel like recalculating relative- man-made set of concepts and/or ele- 

branch offsets, so we do it the easy way. ments used to satisfy some human need. 

This kind of feeling must have pervaded All components are integrated to yield 

the SYM monitor-writer(s) near the end a set of optimum outputs from a set of 

of the task. Michelangelo too, when he given inputs (some of them random, 

put the finishing touches on the Sistine so that the exact performance at any 

Chapel, at an age not far from my own. instant is unpredictable). It works semi¬ 
in fact, the subroutine-library concept automatically: machines always perform 

that I lauded at the start of this com- some of the functions and human beings 

munication is elusive. Who knows what always perform other functions. The 

will be useful to many other workers? No design goal is to maximize “effectiveness” 

monitor has a bytecount routine, but for a given cost—that implies trade-offs, 

we now know it’s useful because so many I now shift from paraphrase to a key 

have been created. The SYM provides a quotation: “Because it is generally impos- 

block-move routine, that many KIM sible to find a single number which real- 

users had to write for themselves. How- istically represents the effectiveness of a 

ever, its byte-search program can only complex system, there is a good deal of 

find single bytes (my EDITHA program subjectiveness, as represented by judg- 

can also find sequences of two or three ment, as well as objectiveness, as repres- 

bytes). What length of byte-string is sented by analysis, in systems engineer- 

likely to be needed? ROM-design is ing.” The system is an entity such that 

bedeviled by dilemmas, and is analogous "... optimization of each subsystem 

to the design of the CPU itself, likewise independently will not lead in general to 

frozen in silicon. a system optimum, and . .. improvement 

One essential of ROM-design is mastery of a particular subsystem actually may 

of the CPU instruction set. The SYM worsen the overall system.” Food for 

monitor shows great skill in complex thought there! Less arguable is the con- 

assembler logic, and is usually very well cept that “no system can be all things 

coded, but there are spots where recod- to all people, all of the time” so that 

ing would save both bytes and time. “the fundamental mission of a system 

That kind of thing is rare in the work of should not be jeopardized, nor its funda- 

Jim Butterfield, who “thinks in 6502”, mental objectives significantly compro- 

so I assume that the SYM writer(s) learned mised, in order to accommodate events 

on a different kind of machine. One gets of extremely low probability” since that 

“conditioned” to a set one uses all the would make the system “too complex 

Number 48 Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 Page 19 

327 




sihSk coin pin u\ cm 
CMSOSPSSSS 


g 

© © "-^ 

• P P 
P • 3 
>» E E 
P 3 G " 
G O I 
so cd -i 
P a I 
G J 

>>P © 

3 O P - 
H Ml 
CLP P i 
B £JH i 
•H O i 
P O P i 

o 

o p g *» 

"I .: 

x Gs r 
o 

P 04 Oh 


• 


- — - 

-• 


T3 

p 

'—» 

• 

— Q 


T3 

>» 

^ © 

u 

© © 


O 

JO — 

c c 

cd 

rH P 



>» 

o o 

xi 

X> O 



P S-i 

•H -—- 

o 

X3 Cd 

• 

•H 

X t. 

pp-d 


•rH fL, 

Q 


• cd 

OK© 

M 

C cd 

4 

P 

C o 

3 © P 

M 

XI 

‘—Sl 

© 


fn d © 

O 

O o 

d o 

© 

p p 

P rH 

CO 

rH 

o 

P 

© © 

© * CL 

X 

K *H P 


bO © 

dso e 


» © 

© K 

O 


•H »H O 

p 

K X3 

U © 

P 

OHISl 

O 

© 

« 

© c 



3 p p * © 
•H d S C = 
3 © O 

i p E p 
) c © o p 
<P G G C 
" G O *H 

a © oh g = 
^"O-h a 


W . 

5 W CQ \A 

CM Cd O'O P O M 

6 £?G 2 Q & o»Q ofx X CO 

SHKfcKSHKH* *Eh 


^ 04 — Eh^-Eh 
O CO X CO >H 
S 

rH K |S CQ E-* CQ PH 

<8-P X N3 >H N] b 
=*fc CQ cO — CO — o 


MOM 

S CQ 

CQ 

o 

W ^ S5 

cd o 

o 

CQ 

Cd EH o 

O fH 

a 

CO 

3d 

CQ X 

£ 

M 

Eh 

S5 W 

X 

* 


P fc 

CO 



vO 

O CM 



X 

S co 

co CO 


s cq insets x 

mru cm 


rHp-SSf^-SCQ 

S_d-J- 


OS O' S 0 s O' S CT-SCO CO S 
oCQcmqcmoCQcm&MMvO 


CQ Q ^ Hr^lfNNO'CQP W CQ 
CO 


O P 3 > 

£ c a o 

Q. O P O 3 O 

©POO X 
PC,* 

P • o o 

P G P 

Cd © G O CL 

O > O p © 

P G G © O > 

—' O G— P o 

o © —' £ 


— *H C 
-OHO 
p 3 -h 

o p © o 

G P 

Oh *r» ® 

•H p > © © 
C p rH 
p p O %H 
© C O H JO 
© © P -H 

>*h « G 
- CXI • 
t>» O P P 

L o-o 

G 3 © 

Cd *«H o 

O -OH P 

P © C 

O O G -rH 

P — o 

C-> p © 
S-H > 

'-'X P O 


CQ CQ 


r- 

P * 

•rH CO 

O O 

+ H Cl 

o + 

_£) X + 

W Eh 

co as r 

H CO 

—' [i! cO 

£ X 

5 ° a 

C X 

£ < 

X W 

CQ cO - 

H P 

> CQ 

co as 

M X 3 

u N 

X ONI 


© o s c © 

rH X • 

3 JQO 

p o o d 
t, © d 
© g • • 


XX© 
•> •> © 

O'O'P 
+ + — 
CO CO 

X X 

CQ CQ 
X X N NJ 


X Cd CO XX X 

9 CO OCH w x 
^ CQ CO Q H 


CC0< J<C<t4Oc0 

CO OQ COCOCOcOCdEHXiactJE^ 

J cqp < < x < o co h cQ o cd 


O Q 

O £ Op o 

d Q 

X >>rH 3 p d d 

cd 

Q — a © © 

©4 O 

p q e q 

•H 

© cd « -n 

—' Q 

© o X X X Q '— 

rd 

— ~ o 

© 

p nj _ 3 fM d 

X rH 

© + + + H 04 

M o 

M n co p P — h 

tr: —' 

CQ^- XXX P 

> 

-€0- P P P p 

o 

=*h N N N p 

M o co 

X O X O X X H 

as P E-< 

QMQPhZS 

P o cd 

PP P P P M P 


f\J Q SPSPS XSSSCO SXSSS 
XX»0QC\JCQC\jOQ(\JC\JOOCOQa'vO 

scMinr^O'OMPCMJ-^X 'QQM'Si^ 

o- xxxxxxxxcoco 

C5 


r- iaian 

S f^PS 

\A x 

CQ CM CQ O O CO 


H-\ IACO X o Q 
CQ 
o 
s 


O' O' IA 

SS P4 


M CM_=J-CM 

CQ SSS [Q 


X Sin x X X X IAIA X Si. CO S 
J-CQCQSISiSSpCACOQPnO 


W £Q P rApflAvO f-^CQ O H &< 
CQ u 


CM CO UNUMACO Sl S 

xnffl fcO'MQvO 


SCM rAlAC^-O' X O 
P 
o 
S 







© 

© 


W 

r-v 

G 

G 















G 

> 


^ w 

T3 

© 

3 

© 




,—^ 




___ ,-v 

• 





33 

o © 

-—* 

£ © 

C 

04 

O 

P 




n 


,,_^ 


— S 

n 


r—* 


—- 

P 

E © 

c 

X G 

> 

04 ^ 

o 

G — 


,—» 


© 


© 


P o 

n 


EH 

r—» ■ 

© 

O 

p 

o 

Cd TJ 

o 

3 © © 


© O 


•H 

,—» 

o 


d 


G cd 

>> 


b 

Q Q 

C 


>» (>)H^ 

P 

E 

P r-H O P © 

• 

E P 


as — 

© 

3 


^ O—' 


© 

2*J 


o 

cd 

•H 

M 

Q P 

© T3 

o cd 


© -H >»p 

p 

© 


p 

P G 

a 


Sl 


E 3C 



p 

p — P 

bf- 

CH 

-H 

G © 

p 

© 

G © !* P >» 

>» 

G P « 

,—» 

©•h d 

G *h 

© 


3 P O 


E £ 

• 


P 

•H rH O 

© 

U =tt Q K 

© > 

© 

p 

•H © P P 

p 

O © © 

o 

E as 3 

3 rH 



H cd C 


O CO 

£ 


CC rs 

G 3 

P 

P 

© © 

> O 

m n—' 


G K 


C > P © 

p 

3 O 

O 

rH 


CL O 3 


o 



Q 

OQ L 


X 

G > P 

G E 

© 33 © 

o 

© T> K © P 

rH 

•rH O P G 


W • o 

O p 

rH 


© O G 

_ __ 

d 

© 


cd © 

£ © © 

? 


© 

O 

PPG 

p 

P’0 CP K 

cd 

E cd p 

• 

G 

K 

3 

,—^ 

•H rH P 

© 

P -H 

p 


p 

Q P 

o 

m 

> - o 

O •r-K 

I>> -*H 


>» 33 P © 

P 

-3- *o 

G 

»p © 

O © 


• 

P r-s 

© 

o 



P o 

O 3 P 

G 

cd 

© © P 

w o- 

P © rH 

© 

P „ G G G 

O 

© G Cd 

P 

GPP 

P C 

P 

G 

PPG 

d 

3 X 

E 


m 3 

POO 



© 

K G G 

03 

© 

£ -H © 

P 

G © O 

P 

cd cd >> 


3 

P 

o d © o 

•H 

E © 

o 


© Q ^ 

G 

>> 

© 

G o M 

© 43 3 

© P 

p 

^ X 5 o 


O P 04 © 

cd 

© P 

P P 

© 

P 

P 3 OP 

P 

3 

Q 


p cd 0” 

X © cd 

f-, 

C 

cd cd M P .G o 

> © K 


OCX oo 

P 

04 s>> © 


rH p 

P 3 

G 

3 

O G *H 

d 

G E 



P P 

o P 

O 

•H 

CLO 

1 O 04 

O © © 

X)=*fc4-> rH 

G 

p t>»cfl 

5 

o d g 

3 • 



© O O d 

o 

O < 



o o o 

cd P 

E 

rH 

p m P 

c 

EGG 


G p •* 

cd 

K G P 

© 

© o 

G 

Q 

© 

© 04 O 

Q 

04 Eh 

• 


bn 

P o- © 

© 


O X 

o Qf d 


04 +3 

CL -H d P S 


© 04 G 

d 

>>E 04 


x 

© 

C © E 

x> 

M 

d 


P *0 

Eh tt) 

E 

© 

G rH 

d o cd 

- *>P 

O G 

3 © K 

p 

p o cd o 


G © 

S O 

w 

3 

•H P 3 

3 

CM CQ 

3 


•* x c 

•b 


c 

rH P 

P 

© G cd 

© 

© E © P 

33 

C op 

© 

G G Ol 

tt) 

td 

P 

*4 O 

© 

CM 

.d 

r-^ 

POO 

©OO 

£ 

o 

• cd G 

+j 

© 3 © 

^ E X G © G o 

© 

•H ^ 

G 

3 o a 

P 

K 


jQ >aj 


^t;CO 

o 

o- 

o d o 

© P hfi 

>H 


G © 

G 

N» O G 

© 

o o G d 

G 

G P 

o 

o d p| 

o • 

P 

P rH 

© 

S 


cd 

d © 

>»P 

P 

© 

O © > 

O T3 © 

04 

T3 G *H P O G 

l 

X P * P 

P 

•H 

c s 


© 

O r-iX 

P 



p o p © cd • 
© Oh © %-i o 
bO 3 P bfl 3 P © d 


cd co cd td 

5s w as cc 

OPfHUPHfcO 
Eh SI CQ Eh SM A-X 

as as w-x-ce-w 
cd nN^W^S?: 

cd <Q w cd td c?cg w 

coS^coSH^se 

hOObOfflOCO 


o ^-Hot.oo-HdHd 
E CH o oh E-h a 

CL, P P 

o Cx, x + s: x x 

CO Eh M W Eh CO < ft « 

o h k ® h < cd o S 

r X w > X CQU\> EH sc 
C d W > O W tSl^hS CO P 

cd coMCdcoxxcocdo* 

CO UZCOOQQhUCOW 
t-3 COCQbCQHOCQbCQ 


O ©'-' — ' 
rH TJ 

X >H 


CO CO X 

X X CQ 

CQ CQ N 

N C<I — 


MinXXX^H 

P WP Eh M W g 

apjcoppco 


cd © cd © d_4^— CX 

p O rH —' —» -H 3 %H%H 
© rH o — -H -H 

x x —— 

-f q 

+ + + ?: + Oh ■< 

OCO CO to<to OH 

■»CQ ffl ShS O* 

=fcN N N S(j <3 

X<ou cooxxwo- 
QQHQ HO* K * r H 
P^nox CO CQ hH M H CQ CQ 


p L do 
© © • Cd 
© N 


Eh O 
P Eh ^ X 
X 5CO CQ 

S O Cd CO 
dWH 

co Pm p 

td cdcd c^co 
co coco WEh 
»-a fflcd 


5 X EH M 

O P H 2 

d P CQ CQ 


cd 


CO 

X 


w 

o 


Eh 

X 


CQ 

w 


D 

X 


cd 

X 

X 


CO 

CO 



s o 

o 

CQ 

U 

X w 

G 

O 

£ 

cd p 

P 

Q 

x 

> H 

P 

P 

CO 

£ ^ 

3 

© 

X 

»H 

as 


CO P t^-co P_H-Oc< M 
in si si u\ tsi 3-w 

SI O'SI Si O'SI O'SI 
(MOPOJO&rUP 


rH _d-vO COCQpfcH 
CM m 

o 

SI 


m cq w nj-nuMApO' 

t^- mcM CQ -nsisisi x w 

Sl SlSlSlSl^OSlSlSlSl 
CM CQfOCVJCQ XHCQCM&, 


r^vO co xq&-h mmco 

cn -p- 

o 

Sl 


_ztco m h x x si 

XCOCQO'UOP 


X o p h cm m 

-9- in 

o 
Sl 


„„ ^ . -d-CMin rH CQ 

^ISSIIS. fc,o 
PH s s 

msvo co co ss 

^'£) CO CT'O&.H HQ&< 

OH<Sl(M co-dvo 
UNSO' H IA sO 
\A o 

“ <a 


O OQ 

E 

s 

s ss 

3 

G 

co 

S QO Q 

bO 

P CQ 00 

Q Q X CO 

o 

G 

sss 

s ssss 

a 

CM OS 
X CM Q 

CM CM CM CQsO 

G 

•H 

CO CQ W 


_3-vO O' 

sO N-A- 

t 

r- 

O 

>— *• 

o 

s 


s 


Page 20 

328 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 


4 d G Eh 

a 4 • © 

• = d © d 

O P u 

Eh d O «) 

© ^ « C C 

N O ® P 

O d d P 

fir OOP 

P OJ U 

d * o 
>-» S<! • o © 

O P CO Eh 

U Eh d W 3 

O O C o 

B «TD HT3 
Eh Eh d 60 d d 

3 3 © t>0 © d 

o o © o *o © 


S 

O COcOOCQOsOOft, 

W << 04 uno^ 
as mcn^^-co-fo-co-^o- 
O 


O Q CO ph 
Or^HP 
co-e^e-o 
W^^P 


w XXWXWXWXWXXOSXOSCO 
5 QQZQZQfcQZQQWXCOtH 

coajcQacQjtQasajhEH^K 









'd 

P 

o 





Eh 



d • © 

>> 

d 





© 


r-N. 

5 d Eh 

_Q 





'—• 

-Vh 


P 

O p o 


p 




C 

• Vh 


4 

■OP P 

Vh 

3 




d 

Eh 3 


d 

m 

O ^ 

d 




p 

4 d 


UO 

Eh P 

^•Sl 



© 

^—■ 

p 

d 

-—' 

P 

O K • 

^ « 

•» 

'—- 

d^ 

Eh —' 

i 

o • 

• 

N 

© © R 

II • Vh 

>. 

T3 

p © 

© >• 

Vh 

a 

3 


Eh d Eh 

—P O 

Eh 

d 

P c 

P TJ 

O 

p • 

d 

• 

3 © 

P • - t>> 

P 

4 

p 

o d 

1 

x « 

•fH 

d 

O Vh d 

d o oj d p 

d 


Ok 

&.TSI O CO P 
[i, OJ p [t, OJ 
-t/MO-w-ee-to- 

CO =#;=**: 

x X M X X 

aasaa 


o 


a 

E F 

hE 

E 

Fh 

d 

td 

P 

X 

M 

CO 

P ^ 


SC 

3 

h-J 

CO 

p 

►J 

X 

O OO 

o 

© 

X 

o 

8 

*5 

K 

Eh OO 

W 


Q 

o 

w 

t=> 

W C05 

z 

P 

E 

z 

Eh 

CO 

o 

CO WEh 

o 

4 


2 


X_t rOTSi CQ X'O 'Q 

PTSl TSlH _J-XSi<-OlSlrO 

^SUA v£> TSl <\j TSi OJ TS4. OJ 

Q X X Q X Q X Q X 


OJ Q CQTSl TS. 
TSi rOP X X 


Q Cl, rH rOU\ r— O' CQ Q 
\A 


TSiOJ O'tSi X'Si'Sl 
p x X OJCO OJvO 


ft, rH rOlACO O' o 

vO 


p fr, rH (OlA 

sC I s - 

Q 

*Sl 


C'^O'CQ M rH 
I s - oo 

Q 
TSl 


© eg d © 

E E C-C C 

©4 ® K P 

.da © p 

o E P T3 ® C 

O © C t£tn 

P O © P O 

d P -P 

• >> X © « 
W d o > 

bO P p - 

4 d d P P 

© -©40 

P-O o E bDC 

ad©©© 

© P >» Eh d Vh 


© P P 
d d d rH 


o K p d 

©©•HP 


**H O • 0 

P Oin • C 

• C 0 3 

U) Eh - • d 4 

O _d TJ P •' 
•> P O d P > 

© « d © d < 

>40 
P - Eh © O < 

P P d - J 

4 0 P •> 4 

aid 'OPP 

© © O J 

d o o. d < 
P EK 4 
vh oom 


lAO-Z Z 0- 
+ + Hp + 
CO CO dJ w CO 

< < (C K < 

p p a < cq 

N N W O N 

<XKKW 
P H CO CO Q 
CO CO *-) *"3 P 


Q Q 

fcSJ-mn 51,54 

EtVJCilk.CM 

OJ O' TSl C\J O' 

X X Q X X , _ n xa v r, 


OS CO OS 03 ; 
SC + SC sc: 

OP UQOi 
OS X OS^SJ. OS ( 
O P O-ffc-O | 

s n ss^s: i 


^ r ~1 ^ ►—< »-h , 

psozs:^ ppj 

*-aOPhHPp pot 


O X >» X 3 
i O X) © O 

• o jd o 

Eh P © 

: © d d Vh • 
p P P o Eh 
I O > © 

I 4 X P P -d 

I Eh ’O d O 

■ 4 E 3 
> d O - O Eh 

| O Eh P O O 

Vh Vh Vh 

l © P © 

• > • .d > © 

4 > n 4 p 
I © O i n n 

— E p — © 

: — -d p 

bfi — 


1 W 


I E 3 P ^ 
IOOP© 
Vh O P 
> « 

i © o d © 
I Eh Eh P d 
I O © P 
P N P 
I W I W d 
I © Eh • 
> T> Eh P d 
Id Vh P 


K 


r- 

+ 

•r4 >0 

Eh + 


p d 

O' P P CO OJ 

+ + + + + 

CO 

— CO 


o n 

CO CO CO CO CO CO 

X 

X 


P 4 

X X X X XX 

CQ 

CQ 


d 

CQ CQ CQ CQ ISl CQ CQ 

tSJ 

X M 


o 

p p 

M NJ tSJ CSJ^N N 

X H 

C P X - 

d cO 

4 

xxxxxxxco 

p > 

<C0P> 

< P 

d d 

QPQPQPPP 

CO EH J CO p E 

O P 

1-1 CO d CO J CO CO E 


CO \A> 
lATSl^a 


vOCO OJ Q p 
ft,TSl E^P 


lAvO ^Sl iSlvO 
GOOD OJ OJ X 


ISUA^OOrSllA^Sia'lSl'Sl^CO vO X XIAX^SL 

OJOO'H^O'HOQOJOIMCOCO _^-CO CO vO 

rOHDCO X P Q &hH roiACO P O f© E TSl OJ rO 
on rtv ^ 


K 


O' P P TSl^SLC^OJ 
tsi tsusi ^si tsi ^a. 


IAIAIT\IA0'\A\A1SI 
x CO x CO XcOcOvO 


H-sOcO XUWSOJ 

x CQ P 


) 


a 


a 



/— 

^ o 

n v 

^CO 





X 

© X 

d o 

^ P P 


Eh 


-■ — 


d p 

4 

Eh P -e> 

■ —*• 

© 


P P 

© 

P CO 

e d © 

• X 

• 

P 


d d 

p 

PCM 

e o d 

P © R 

> 

© 


r— to bO 

d 

d do 

O P P 

© P 

O 

E 

-—» 

o « •— p P 

© p 

p p p 

OP • 

E O 

e 

4 

• 

f-3 aiSi Eh Eh 

3 

© P Eh 

i o d © 

4 © P 


Eh 

to 

o 

d x 

>» d o 

TJ 4 P © 

Eh P 

© 

4 

4 


§5 

sc ^ 

p 

p E 

d o 

Eh P P 

4 P O P 

M © 73 P 
•H p © P 

a Eh p © 

op-E • e 

p 

O 

O P • O P 
a o P Eh x p 

O • 

P 

n 

© 

O 4 

Eh P 

O Eh 

o o d d 

d d © 3 

p 

Eh P 73 Eh Eh 

p 

P 

4 O • © • 

P © 

d 

O P 

© d 

O Vh 

4 5 3 

top 3 o 

d 

Eh >»P T3 T3 • 

o 


Eh Eh 4 U d bO 

© c 

p 

o 

« 3 = 


© Eh O 

O Eh 

3 

• 4 X 4 73 *9 

© 

2 *! 

O 4 Eh 

n p 

p 

© Eh 

d o 

h-* »P 

d Vh © O 

O Eh tf)d 

O 

P © 4 

Eh 

O 

© d 4 d Eh - 

•o 

3 

P 

P o 

c'-t®. d 

p d 

© o d 3 

o 

d D. © £ 

P 

4 

Eh O d P © 'Si 

• Eh 

O 

d 

o © 

© 3 

d p o 

O O C 

• d d 

Eh Vh .h © 

d © 

1 

« 

4 © - « ap 

p • 4 3 

-o 
— d 

d 

3 O Vh 

O rO « P 

P • 

• 

Eh 

Eh 

p p 

o e o 

P 'O P 

3 P d P 

d 

© 73 Eh d © 

Op 

- 

4 Eh p O 

P © 

73 

T3 © 

« 

x) d 

4 -T3 p 

d 4 

p 

P O 2*! Eh 

»-4 

Eh 

• Eh Odd 

4 

d 

4 Vh 

>*p = 

© 

p TSl 4 

• 4 P P 

p 

Eh E Eh O O 

a o 

2 s! O P P © 

C 73 

© 

O 

Eh O 

© Vh d 

o © 

d © p p 


O © O P P 

P E 

Eh 

© Vh © © E Vh 

bO C 

© 

p X 

Eh Eh 

Q,*fH «P 

Eh Vh - Eh 

p E 4 d 

TJ 

Eh D. Vh Vh a © 

• 3 

Eh 

4 bO— © P 

p • 


p 

© 

© — 

o 

O — P 

Eh • 

— .H P O 
— OP 

d « 

© 

d « d « 

P © o © 

4 

O 

P 

r ap —— 

*9 3 — P 
— — c 

Ctf*r-J © 

Vh 

— p— Eh — 

© X o 

© - © 

n © 

Eh 

• 

P 


OJ « Eh 0 ^ 

+ — 4 + 

P © CO 
X rH X 
P-Ct O P 
»N3=1fc'-'N X 


3 O > ro * —' 

O id O + H Vh 
Vh X EM JP 
— O'— X O — PI 

3 P fH P 
NCO P| 




:d 


XXJOEPXMXPO^XXP 

QQ^OOWPXOM*EhEh 

JPOEEQPHEPmPP 


? p 

p - ^ 
« 3 s © 
p o o d 

Eh Eh P 
4 -O P O 
P 3 O 5 
UWVhP 


Eh Ph' 
d> O' p 
djp p o 
PKCHTi-E r 
p ba w = 


9 HSDQQ 

POP JJ 


X X ^3 p CO 
Eh W P P H 
CO Q P *~3 E 


P —E fOT3 E 
CO P + — E 

X OP O 

E Eh X Q 

b r^Z P O 

O^trP|t0 dJ 

E XP X X M P 
PQPFhHZEh 
*-i P »-3 P Q PE 


>—eEe e e p p p 
p —E p ^ p p ^ p n p 

CO OXCOPOOOQOCx,Of 
w w?siwsiHiawtsiMpHr 
o-^cojE-ce-ss-p-sc^a-fcjHO-sc-^p-* 
o=th o^o-j 

XMXWXWXMXWXWXW- 

a§asa§agasasa§£ 


EH 

o 

z 

bO . 1 • 

Eh 

Oh 

p 

q os as 

p 

Z 

tJ 

p 

©pod 

W 

IS5 

S3 

P os sc 

M 

o 

x 

hJ 

aw oj p 

ns 

O 

O 

CO O O 

CO 

z 

o 

o 

as O' 

Oh 

P 

as 

as pq 

as 

J 

z 

p 

E Oh 

z 

Oh 

H 

S3 as o 

S3 


Id 

00 

4 Z © E 

Eh P d 4 

P Eh 

p 



o PP 

o 



vO 

O - b;0 

vO 

v£> 

vO 

Q X 

O Q 



X 

Eh Eh 73 o 

a © G Eh 

X 

X 

X 

^Si CO 

tsi^a 


• 

P 


z 

Ol, 

p 

z 

z 

i 

w 

Ph 


S3 

os 

p 

p 

© 

a 

w 

o 

CO 

o 

w 

p 

p 

oo 

p 

p 

OS 

p 

OS 

5 

a 


D 

5 

S3 

OS 

X 

w 

•H 


o 

o 

o 

o 

o 

z 


IA OJ CO sO X X^SlXvO 51 CO MTS. 
XXPvOsOOQX'OPMOOd 


Q &h P OJ _=flAvO CO O' P Q M P 

Q M 

o 

^Si. 


p 4 a 
p © 

K Eh S to 
© a>H d 
d ep-h 

© js; 
© P © Eh 

d d d o 
P -H p ? 


W ri U' p rH U » 

J-P P TSl^^j-TSl 

Q^SKT'^SlOJQlAXTSlOTSl 
XPOP XPOOPsOsO 


tSl rALOO- O' P HSlPfOvO 
^Sl P P P P 

Q 


Q r<YXD rA 
lAXSUA^Sl 


TSIOHSlIAX 

OJ x OJ O' O QvO 


r"X o P p oj^j- 

P OJ 

Q 

TSk. 


C^vOCOOJXMPXOvOQOJPMM 
’Si rATSir^VSiOJTSiOJTSl OJTSiOJ P P P 

0'^SiO' 1 SiO'TSiO s TSlO'TSiO'tSlO v TSlO' 

XQ XQXQXQXQXQXPX 


p p rnlAO- O' P Q P P rOlA I s - O' c 

OJ 

Q 

TSL 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 

329 





PASTIMES 


AND 

PLEASURES 

BY CHARLES WETHERELL 


Structured Programming: Disease or Cure? 

If you have spent much time around professional program¬ 
mers and their managers in the last five years, you have cer¬ 
tainly heard about structured programming. However, you 
could be forgiven if you have not made up your mind whether 
structured programming is a blessing or a curse. As a matter 
of fact, you might well decide that structured programming is 
some kind of disease. 

The reason for your confusion could be the conversations 
you had overheard. It is not uncommon to hear that over at 
Impossibly Big Machines, Inc., they have just taken up struc¬ 
tured programming, said in tones suggesting that the company 
should live through the attack. Or you might hear a project 
leader from Completely Delerious Computing say thankfully 
that he finally got his system out in spite of all those fancy 
rules. Then again, you might go to a meeting trying to sell 
your application package to Golf & Wasters, Inc. and be told 
that it won t be considered unless every last IF statement is 
indented just so. All of this suggests that structured program¬ 
ming is something like staphylococcus —it causes boils, but 
it also can be turned into a valuable antibiotic. 

The Source of the Confusion 

A difficulty with the phrase “structured programming” 
is that it describes a variety of activities, by no means all 
comparable. First, structured programming is the name given 
to the program synthesis tehcnhique developed by Dijkstra in 
his book A Discipline of Programming (Prentice-Hall). This 
method (and similar ones developed by others) aims at build¬ 
ing a provably correct program from a logical specification 
of the program’s input and output relations. Two things 
are required for Dijkstra’s structured program: a mathe¬ 
matical analysis of the programming language and consider¬ 
able mathematical sophistication on the part of the program¬ 
mer. When these requisites are available, Diskstra’s synthesis 
can be very powerful, but it cannot be surprising that program¬ 
mers without the necessary training are overwhelmed and 
bewildered by the heavy symbolism. Still, I can recommend 


a look at Dijkstra’s book if only for the material on practical 
programming. 

Second, structured programming often refers generically to 
a family of techniques for managing large programming pro¬ 
jects. Typically these techniques reduce the input and output 
specifications of something like an inventory control system 
to a standard format, a format that reveals the interdepend¬ 
encies and common needs of the system. Structured Analysis 
and Design Technique, the Jackson Method, HIPO charts— 
these are a few of the methods available. As might be ex¬ 
pected, these methods are not very useful to a programmer 
working alone. Rather, they are more appropriate for mana¬ 
gers and planners in corporations and software houses. 

Down to Earth 

More appropriate to the programmer working alone is the 
third meaning of structured programming. Here, the term 
refers to the regulated and standardized analysis of a single 
program. Top-down programming is nerhans the best known 
technique of this type, but many methodical programmers 
have their own home-brew structuring techniques. The ear¬ 
marks of a structured program are clean procedure interfaces, 
well described data structures, straightforward control flow, 
mnemonic variable names, ease of modification, and so 
on. The good working programmer may already produce 
programs like this, but structured programming is supposed 
to increase the probability. 

Finally, structured programming often refers to what I 
call “structured coding.” This is the genesis of the canard 
that structured programming is a blind book of rules governing 
every comma and keyword. Actually, structured coding is 
more like a newspaper style book. The purpose is to ensure a 
uniformity of presentation in all programs. Further, best 
solutions to common coding problems should be encapsulated 
in the book so that each programmer need not redevelop 
(at the programmer’s mental expense) the solutions. A good 
style book does not inhibit a programmer’s expressiveness, 
but it does make sure that his programs can be understood. 


Page 22 

330 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 



Now we can see why there is such a mixed reaction to 
structured programming. The manager thinks he has to be a 
mathematical genius to understand it. The line programmer 
is not very happy at having his creativity “managed.” Free 
spirits don’t like any rules at all. And mathematicians don’t 
program much anyway and can’t understand all the fuss. 

Before I discuss how structured programming might apply 
to you let me say that the proponents of the techniques I 
have described might not all want to be lumped together. 
But it is clear that in the minds of many computer people, 
they have been lumped together. So when you hear structured 
programming discussed in the future, you will at least be 
able to decipher the conversation. 



C*&-v 



What Does Structured Programming Cure? 

I assume that most of my readers are hobbyists and pro¬ 
gram for personal benefit. If that describes you, you may well 
wonder how structured programming, thought up by academics 
and industrialists to simplify the economical creation of 
correct, efficient, maintainable programs, has anything to offer 
you. Correct and efficient programs are always nice, but what 
is this about economy and maintenance? Sounds like an ad for 
an imported car. For the personal programmer, economy 
means writing a program with as little psychic pain as possible. 
And maintenance? An old philosopher once said that no man is 
the same person after six months. In six months, though, the 
new you is going to have to fix what the old you wrote; better 
make the repair job as easy as possible. You would be surprised 
how much you can forget about a program in six months. 

And do you need to be programming in PL/I, COBOL, 
ADA, or some other high-falutin language to use structured 
programming? No, even in BASIC and assembly language, 
structure pays off. My third and fourth meanings—standard¬ 
ized analysis and structured coding—can be applied to any 
size program. We have all had experience beginning a new 
program in a fever of creativity, writing and testing and de¬ 
bugging and modifying at top speed. What comes out of these 
bouts? A program that works, but not one you would like to 
work on. Generally, the result is badly commented, has 
control flow that resembles a bowl of spaghetti, doesn’t work 
on special cases, and gives readers hives. So back off and 
rewrite. Use your own style, but do the job tidily. Build on 
what you learned about how to do the program, but write the 
program in a structured way. For this is the disease structured 
programming cures. It cools brain fever. 



Number 48 


Dr. Dobb’s Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 23 

331 


Polymorphic Talks 

to the Heath. HT4 Priptet 


BY MARVIN KONOPIK 

American Embassy 
APO San Francisco 96503 

Here is a short update to Marvin 
Konopik’s article in DDJ #44,‘‘All The 
Secrets You Ever Wanted About Poly 
88 BASIC”: 


I originally tried to warm start 
the Editor at 2003, but it did not 
work. As a result of my article in 
DDJ, I was informed that 2003 
was the location. I have retried it 
and it does work. 

My request for assistance in lo¬ 
cating the end of BASIC brought 
many responses stating that 48AA 
is the place to go. This would sim¬ 
plify the process of combining pro¬ 
grams drastically. 


I purchased the Heath H-14 printer 
after careful thought and meditation. 
I certainly never assumed that my limited 
background in electronics was sufficient 
to contemplate building an interface to 
connect a printer to a computer. Desper¬ 
ately in need of professional advice, I 
called Heath to find out how hard it 
would be to interface the two. Needless 
to say, they said they were only con¬ 
cerned with Heath problems. This left 
only me and the computer to solve the 
problems. 

Armed with determination and some 
hard-earned cash, I ordered a printer, 
waited out the delays until it arrived, 
and began putting it together. It ran tests 
with only a minimal amount of smoke. 
The smoke seems to occur only as I be¬ 
come a more experienced Heathkit build¬ 
er. Actually Heath makes a very tho¬ 
rough, smoke-proof manual, but we 
professionals seem to lose our ability 
to read. There are three big questions 
in this project. First, what kind of signal 
is the computer putting out? Second, 
did you make any mistakes in budding 
the printer inputs? Third, with all of 
those input wires, which ones will be 
needed to do what? Since I did not have 
an interface board, luck would be very 
important. 

As I stated above, I am not even close 
to being an engineer, so the following is 
probably not the right way to do the 
job, but it worked for me. Give it your 
best shot, and it might work for you. I 


needed only 3 wires to make it go. You 
will need a TTL/RS232 converter from 
pin 1 (TXD), the computer out line, to 
pin 5 (SIN), on the printer board. When 
the printer is busy, it puts out a signal 
on board pin 7 (RTS). This is a RS232 
output, and must be converted to TTL 
to talk to the computer. The RTS, con¬ 
nects to pin 4 (CTS) on the computer 
board. The third wire is the ground, to 
printer board pin 1. I made the TTL/ 
RS232 interface featured in a June 79 
Kilobaud issue, for the SIN line, and then 
that portion worked fine. But then the 
printer was not able to keep up, and I 
discovered I needed an RTS/CTS link 
from the Printer to the Computer. I 
used one of my already-procured spare 
chips, which I buy automatically when 
I get new equipment, and which is an 
absolute necessity when you live over¬ 
seas. The printer uses two special In¬ 
tegrated Circuits. The 75189 (U103) 
a RS232/TTL converter and the 75188 
(U104), which is a TTL/RS232 converter. 
75189 is ideal for use on the RTS line. 
Had I known what the chips were for 
in the beginning, I could have used the 
75188 (U104) as well for the serial out¬ 
put. The easiest way is to buy the widely 
advertised kit: however, a 7404 must be 
used to invert the RTS/CTS signal. 

Also had I known that the U103 
and U104 were RS232/TTL and TTL/ 
RS232 converters, I would have certainly 
tried for a shorter, simpler direct TTL 
hookup, bypassing U103 and U104 
completely. A 7400 would have provided 
enough buffer power, with room left 
over to invert the signal, if needed. 

All that remains to getting it running 
is the setting of the baud rates. Imagine 
my surprise when I found that even 
though the printer will work up to 9600 
baud, it still prints at the same line speed. 
A 9600 Baud printer at H-14 prices 
would have not only been a definite 
bargain, but it would be a real paper eater. 
The high baud rates mean only that it 
can load the printer with extra text much 
faster. I found the 4800 baud rate just 
seemed to work better, so I use that as 
recommended by the Heath People. 
But to make things more complicated, 
I used an unorthodox signal cable. I 
like things to go on and off with one 
switch, so I put power and signal in the 
same cable. Any engineer will tell you 
that this is a real no-no, but it works for 
me. If you do not have a plug to fit over 


the printer board, one half of a 40 pin 
dip socket works fine. I really felt guilty 
not using all of those wires in the giant 
cable Heath provides, and I know the 
wires must be important or they would 
not be there, but after hours of testing, I 
just could not find a place to put them. 
One wire will tell the computer that the 
printer is not turned on. If the printer is 
in the same room, this will be apparent 
without wiring. Because of frequent 
moves, my working comer changes size 
and shapes quite regularly, so I decided 
to try a worst-possible situation first. 
I purchased a 20 foot soft cable to give 
me later portability. A word of caution: 
if you use the molex plug, be sure to keep 
the signal and power wires separated and 
insulated. One side of a molex plug has a 
block that prevents reverse coupling. 
It’s a little safer if you put the signal 
wires on this blocked side to prevent 
accidental contact if the plug is reversed, 
and tipped in. 

I had only minimal software problems. 
The Poly 88 Editor worked super, but 
BASIC was putting garbage on the line 
during non-use. After days of frustration 
and study of the Poly documentation, 
I found that BASIC does indeed put out 
garbage, in fact they call it JUNK. The 
junk signal was a 7FH (DEL), which I 
changed to 00H in location 4A7E and 
the line was quiet. 

Another discovery was the lost warm 
start provision when using the Print 
program. Warm start is bringing the com¬ 
puter up from reset, to restore not only 
the BASIC, but the program previously 
loaded in BASIC. Since BASIC and the 
Print program were separate, and each 
had their own starting locations, there 
was no provision for bringing both up 
warm. To use the printer program, the 
procedure was to start it, and it will 
in turn reach over and start BASIC. 
But the start is cold, so I merely changed 
that address, and it comes up warm every 
time. 

My printer printed columns a little 
irregularly at first, but after a couple of 
pages the rough edges wear off, and 
the print quality, with the exception of 
the funny little ‘g’s, is quite good. The 
end result is really fantastic. It is hard 
to imagine life without a printer, and the 
HI4 is certainly one way to go. 

* 


Page 24 

332 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 






BY W. D. MAURER 

George Washington University 

S.E.A.S. 

Washington, D.C. 20052 


There are two kinds of indirect ad¬ 
dressing on the 6502, both of them with 
indexing. Except for JMP, however, indi¬ 
rect addressing without indexing is not 
provided. Since indirect addressing seems 
to be more useful without indexing than 
with it, many people have erroneously 
regarded this as a design flaw. 

In fact, anything you can do with in¬ 
direct addressing without indexing can be 
done, and done faster, with post-indexed 
(Y-register) indirect addressing on the 
6502. We shall now give several illustra¬ 
tions of this. 

Suppose we have two zero-page loca¬ 
tions called IA and IA+1 for holding an 
indirect address. We can initialize these 
by setting them to AD and AD+1, as fol¬ 
lows: 

LDY AD 
STY IA 
LDY AD+1 
STY IA+1 

At this point we may do a JMP (IA), 
but not a ST A (I A) (for example), since 
that instruction does not exist on the 
6502. It may be simulated, of course, by 
loading the Y register with zero, so that 
the full sequence becomes 

LDY AD 
STY IA 
LDY AD+1 
STY IA+1 
LDY #0 
STA (IA),Y 

But this is unnecessary. All we have to do 
is keep IA (the low-order address) set to 
zero at all times, and write 

LDY AD+1 
STY IA+1 
LDY AD 
STA (IA),Y 

which is a decrease in the number of in¬ 
structions (from 5 to 4), rather than an 
increase (from 5 to 6). 

Why does this work? Suppose that the 


indirect address is 2345. Then AD con¬ 
tains 45 (hex) and AD+1 contains 23. In¬ 
stead of putting 45 in IA and 23 in IA+1 
(giving an indirect address of 2345, with¬ 
out indexing), we put zero in IA and 23 
in IA+1, giving an indirect address of 
2300. To this we apply indexing, with 45 
(hex) in the Y register; 2300 plus 45 
makes 2345. 

A common use of this capability is in 
processing arrays of strings. Suppose we 
have an array T of n strings, with n K 128. 
This is implemented as an array of n ad¬ 
dresses, with T(2/c-1) and T(2 k) contain¬ 
ing, respectively, the low-order and high- 
order parts of the address of the first 
character of the k-th string in the string 
array T, for 1 < k < n. To get the first 
character of the k-th string, we perform 

LDA K 

ASL 

TAY 

LDA T-1,Y 
STA IA+1 
LDA T-2,Y 
TAY 

LDA (IA),Y 

This assumes that T( 1) is contained at 
T, T(2) at T+l, etc., so that T(2k-1) is 
kept at T+2k-2 (= (T-2)+2k), and that 
IA contains the constant zero as before. 
This time the saving is not quite as great 
because we cannot do an LDY T-2,Y di¬ 
rectly (we could not even do an LDY 
T-2,X unless T is in page zero). But TAY 
is certainly both shorter and faster than 
STA IA (which is what we would have 
done if indirect addressing without index¬ 
ing had been available). (Note: ASL, in 
the above code, shifts the A register left 
by one, thus multiplying it by 2. On some 
assemblers one writes ASL A instead of 
simply ASL for this.) 

The same sort of savings accrue if T is 
a parallel array rather than a serial array. 
That is, suppose we keep two arrays, T1 
and T2, where all the low-order bytes are 
in T1 and all the high-order bytes are in 
T2. That is, what was in T(2k-1) and 


T(2/c), respectively, is now in Tl(k) and 
T2(k). There is now no need to multiply 
k by 2, and, perhaps more importantly, 
we can have n < 256 rather than n < 128 
as in the preceding example. (The reason 
in both cases, of course, is that our 
indices into the arrays T, Tl, and T2 
must, in each case, fit into an eight-bit 
register, and must therefore be between 
0 and 255, inclusive. Arrays with this 
property may be referred to as short ar¬ 
rays.) The code is now 

LDY K 
LDA T2-1.Y 
STA IA+1 
LDA Tl-l.Y 
TAY 

LDA (IA),Y 

under the same assumptions as before. 

In either case, incrementing the calcu¬ 
lated indirect address is also speeded up. 
Incrementing the 16-bit quantity in IA 
and IA+1, if we needed that, would have 
been performed by 

INC IA 
BNE NXT 
INC IA+1 

NXT (next instruction) 

In the actual case, the incrementation is 
performed by 

INY 

BNE NXT2 
INC IA+1 

NXT2 (next instruction) 

which is again both shorter and faster. 

It is true that, in this case, if we know 
that none of our strings has length greater 
than 256, we can do even better by using 
straightforward post-indexing rather than 
simulated non-indexing. The setup takes 
a little longer—we have to write some¬ 
thing like 

LDA K 

ASL 

TAY 

LDA T-1,Y 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

333 


STA IA2+1 
LDA T-2,Y 
STA IA2 
LDY #0 
LDA (IA2),Y 

— but now a simple INY suffices for incre¬ 
menting the indirect address. Note that 
we carefully set up two further page-zero 
locations here, IA2 and IA2+1, because 
IA2, unlike IA, is not kept at the con¬ 
stant value of zero. 

Another, even more common, applica¬ 
tion of these ideas is in indexing long ar¬ 
rays (this is, arrays of more than 256 
bytes). Suppose that U is such an array 
and we wish to index U(J), where J has 
just been calculated. Here both U and J 
are 16-bit quantities. Assuming that #U 
and /U represent, respectively, the (con¬ 
stant) lower half and upper half of the 
address of U, we can add U and J and 
store the result at IA2 by the following 
code: 

CLC 

LDA #U 
ADC J 
STA IA2 
LDA /U 
ADC J+l 
STA IA2+1 

and then, if we had indirect addressing 
without indexing, we would be ready to 
apply it. As it is, all we have to write is 

CLC 

LDA #U 
ADC J 
TAY 
LDA /U 
ADC J+l 
STA IA+1 

with IA set permanently to zero as 
before, and we are ready to use an in¬ 
struction like LDA (IA),Y (again, this 
is both shorter and faster than what 
preceded it). 

If we can set aside another two bytes 
in page zero for use only with this partic¬ 
ular array U, we can do even better than 
that. Let us call them IA3 and IA3+1; the 
permanent contents of IA3 are the low- 
order byte of the address of U, rather 
than zero. This can be set up with a de¬ 
claration like 

1A3 ADR U 

which actually sets up both I A3 and 
IA3+1, although only IA3 will be needed. 
We can now save two instructions each by 
writing 

CLC 

LDA /U 
ADC J+l 
STA 1A3+1 
LDY J 

and now LDA (IA3),Y will load U(J) 
into the A register. Why does that work? 
Let us make the following abbreviations: 


p — high-order byte of address of U (i.e., 

IV) 

q — low-order byte of address of U (i.e., 
#U) 

r - high-order byte of J (contents of loca¬ 
tion J+l) 

s — low-order byte of J (contents of loca¬ 
tion J) 

The 16-bit quantities we are adding are 
256 p+q and 256r+s. The two bytes IA3 
and IA3+1 contain, respectively, q and 
p+r, so that this 16-bit quantity is 
256 (p+r)+q. To this we add s by post¬ 
indexing, so that the computed address is 
actually (256(p+r)+<j0+r = (256 p+q)+ 
(256r+s), or J plus the address of U. 

The above may be extended immedi¬ 
ately to arrays U of two-byte or four- 
byte quantities. A curious intermittent er¬ 
ror may arise, however, if three-byte 
quantities are used. We would, of course, 
multiply the 16-bit quantity in J and J+l 
by 3 before using it, and then we would 
increment Y by one (using INY) to get 
the second byte set up, and again to get 
the third byte set up. This works fine, 
99% of the time. However, if J is 85, so 
that 3J is 255, then incrementing Y by 
one is not enough, since there is carry 
into the high-order byte of 3J. We must 
test for nonzero after the increment, and 
then increment IA3+1 otherwise. (Similar 
problems arise for J = 170, 341, 426, 
etc.) It should not be hard to see that 
there will never be carry of this kind for 
an array of rc-byte quantities where n is 


2, 4, 8, or in general any power of 2. 

In the above case it was assumed that 
U(0), rather than U(l), is contained at 
U, if this is not the case, then the address 
of U minus 1 must be substituted, in the 
above, for the address of U. We assume 
throughout, of course, that all 16-bit 
quantities are kept with the low-order 
byte first, as is customary on the 6502. 
The concepts of serial and parallel array 
are discussed further in [ 1 ]. Finally, users 
of the LISA assembler for the 6502 
should substitute $0, $1, and $2 for 0, 1, 
and 2 respectively, throughout the coding 
examples above. 


Reference: Maurer, W.D., Programming, 
Holden-Day, 1972, pp. 74-75. 


About himself, Prof. Maurer has this 
to say: 

I’ve worked for CSC, Lockheed, Proj¬ 
ect MAC, UC Berkeley (as an Assistant 
Professor) and The George Washington 
University, Washington, D.C. (as an 
Associate Professor and now a full Profes¬ 
sor). I've written a book called Program¬ 
ming as well as The Programmer’s Intro¬ 
duction to LISP and The Programmer’s 
Introduction to SNOBOL. In my spare 
time I write songs (My Pet Rock Is In 
Love, Dracula’s Mood Ring, etc.) and 
have them performed by a group of weird 
people called The Hexagon Club. 


LISTING 


28 

29 


STA 

LDY 

IA 

AD+*1 





30 


STY 

IA+* 1 


3PRINT "" 



31 


LDY 

AD 


!LOAD PPR5 



32 


LDA 

#*37 


BLOAI) PPR5, A*2000 

33 


STA 

( IA), Y 


OX!LIST 



34 


JSR 

TS1 


1 

ORG 

*18 

35 


LDA 

#*11 


2 

ADR 

U 

36 


STA 

K 


3 

ORG 

*0800 

37 


LDA 

#P 


4 

LDA 

#L2 

38 


STA 

T+*20 


5 

STA 

AD 

39 


STA 

Tl+*10 


6 

LDA 

/L2 

40 


LDA 

/P 


7 

STA 

AD+* 1 

41 


STA 

T+*21 


8 

LDA 

#*0 

42 


STA 

T2+*10 


9 

STA 

P 

43 


LDA 

K 


10 

LDY 

AD 

44 


ASL 



11 

STY 

IA 

45 


TAY 



12 

LDY 

AD+* 1 

46 


LDA 

T-*l,Y 


13 

STY 

IA+*1 

47 


STA 

IA+*1 


14 

JMP 

(IA) 

48 


LDA 

T-*2,Y 


15 L2 

LDA 

#P 

49 


TAY 



16 

STA 

AD 

50 


LDA 

(IA),Y 


17 

LDA 

/P 

51 


CMP 

#*0 


18 

STA 

AD+* 1 

52 


EEO 

L4 


19 

LDY 

AD 

53 


BRK 



20 

STY 

IA 

54 

L4 

LDA 

#*15 


21 

LDY 

AD+*1 

55 


STA 

P 


22 

STY 

IA+*1 

56 


LDY 

K 


23 

LDY 

#*0 

57 


LDA 

T2—*1,Y 


24 

LDA 

#*37 

58 


STA 

IA+*1 


25 

STA 

(IA).Y 

59 


IDA 

Tl-*1,Y 


26 

JSR 

TS1 

60 


TAY 



27 

LDA 

#*0 

61 


LDA 

( IA),Y 



Number 48 

334 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 27 




» w * * * X ~ « 1^ — — 

+ +<r + + + o o) « - o ++ 0) « - - 

<IQ<r*-a.QQ.OQ<IQ<X»« — 0)*©Q©Q*>-d)* 


o o 

Q H H H 

(N * M« 

* + 4* + 

ix + — a + cm 


>-*© — 'n*©x©©>-<©>-i*#—i-#>-<<x — ©# — i-^^^i-^xi-hy 


— « m ^ 

* + » a o 

i a i — « «+ 

H >- k ~ * _J 


in « * « ~ IP 03 — 

— i + I In ip » 

« oi © — — » ip « + © 

* 0. Y I- •- I- — # _| tfc Q_ — 


> >- > CL <X © 


(-Dt-rQI-QI-QhDI-ODhBQhQI-QOhWDI-DI-l-DI-t-DOlIQI-DIDIlilltQhDDI-BIQriilltDI-D 


-•OIO)«tlO-<3Xa30'©’nOld);a;lp'OXC»0'0*nOIO)«»-|0'OXa)0'0*-'CMO)«flp'!3XOC!0'0'-'CMP)^-|PM3XO()0'0*nOIO)>+lP-<3X 


O' O O' 

o o o 

© o ca © o il c- 

•n ^ ’I 01 0) O 
fO^OC-QO' 

as © co -o © co © 

CM *t X O' CJ 111 *- 

H H H m H «H OJ 

03 03 00 0) 00 00 00 

o o o o o o o 


O' O' O' O' O' O' O' O' 

ooo o oo oo 

OU.IOIllO^K'IOaOffllLMNn- 
■j«n'tnonr.non^«nnrtpirt^ 
QO^O^OO' nOO'IPU^UO-nOO-Q 
oo©oo©a3©©0'N©a3©co©©0'CM©oi) 

00'0 0'C0llJO('J^''00'CaQOCSIPN0'OLJ 
CMCMCM03CMO)d)0)0)0)0)0)«+<»-»+»r*»-*-st 
03030000 03 03 030300030000030303030000 03 

ooooooooooooooooooo 


O' O' O' O' O' O' O' O' O' O' O' O' 

©ooo© oo ooo o o 

O CM CM O' 0) CM — nWO I O n If) O n 03 in C IP —' 0) '-' © 

f) 'O I O >0 tL ^ n <t O O n-1 oo «a- lil —• O' — — O IP 03 -• 

0'QQO'QDQICOO'IPO'OinO'OOP'QOO'IPO'03nO'00(3'Q'0 

©d3oo©CDC(3«o«eDoocQ©cac3LLO©oo«eao(3ca©caoiLO©c»© 

-<o)'OO'0auj'-'«+iP'OO'03tiju. — 0)iP'000<auj*-«d)'0X0'eaQiiJO0) 
IPIPlPIPIPIP'O'O'O'O'O'O'O'OXXXXXXXCOCOaSCOCOCOOOCOO'O' 
030303 0) 030303030303030303030300000003000000 00 00 000000 00 00 00 00 
OOOOOOOO00000000OOOOOOOOOOOOOOO 


+ CM >* 

CM O © «n 

a w w * y z» 

1 -n * ~ * 03 # -0 


© > © <1. 
hOQI 
WJ JO 


uo«o> 

Z _J O Q © 

ca o _i © i- 


X*''t 

* + © « 

Z> + © •" * Y 

X "3 >1 - * CO 

© o © © a. u ' 

Q Q X Q E Z 

j i o) j u a 


nn + 03 «t 

* 03 © — 

Z> + © ►* « Y 

X "3 >-• "3 -n * 03 


H rl fX 

* W 03 O 

+ + » Y » 

* * * CL 03 * a. 


o 

o o o o 

~ IP IP IP IP CM 

03 I O ****** 

nnn(V+ + + + + + 
***_!****** 


00 00 04 Ol + O 

— OJDJQ# Q 

*D*#©x©*a.© 

oioamii)- 

IDIQhOhPhQ 

OIGJ03J03J03J 


oaua>aiLiiiYYOoao.uiaao)NNNir(oo!C3C!OOQ 

JQDhQDrZftICICQIDEZQhhCLCLILOQfOfOfCCfCICZ 

o_j«ro3_j_iooacQoaoo_Joa3_icf3o:iiiiiJiij<ioooooouj 


03 01 

© <r © q - oi 

Hnniy+KhOl 


OOnOI 

-i 01 01 01 


03 "+ IP +3 X 
0101 CM 01 CM 


00 O' O « 01 03 
01 01 03 0) 03 03 


«* IP -<3 X CO 
03 0) 03 0) 0) 


03 0)- 0in<tiP'0O 00 0'n 
03 0) 

© © O' <?' O' O' 

— 0)01 <3. CL OOOO 

ZYM03 © © © Q -N I CllLffiOOOlL 

liJ 03 Cl Q. I— nni-ii-.©i/|-l-l-0"3 Il tL O m 0) O ^ O 0) 0) 

OO 03 O' Q O' Q O' Q O 
0) © 00 © 00 « 00 © 

O Q 

EZZOOOOOONB3MOIL 
O'OnOIOl+IP'OOOOO'OnOlP + IP^MBO'OnOiroUJIilnnOOOOOOOO 
03<t->J'«+«+«+<+^«+<+<»-|PIPIPIPIPIPIPIPIPIP'i3-0'0©**0000000000 03 a3 00 a3 
— — — — — —— — — — — — — — — — — — — —— — — — — $ + OOOOOOOOOO 


* * 03 OIW-'O) 

+ h- + O © IP K + CIP X O' 

©a©Q.©©x©* — *,0 ©CL x © — * Y * *01 

H 3t H X w mZH^n< —| — * Z— '-*Q3*CL*CLY 


> nn > 

- * - — 

— + 01 CM 

« CM * CM O © X 

I © I © * — W Y 
X — (-►-♦■■'♦Ca 


CM — 

© O' IP 

>-< * Y * 


IP 

— <+ 03 
03 « — W 

* + * + 


- - - ---- - -- - - ---*CQ*0#“)*0 

x©©©©CJUJO>-©Q.C3Yx>>-UJO©Qilii©©©©©_l>©©<IC>-©Q.ljJ>©CLUJ©©©©©©CJ 
OOXQXZZZQQEUJQCXC3ZZZQEZQXC3XQO)©QXCiXQQEZZQEZQXQXOX _l 
_l_J0)_J03>nC0>-i_|_|OC30003_|i-i00>-i_IO(23_l0)_l03_l©l-_l0)_l03_J_JCJ0Q>-i_|cJCa_J03_l03_l0)O 


Q. Q Y © © 
EIJICQh 
O 03 CD J 0) 


CM W 

o © o + 

* -o >- X -3 

' © L) © © O 
I Q O I- O Q 
' _J © 0) _J © 


?!^11 ll ''S , ]; c 5 ( !;Prf l !?^ l,, '‘ )l '® l! ' o " Nn ^ lfi ' s,v(I!|, ' o ’ HNn,,|,! ' i !MJ3 0'Oooooooooonnn!12152n2 

-0-0'0'0-0'0'0'OXXXXXXXXXX00 00 00 00 03 00 03 00 00 00 0' O' O'O'O'O'O'O'O' O' -nm-n-ii-. — — — — — — — — — — — — — — 


Page 28 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

335 




Ll 



o 




o 

Ll 


o 


<x 




Ii. 




o 


lb 




o 





> 


CM 




G 


li„ 


(J 


O 

00 


«fr 


o 


oo 

00 




c 


o 


oo 


O' 




oo 






o 

N 


<r 


G 


h* 


OO 


CM G 


ft 


O' 

c 


O' 


c 


O' 

O' 

<1 

O' G 


o 


00 


O' 


o 


* 


a 


<x 


O' 

G 

c 

00 


ft 


O' 


G 


O' 


O' o 


444 


O 

444 


o 


4* 


c 

o 

ft 

O t-t 


444 


+ 


c 


444 


o 


o 


ft 


o 

ft 

444 

444 


444 


Q 


444 


G 


G ¥4 


* 


4* 

* 


4# 


* 


4* 

4#4 

4* 

4# 444 


w 


# 




* 


444 


444 


441 


444 

444 

# 

* 




444 


♦ 


444 


444 * 



00 

00 


00 


00 


00 


00 00 


00 00 

oo 


00 


00 


00 


00 


00 


00 


00 


00 00 


00 

00 


00 


G 


ft 


ft 


ft 


lb 

lb 


lb 


lb 


lb 


lb lb 


lb lb 

lb 


lb 


Lb 


lb 


lb 


lb 


lb 


lb 


lb lb 


lb 

lb 


Lb 


lb 


lb 


lb 

lb 

lb 

<x 

ii 

<X II 

<r 

II 

<r 

II 

5 

II 

«x 

n > ii 

> 

II > II > 

II 

a. 

II 

<1 

II 

<L 

II 

<x 

II 

<L 

II 

> 

II 

> 


> 

II > II 

> 

II <1 

II 

<X 

II 

CL 

II 

c 

ll 

CL 

II 

UJ II (X 

II 

o 

g 

1- V) 

o 

OO 

4— 

0) 

o 

0) 

4- 

G Q 07 4- u) Q G 4— 

G 

r 

G 

a 

G 

h" 

G 

D 

G 

l— 

G 

a 

G 

h- 

G 

a 

G H G D G Q 

G 

H 

G 

OO 

OO 

O 

G 

E 

G 

Z G Q G 

_J 


G 

-j 


OO 


-J 


oo 

— J 

OO 

—1 G 




-j 


G 


_J 


OO 


-j 


G 


-j 

G 

_J 

-1 


G 


“0 


G 


o 


CQ _J 



tH 

ft 


ft 


ft 


00 


00 


ft ft 

ft 


ft 


ft 


ft 


ft 


ft 


ft 


ft 


ft ft 


00 

ft 


ft 




ft 


G 

G 

G 


00 

0 


oo 


00 


oo 


00 OO 


00 OO 

OO 


00 


00 


00 


00 


00 


00 


00 


00 G 


00 

OO 


G 


OO 


G 


00 

G 

OO 


II 

M 


II 


II 


II 


II II 


II H 

II 


II 


II 


H 


II 


II 


II 


II 


II II 


II 

II 


II 


II 


II 


|| 

|| 

II 


a. 

0. 


CL 


a. 


0. 


a. a. 


0. Cl 

0. 


Q. 


a. 


CL 


CL 


CL 


CL 


CL 


CL CL 


CL 

CL 


CL 


CL 


Q. 


Q_ 

CL 

CL 



O' 



O' 




O' 

O' 


o 


O 




O' 




* 


* 




o 







O 




0^ 





i-t 

O *“• 


ft 

O 

ft 


ft 

o 

~ O CJ 


GOG 

G 

O 

G 


G 

O 

G 


G 

o 

G 

o 

O 


O 

o 

O' O' 


O 

O 


O 

G 

o 


G 

G 

o 

G 

G 


in 

in 


in 


m 


in 


in 


ft o 

o 


O 


o 


O 


O 


O 


00 


00 


O O 


O 

o 


O 


o 


G 


c 

o 

G 

o 

ii 

lb II 

00 

ii 

o 

ii 

o 

II 

o 

H U. II 

<r 

II O II CO 

II 

<X 

II 

o 

ii 

Lb 

II 

* 

II 

o 

II 

a. 

II 

<r 

II 

o 

II G II 

o 

ii 

II 

<X 

II 

CM 

II 


|| 

G 

II 

MO II G 

II 


> 

00 > 

c 

> 


> 

o 

> 

00 

> oo > 

ft 

Y 
4 

Y 
1 

> 

ft 

> 

00 

> 

OO 

> 

O 

> 

M 1 

> 

oo 

> 

ft 

> 


Y 
1 

Y 

o 

> 00 

> 

ft 

> 

OO 

> 

CO 

> 

G 

> 

lb > G 

> 

O' 

o 

D o 

O' 

o 

a 

o 

O' 

o 

Q 

oootooot 

o 

G 

o 

o> 

o 

a 

o 

O' 

o 

a 

o 

G 

o 


o 

G 

O^OOOO^ 

o 

ft 

o 

o 

o 

O' 

G 

o 

G 

G G 0^ 

G 

<1 

o 

00 o 

<1 

o 

00 

o 

<x 

o 

00 

040(004000 

o 

>0 

o 

<r 

o 

G 

o 

<x 

o 

G 

o 

<1 

o 

G 

o 

<X 

o g o <r o a 

o 

0^ 

c 

CN 

o 

<L 

O 

(J 

O 

Q O <[ 

O 


II 

II 


II 


II 


II 


II II 


II II 

II 


II 


H 


II 


II 


II 


II 


H 


ii ii 


H 

II 


II 


II 


II 


II 

II 

II 

v— 

X 

X 


X 


X 


X 


X X 


X X 

X 


X 


X 


X 


X 


X 


X 


X 


X X 


X 

X 


X 


X 


X 


X 

X 

X 

O 1 

u 

1 G 

1 

00 

i 

00 

1 

o 

1 

O 1 O 

i 

O 1 O 1 

o 

1 

o 

i 

O 

i 

o 

1 

Ov 

1 

* 

1 

<> 

1 

<> 

1 

0v | 0^ 

1 

O' 1 

N 

1 


| 

N 

1 

fs. 

• 

h. 

1 K 1 

o 

o o 

ft 

CM *-« 

in 

o 

x 

o 

<x 

o 

G 

OIlOMO^ON 

o 

O' 

o 

G 

00 

lb 

oo 

ft 

o 

00 

o 

-0 

o 

0- 

o 

G 

O lb O 

o 

O CM 

00 

+ 

oo 


OO 

CN 

G 


G 

N CO O' O 

00 o 

II 

O II 

o 

II 

o 

II 

o 

II 

o 

II O II 

ft 

II ^ 11 —* 

II 

ft 

II 

ft 

II 

ft 

II 

CN 

If 

CM 

II 

CM 

II 

CN 

II 

CN 

I. CM II 

00 

II CO 

II 

oo 

n 

oo 

II 

G 

II 

(S) 

II 

m ii m 

II 

o g 

<L 

00 a 

00 

<x 

00 

<x 

00 

<1 

CO 

<I00<IGCG<IG 

<x 

G 

<x 

00 

<x 

00 

<1 

00 

<x 

G 

<x 

G 

<1 

G 

<x 

G 

<r oo <x oo a oo 

<X 

G 

<i 

G 

<L 

0^ 

<x 

O' 

<1 

O' <L O <L 

♦ o 


o 

o 


o 


o 


o 

O 

o 

o o 


O 


o 


o 


o 


O 


O 


O 


O 

o 

o 

o 


o 


o 


O 


o 


o o 








> 





ft 


> 



















G 






ft 






444 




















G 

C G G 






444 





ft 

+ 


OO 

<* 




ft 

ft 

N 










ft 

in 

in in in 

CM 




444 

+ 

G. 

ft 



4fr 

OO 


<x 

ft 




4# 

4* 

G 



O 



G 

<1 

o 


* 

444 

444 444 444 

444 

D 


D 

+ 

<r 

>—t 

444 


D 

+ 

<r 


»-t 

444 

i^ 



+ 

+ 

444 


id 

444 



ft 

ft 

*-t 

CM 

+ 

+ 

+ + + 

+ 

# 

“3 

s 

“0 

i-t 


# 

OO 

\ 

"0 

t-t 



# 

CO 



♦ 

♦ 

* 

CL 

CO 

# 

CL 


4^ 

444 

444 

-J 

♦ 

* 

* * * 

♦ 

(J <X 

o 

> <r 

o 

a 

<r 

0= 

lb O 

<1 

o 

<r 

> 

<1 

CL 

lb 


y 

CD 

CD 

<1 

CL 

lb 

a 

<r 

G 

M 

M 

M 

CL 

CD 

CD 

CD CD CD 

CD Q 

J o 

o 

<r o 

Q 

H 

a 

E 

Z _J 

Q 

Q 

K 

Q 

o 

E 

z 

a: 

CL 

o: 

CL 

O 

E 

z 

a 

»- 

h 

CL 

CL 

CL 

a 

CL 

CL 

CL CL CL 

CL Z 

O -J 

<1 

»- -J 

<C 

G 

-j 

O 

00 o 

-J 

<r 

G 

-J 

-J 

O 

CO 

CO CO 

o 

O 

-1 

U 

GO 

-i 

G 

CL 

lb 

lb 

lb 

<r 

O 

O 

O O O 

0 lb 


Z i£ CM Crt 
bJ Oi Cl Cl h- 


CO CM 

<1 <1 <X D CM 

<r ^ 1 - 4 - 1-00 


t- in 

>0 

g 

O' 

O 

ft 

CN 

O t 

in 

>0 


G 

O' 

O 

ft 

CM G 


in 

>0 


G 

O' 

G 

ft 

CM 

G 


in 

nO 

N 

G O' G 

CN CN 

CN 

CM CM 

<N 

G 

G 

G 

o m 

G 

oo 

OO 

OO 

G 

<fr 


<fr <* 


•si¬ 

•t 



<* 

in 

in 

in 

m 

in 

m 

m 

in 

in in mo 

ft ft 

ft 

ft ft 

ft 

ft 

ft 

ft 

ft ft 

ft 

ft 


ft 

ft 

ft 

ft 

ft ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 

ft 



lb 


u. 






u. 


lb 








O' 



O' 










c 


o 






o 


o 








o 



G 









CM 

CM 

<x 

« 

G 

<1 

<fr 

CM 

<r 

O') 

O' 

CM 

G 

<* 

ft 




N 

o 

MO 

o 

o 





G 




G 

OO 

o 

CO 

ft 

ft 

ft 

ft 

o 

cn 

ft 

G 

ft 

ft 

o 




G 

oo 

lb 

o 

oo 





G 




G (O' 

a 

G O' 

a 

in 

ft 

O' 

G G 

0- 

a 

in 

O 

ft 


o o o 



O' 

o 

c 

O' 

Q 

G 




CJ 




ft <X 

MO 

<x <r 

•0 

G 

G 

<J 

Q ^ 

<i 

~o 

G 

<X 

G 

u 

a 

o o 



<r 

o 

Q 

<x 

G 

MO 




ft 




O' <x 

CJ 

lb G 

M 

in 

N 

O' 

G a 

UJ 

o 

G 

in 

G 

<1 

o 

UJ u 

ft 

(N 

CM 


h» 

O' 

G 

lb 

ib 

ib 

ib 

lb 

CM 

CM 

CN CM CN 

O G 

o 

G *+ 

ft 

ft 

ft 

ft 

ft ft 

ft 

CN 

<N 

CM 

CM 

(N 

CM 

M (N 

00 

CO 

G 

oo 

G 

G 

G 

OO 

G 

G 

G 

G 


O' 

lb OO G 

O' O' 

C?' 

O' O' 

O' 

O' 

O' 

O' 

O' O' 

O' 

0- 

O' 

O' 

O' 

0- 

O' 

O' O' 

CN 

0- 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' <1 lb 

O O 

G 

o o 

G 

o 

O 

G 

O G 

o 

o 

G 

G 

O 

o 

o 

o o 

o 

o 

o 

o 

o 

G 

G 

o 

o 

G 

G 

G 

G 

G 

O O G 




444 


444 



G 





CN 

444 

~ G 




+ 

h- 

+ 

G 

<r 

in 





4— 

+ 

<x in 

X 

CL <1 

Cl 

<X <1 

X 

<L 

444 

y-t 

444 MO 


<r 

CL 


X 

<1 

^ 4* ii 

444 

* •- 

X 

y-t y-t 

Z 

►-t 

# 


* _J 


y-t 

# 


Z 

y-t 

~ ♦ G 

* CL 

<E <X 

<1 

<1 O 

lb 

CJ 

> 

<X 

CL O 

ii 

X 

> 

> 

Lb 

(J 

<E Cl lb 

<e <r 

Q h- 

Q 

4- Z 

z 

z 

a 

Q 

E lb 

CL 

K 

O 

z 

Z 

Z 

Q E Z 

D h- 

-J G 

-1 

G »- 

G 

y-t 

-j 

-J 

CJ G 

G 

G 

_J 

y-t 

G 

y-t 

-JOG 

_J OO 


CN 

Q. it 


> 

-J 

G 

e 

Lb 

G 


Ll 

o 

o 

z 

Lb 

♦ 

* 

♦ 

♦ 

* 


- 444 - - — 

♦ CM CM CN ^ 

« m tt cn o a n <i ^ in 

I <1 I <L «4 •-« ¥4 y 444 444 

~ * g * 


* * * * 
* 

* o 

♦ 

♦ ft 

* 

* > 

♦ 

* I 

* I 

* 

* lb 

* -J 

♦ G 

♦ <x 

* 4- 

♦ 

* -J 

* O 

* Cu 

* E 

* > 

* g 

♦ 

* * * * 


o 

* o 

* _J 

* 

♦ 

* -J 

* UJ 

* cu 

* <r 

* _j 

* 

♦ 

♦ 

♦ o 

♦ o 

♦ -1 

* 

* 

* -J 

li 

* <r 

* _l 

* 

* 

* 

o 

o 

_l 


O Ul If) O U. 

- a> a n m 
o oo omj- a- 
o o o o o 


(N 

cn i- 

a IT! X Q 
H JZILd 


<X >0 O U. CN 

— N <1 CM m 

o co oo cn o- 

o o o o o 


<x t -0 ¥ 0 ) 

HJJBI- 


00 O CO Ui ^ 

-* -< <X <N Ch 

O 00 00 CN (N 

o o o o o 


<N CN 
O' CO 

c- u. 
o o 


H *0 


CN (N 
«* CO 
O' <1 

o o 


t- z> 


- CN 
f UJ 
O' O' 
o o 


_J 

UJ 

00 CO t- 

aaNxzN cn 
JM JZUJ0.1CI- 


10 

— <r 07 

07 « ~ W 

* + f + 

« ~7 * D 


—• + 

CN « CN O 

Z3 <r D + c « 

* "0 x -} >-i * 

<x o <x « o c > 


CN «t 
<1 - 
I-* W 7* 
- * CO 

<r o. ui 
O E Z 
joa 


K 

X 

z 


N> 

_l 


CN 

y- 

X 

z 


CO O' 

G 

- CN 

G 


in 


X G 

O' 

o 


CM 

G 

<* 

in «o n 

G O' 

O 


04 

0 } 


m 

M? 

N 

G 

O' 

G 

G 

ft 

o 

CN 

G 

0 

G 

in >o x 

G O G G 

G 

O 

O' G 
G ^ 

ft 

ft 

CN 0 ^ 

ft ft ft 

in X G O' O 

ft ft ft ft ft CM 

^ CM 0 
CM (M CN 

-0 «0 

N 


h* 

N 

h* 

N 

N S 

h* 

00 

G 

G 

G 

G 

aj oo oo 

G G 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O' 

O 

O' 

ft 

ft 

ft 


ft ft ft ft 

ft 

ft ft 


ft ft ft 

ft ft ft ft ft ft 

ft ft ft 
















O' 


O' 

O' 



O' 


O' 








lb 

lb 


Q 

Ib Ib 

















o 


G 

o 



c 


G 








G 

G 


O 

G G 


o <r 

O' 

ca <r 

CM 

G 

o 

<C 

G rt 


a 

O 


CM 

G 

<r co «t 

N G 

O' 

•*-t 

ft 



ft 

Q 

O 

CJ 

G 

(J 

O' 

0 


CJ O' CJ ^ 

MC!f! 

«■ 

0 ? CM 

CN <J C 0 Q G 

CJ M) 

07 — 

o 

ft ft 

o 

ft 

o 

ft 

in G 


ft 

G 


G 

ft 

-< in n 

G CO 

O 





«* 

ft 

«fr 

ft 

c 

ft 

G 

in 


-« g <t in 

CO 

G (^ 

ft 

G 0 

0 ^ G 0 ^ G 

ft ft CM 

a- in 

O' 

in -0 

o 

*0 

o 

ft 

O' G 

o 

M 3 

G 

G 

O 

MD 

— O' o 

O' Q 

O' 

Q 

Q 

<x 

G 

O' 

in 

O' 

in 

G 

ft 

O' 

o 

G 

ft O' G O' 

Q O' Q 

O' 

Q G O' 

Q in O' Q in G 

ft O' O 

<r ® 

<X 

00 Ul 

o 

lb 

<r 

G 

O Lb 

G 

G 

<X 

(J 

a 

UJ 

OUD 

<X G 

<x 

G 

<1 

o 

<r 

G 

G 

G 

G 

<E 

G 

(J 

Q 

U 

G CJ Q <r 

G 

<1 G 

<L 

G <1 

M) G C M> G « 

GOD 

in n 

O' 

oa a 

lb 

ft 

G 

in 

N O' 

G 

(J 

lb 

O 

ft 

G 

m n O' 

G Q 

o 

CN 

in 

G 

O' 

<1 

Q 

lb 

CM 

* 

>0 

G 

<1 

CJ 

Q lb — CO 

in 

G <L 

O 

lb CN 0 

in g <[ o ib ^ 

0 in n 

d- <N 

O' 

(N O' 

O' 

<X 

<t 

<i 

<r <i 

<1 

<X 

<1 

G 

G 

G 

cq co ca 

G G 

CJ 

(J 

o 

g 

CJ 

g 

CJ 

g 

o 

Q 

Q 

Q 

a 

Q 

Q Q UJ UJ 

UJ 

UJ UJ 

UJ 

UJ Ll Ll 

lb lb lb lb lb G 

G G G 

00 00 

00 

00 00 

G 

G 

G 

G 

G G 

G 

G 

G 

G 

G 

G 

00 00 00 

G G 

G 

OD 

G 

G 

G 

G 

o 

G 

G 

G 

G 

G 

G 

CO 

G G G G 

G G G 

8 

G G G 

G G G G G O' 

O' O' O' 

o o 

G 

o o 

o 

G 

O 

O 

G G 

O 

G 

O 

G 

O 

G 

o o o 

G O 

o 

G 

o 

G 

G 

G 

o 

G 

G 

G 

G 

a 


Li 


o 

o o 

G 

GOG 

G G O G G G 

G G O 


Number 48 

336 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 



8 

00 <L 

o 

m 

CQ 

> 

<r 

CO 

iL 

04 

r^ 

o 

m 

CO 

00 

tH 

D 

* 

o 

O' 

O 

• 

O 

444 

« 

o 


o 

* + 

« 

4* 

w 

« 

444 

* 

444 


> 


> 



> 



> 






6 





\L 



U. 






o 

(J 


04 

o 

O' 

OJ 

*-« 

O' 

Q 

o< 

o 

o 

H 

o 



o 

O' 

10 

o 


o 

t-t 


444 

¥4 

o 

¥4 

444 

o 

m 

<44 

444 

444 

444 

* 


* 

444 


* 


# 


co co co 

111 III llJ 

G II X H > II > 


CO CO CO 

111 Id LU 

H LU II <r II i 


UJ W t-WDWZWZCOQW: 


CO CO CO CO CO 

III III 111 III LI 

i ii <r ii <i h <x ii <i ii ■ 


CO cocococococococococo 

LU UJUJUJUJUJUJUJUJUJUJ 

ii > ii <i ii <x ii <i ii <x ii > ii « ii o. ii uj ii > ii <r 
05 4WQWI-(l)D(l)l-(/IDODWr(l)Z(l)Z(/!Q 


TOCOCOCOCOCOCOCOCOCOCOCOCO 
II II M If II II II II II II II II V 

a.Q.a.a.a.o.o.Q.Q.Q.a.Q. 0 . 

. _ _ O' O' O' 

O O O H H f-4 0 tH O ^ O ^ 

OOCOCOCOCOCOCOCOOOCOCOCO 
*? ■!!. a i 1 II N II « II 05 M «» II N II O II O' II - II II 

o>* H ><o> >o>«>in>N>o>-co>o>co>-^> 


o 

O 

O 

O 

O 

<N 

CO 

CO 

CO 

CO 

CO 

CO 

II 

II 

H 

II 

II 

II 

Q. 

Q. 

CL 

Q. 

CL 

Q. 


O' 

NOCI 
M N 


O' 

NON 
N N 


II — II Q II o II O II O II U II N II CO II 


CO CO CO CO 

III 111 111 u 

II Q. II UJ II <X II 

o) r o> z co q w 

O CQ _l 

« f! (0 - 

CO CO 01 CO 

II II II II 

a. a. o. a. 


o o o o 

II O' II O II « II 

> o > «t >- in > 


00-000000 

0.0(00400 

II H II 
XXX 

I CO I CO I CO I 
0 - in o in uj in o 
<X II <X II <[ II CQ 
00 <1 00 <X CO <X 00 

o o o o 


OOO^OO'OOOG'OQOO'OQOQO*! 
000(90000040(0040(110400 
n ii ii ii it ii ii ii ii ii 
xxxxxxxxxx 

COICOIOOICOICOI|X||X|0'I(^<-|| 

in»Hintoioixino'ir>caoaoooNoio-«oo 

JL g Ji g J( g ii oo ii oo n on ii o ii u ii o n o 
«oo<ioo<ioo<ioo<ioocoo<ioocoo<roo<roo 
oooooooooo 


O00O0-OIOOOOinOOO' H O0'OOO0JO^O0'OOO0-O 
04000000(90(0040(100000 0 000 0 00040 
II II II II II II II II II II B M M M lT 
X xxxxxxxxxxxxxx 

ON INIO'IO'IOIOIOlh'INININIO'IC.IO. l-< 
N0'N4OQOL.nNO4(')LJOa)O4OOOOOL.O'<ONin 
II O II U II O II O I. O II Q II Q I, Q II Q II Q |1 O r Q II UJ II LU II 

<roo<rmaoo<too<roo<ioo<roo<roo<ioo<i(»<ioo«oo<iooao3i 

oooooooooooooo 


> 

> 






> 


> 

> 

6 



NO 


O 







<1 

c 

N 

in 

CO 


UJ 


O' 

<1 

O' 

iH 

o 

00 


o 


O' 


O' 


o 

4^ 

4#4 

C 

444 

o 

o 

o 


o 

444 

4^ 



444 

# 

444 

444 

444 

444 

4* 



00 

o- <z 

o « 

* <* 


CO 

<1 

o 

> 

2 

00 

CO 

o 


in 

o 

444 

444 

444 

« 

* 


# 


CO CO 

CO 


(0 

CO 

CO 


CO CO CO CO 


CO 

UJ UJ 

UJ 


UJ 

UJ 

Ul 


Ul Ul Ul UJ 


UJ 

<Z II <X II 

> II 

c 

II 0. 

II G 

11 

c 

ii a ii > ii c ii 

<r 

II 

KCC50 05 a05Q05E 

05UJ050 05 I— 05D05Q05I— 

oo 

05 _J 

1- 

-J 

Q 

CO 


-J 

05 _J _J 

(0 

O O 

o 


CM 

CO 

CO 


tH H tH »—4 

V* 

CO CO 

CO 


CO 

(0 

CO 


CO CO CO CO 


(0 

II II 

H 


II 

II 

II 


II II 11 II 


II 

Q- CL 

Cl 


0. 

Q. 

Q. 


p 

p 

p 

p 


Q. 

O' 







O' 0> O' 



NON 

O 


O 

O 

O 


0 0 0 0*^0*^ 



(N N 

CO 


CO 

<0 

CO 


05 (0 « « 



a ii o ii 

II 

<r 

II O 

II ^ 

II 

in 

II O II ^ II —< II 

CQ 

II 


> 


A 

0 

A 

0 

A 

*-» 

> (0 > st >- UJ > 


> 


CO 


CO 


CO 


CO 


oo 


CO CO 


CO CO CO 

CO 


CO 

CO 


CO 

CO CO CO 

UJ 


UJ 


UJ 


UJ 


UJ 


UJ UJ 


UJ UJ UJ 

UJ 


UJ 

UJ 


UJ 

UJ UJ UJ 

II 

> 

II 

<r 

II 

Q. 

II 

Q 

H 

<r 

II <1 II 

X 

ii <r ii a ii 

<L II 

<L 

II 

(J II 

UJ 

II 

> II <1 II CL II 

0)<I(OQOOZOOUJOOQa)h*OODOODO^H(0 

O 05 1- 

UO Z OO Z OO D oo o oo r oo 


4- 


-J 


o 


CQ 


-J 

05 

-J 

-J 0) 

-J 

(0 


H 

CO 


-1 -J o 

H 


H 




CO 


CO 


H H 


CO *+ 




H 


^4 

CO «-• CO 

CO 


(0 


CO 


(0 


CO 


CO CO 


CO OO CO 

CO 


C0 

CO 


oo 

OO CO CO j 

II 


II 


II 


II 


II 


II II 


II II II 

II 


II 

II 


II 

II II II 

Q. 


a. 


Q. 


CL 


CL 


CL CL 

ft. 


CL CL cl 

Q. 


CL 

CL 


CL 

CL CL CL 

*-* 


o 


o 


o 


o 


o o o 


o o o 

o 


o 

o 


o 

O O O 



CO 


CO 


oo 


CO 


(0 05 


CO CO 0) 

(0 


oo 

CO 


oo 

o o o 

II 


II 

a 

II 

in 

11 


II 

CO 

II - II 

<x 

ii o ii <r ii 

O' II 

CQ 

II 

<1 II 


II 

o ii <r ii oo ii 

> 


> 


> 


Y 
0 

Y 
5 

Y 
3 

Y 

H 

Y 
3 

Y 
1 

Y 

o > 


> 

*+ >■ 



ID O O' O 00 O 
080(9040 
II II II 

XXX 


«2?:2PSSSSS92S;2!C2 i> ' 0 ® 0-01, 'OOoo>oqo-i!oO'OiooO'Oioo-oooooo-oo'0 
OOOOL.O4O»O4OOO00OfflO4OOOOOL.O4O00O4O4O(PO4OOOlilOQO4OOOOO 
“ “ " II “ N II II II II II II II II II II II II II II fl II II II II 

x x X X X xxxxxxxxxxxxxxxx X XXX 


imoioioioioioiioioio. loioioiioiioiioioinioiioioiO'iO'io.iO'iiLinin 
0'0a05lij08u.0»“0050'0—<00*-*a-<UjO'*00505'005h''- l <j'*-'Ca»-'UJIOOIf>08ll5l/5 05 N05C'OfflOQOU.0050inif8h'ir' 
S i J!- 3 Ji- £ I £ I £ Ji- £ 1 £ Jl. £ 1 $£ i ^ I “ " “ 11 oo ii co ii » ii K ii ^ V & V £ it & V “ if £ l l « m <r ii « ii 

®aoo«gaoo<ia«m«oo<xoo«ooaoo<xoo<xoo«ooaco«a><roo«oo«co<xoo<ico<ioo«oo<ico<ioo<roo<xao<ioo<ioo<x 


o 

o st 

O <X O' a 

« _■ o — 

* » « « 


N <X 

CO - 

* «t 

* — 


CN 

oo 

h» 

o 

CO 

u. 

04 

c 

o 

05 


iH 

c 

04 

04 

<1 

O' 

CO 

>0 

04 

u. 


> 

tH 

a 

CO 

0^ 

O' 

o 

O' 

H 

0< 

oo 

O' 

O' 

o 

O' 

O' 

* 

O' 

o 

444 

o 

o 

444 

o 

444 

c 

444 

o 

o 

444 

o 

o 

o 

o 

444 

♦ 

¥4 

444 

# 

« 

♦ 

444 

♦ 

444 

4* 

# 

444 

444 

4* 



LU UJ 

« II 05 II « 
l-ffll-(OQ 
cj> a. _i 
CO CO 


05 05 05 05 05 05 

UJ UJ UJ UJ UJ UJ 

ii <x ii > ii > ii > ii <r ii <r 
051— 05 Q05I— 05Q08Q05I— 


_l I 
CO ~ 

CO CO 

II II 

Q. 0. 

0- 

O O O' 

o o 


CO CO — — COCOCOCOCOCOCOCOCOCOC'CO 

UJUJUJUIUJUJUJUJUJUJUJUJUJUJUJUJUJUjujuj 
ii oc ii <r b a. ii uj ii <r ii <i ii (0 ii <x ii <x ii <x ii <i ii <x ii <i ii c ii <i ii <r ii _i ii > ii <i ii 
05 05 05 Q05i:05Z05Q05l-05l-05a05l-05Q08l-05*-05 Q05l-05l-05Q 05 05 05 a05Q05 


CO CO 

II II 

a. a. 

0- 

0-0 0 
O CO 


ii <x ii o ii oa ii u. ii ix h <r 

> -• > st > •« > CO>CO>*H 



«■« CO 

oo 

oo 

CO 

CO 



05 

CO 

CO 

CO 

oo 

00 

CO 

oo 

CO 

CO 

II 

II 

II 

II 

II 

II 

II 

II 

II 

II 

CL CL 

O' 

CL CL 

O' 

CL 

CL 

0' 

CL 

CL 

CL 

0^ 

CL 

o o o 

o o o 

o 

o o o 

O 

O O 

O 

05 

CO 

CO 

05 

oo 

oo 

oo 

OO 

CO 

OO 


II N II N II O II -O II O II O II 

>co>-co>-co>u.>o>co> 


CO CO CO 

II II II 

a. a. cl 

0- O' 

o o o o o 

CO CO CO 


CO CO CO CO 

II U II H 

a. o. o. a 

0- O' O' 
o o o o o o o 
CO CO CO CO 


II « II ~ II O II N II CM II O' II CO fl CM II ** II 
>«>Tf>C0>'0><I>O>-'0>U.>«t> 


o 

o 

O 

m 

CO 

08 

ii 

B B 

Q. 

CL CL 

O' 

O 

NON 

00 

04 

04 

11 

ii — ii 

> 

> St > 


ooooo- 

00 O -0 O <1 
II II 

X X 


2£222J222i2?222£22222£20 oool! ' OQ oo'ODODoO'OooQODO4ooi)oo'O 
0®040(»04040C9N040U0004 0 ®0«4008 040(90®040010(»0400040I»0 
ii ii b b ii ii ii ii n ii ii ii ii ii ii ii ii ii ii ii ii ii ii n ii ii 
xxxxxxxxxxxxxxxxxxxxxxxxxx 


12 . 2 i 2 i 9 i 2 IOIOIMMMMMMOIOIOI-I«IOIOIOIIM!M(M-ININIO' 
S29W92i9S2999 00(NO,0 coN(oo'OCNCo«tcoNcoO'Ocaoujoo^uj«-<co(ocO'0(oo'Ofl30ujo«w^cNinc'i'Oo 

11 W 11 * 11 * 11 IP 11 BO II ICO II ICO H IC5 II D ll <5 II 5 II s5 B <5 H 

o;<r^<ioo<ro5<ico«oo<ia5<roo<iooccoo<iO'<iO'<xO'<iO'«0'<ro'flcooiioo<roo<roo<xoo«ooaoo<io3aoo<ioo<r(B<iooc: 
ooooooooooooooooooooooooo o o o 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

337 


08E5- 

8D 

32 OF 

STA 

*0F32 

090C- 

6D 

32 OF ADC 

*0F32 

A=51 

X=00 

Y=01 

P=31 S=E3 


A=83 

X=00 

Y=00 

P=FO S=E3 


08E8- 

A9 

03 

LDA 

#*03 

090F- 

A8 


TAY 


A=03 

X=00 

Y=01 

P=31 S=E3 


A=83 

X=00 

Y=83 

P=FO S=E3 


08EA- 

8D 

33 OF 

STA 

*0F33 

0910- 

A9 

OA 

LDA 

#*0A 

A=03 

X=00 

Y=01 

P=31 S=E3 


A=0A 

X=00 

Y=83 

P=70 S=E3 


08ED- 

A9 

14 

LDA 

#*14 

0912- 

6D 

33 OF ADC 

*0F33 

A-14 

X=00 

Y=01 

P=31 S=E3 


A~0D 

X=00 

Y=83 

P=30 S=E3 


08EF- 

8D 

83 OE 

l STA 

*0D83 

0915- 

85 

IB 

STA 

*1B 

A—14 

X=00 

Y=01 

P=31 S=E3 


A=OD 

X=00 

Y=83 

P=30 S=E3 


08F2- 

18 


CLC 


0917- 

B1 

1A 

LDA 

<*1A>,Y 

A=14 

X=00 

Y=01 

P=30 S=E3 


A"14 

x=oo 

Y=83 

P=30 S=E3 


08F3- 

A9 

32 

LDA 

#*32 

0919- 

C9 

14 

CMP 

#*14 

A=32 

X=00 

Y=01 

P=30 S=E3 


A=14 

X=00 

Y=83 

P=33 S=E3 


08F5- 

6D 

32 OF 

ADC 

*0F32 

091B- 

DO 

12 

BNE 

*092F 

A=83 

X=00 

Y=01 

P=FO S=E3 


A=14 

X=00 

Y=83 

P=33 S=E3 


08F8- 

85 

1C 

STA 

*1C 

091D- 

18 


CLC 


A=83 

X=00 

Y=01 

P=FO S=E3 


A=14 

X=00 

Y=83 

P=32 S=E3 


08FA- 

A9 

OA 

LDA 

#*0A 

091E- 

A9 

OA 

LDA 

#*0A 

A=OA 

X=00 

Y=01 

P=70 S=E3 


A=OA 

X=00 

Y=83 

P=30 S=E3 


08FC- 

6D 

33 OF 

ADC 

*0F33 

0920- 

6D 

33 OF ADC 

*0F33 

A=0D 

X=00 

Y=01 

P=30 S=E3 


A=OD 

X=00 

Y=83 

P=30 S=E3 


08FF- 

85 

ID 

STA 

«1D 

0923- 

85 

19 

STA 

*19 

A-OD 

X=00 

Y=01 

P=30 S=E3 


A=OD 

X=00 

Y=83 

P=30 S=E3 


0901- 

AO 

00 

LDY 

#*00 

0925- 

AC 

32 OF LDY 

*0F32 

A~0D 

X=00 

Y=00 

P=32 S=E3 


A=OD 

X=00 

Y=51 

P=30 S=E3 


0903- 

B1 

1C 

LDA 

(*1C),Y 

0928- 

B1 

18 

LDA 

(* 18).Y 

A=14 

x=oo 

Y=00 

P=30 S=E3 


A-14 

X=00 

Y=51 

P=30 S=E3 


0905- 

C9 

14 

CMP 

#*14 

092A- 

C9 

14 

CMP 

#*14 

A=14 

X=00 

Y=00 

P=33 S=E3 


A= 14 

X=00 

Y=51 

P=33 S=E3 


0907- 

DO 

26 

BNE 

*092F 

092C- 

DO 

01 

BNE 

*092F 

A~ 14 

X=00 

Y=00 

P=33 S=E3 


A=14 

X=00 

Y=51 

P=33 S=E3 


0909- 

18 


CLC 


092E- 

00 


BRK 


A=14 

X=00 

Y=00 

P=32 S=E3 


092E- 

A= 

= 14 X = 

=00 Y=51 P= 

=33 S=E3 

090A- 

A9 

32 

LDA 

#*32 

*0800G 




A=32 

X=00 

Y=00 

P=30 S=E3 


0930- 

A= 

= 14 X= 

=00 Y=51 P= 

=33 S=DF 




Number 48 

338 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 





BY JOHN HOLTRICHTER, JR. 

P. 0. Box 227 
Redondo Beach, CA 90277 

Dear Dr. Dobb's : 

The Northstar BASIC Cross-Reference 
Tool program written by Titus Purdin 
and published in DDJ # 44 is not 
designed to operate in a double density 
system. 

Since double density is now becoming 
very popular, I thought your readers 
might like to make the changes indicated 
at the end of this letter in order to 
implement the reading, in a double 
density system, of single density type 2 
files on single density diskettes, and both 
single and double density files on double 
density diskettes. 

First of all, the routine should be 
organized at 2D00H, and if it is wished 
to be able to leave the program after 
bringing it up but before naming a type 2 
file, a CPI X and JZ EXIT should be 
added to the INFILE routine, where X 
may be 03H for a Control-C or 1BH if 
an Escape is desired in order to return 


x 

o 


§ 


£ 

a 

2 


2 a 

*-i o 

U I n 




^ i—i i—i 

h Q- N D- N 

co o cj n 


U* 

2 


CO 

CJ 


co 

aj 

| 

x 

o 



1—1 • 
Q 


CJ m 

8 - 

< CM 


CM 

r—f 

cj 



'JddJ 


immediately to DOS. 

Since double density systems may 
use up to four drives under versions 5.0 
and later, a CPI 34H and JZ GETCR 
should be added to the INUNT routine. 

Next, the fact that, in the directory 
sectors of the diskettes, the type of 
file is listed with the 7th bit high in 
double density and low in single density 
formats, the CKTYP routine should be 
modified and an additional single byte 
storage location, DENS, must be defined. 
In this modified routine, the type of file 
is first checked to see if it is 02H (single 
density type 2 file) or 82H (double 
density type 2 file). In either case, only 
the highest bit is saved in the DENS 
location, where 00H = single density and 
80H = double density. 

The next problem to overcome is the 
fact that in double density format, the 
reading of a file using the DCOM routine 
at 2022H in DOS provides 512 bytes to a 
designated RAM address, while only 256 
bytes is obtained in a single density 
access of this routine. Accordingly, the 
DATA storage location should be 


increased in size to 512 in order to 
accommodate a double density dump. 

Now the routine which reads the 
DATA area in RAM for processing must 
be modified in accordance with the 
density of the type 2 file to be investi¬ 
gated so that no more and no less than 
the length of the data supplied with each 
DCOM access is examined. The modifica¬ 
tion is made to the RDBL1 subroutine in 
order to determine the density of the file, 
and then to load into an expanded 
BLKPT counter storage location (from 
1 byte to 2 bytes long), 100H (256 bytes) 
for single density or 200H (512 bytes) for 
double density, in this initialization pro¬ 
cedure. Then, the Check Block Routine, 
NXTCR is modified to load this 2 byte 
counter value from BLKPT into the 
H&L registers, decrement it, and then to 
read the next block from the diskette file 
into RAM, only if the counter has 
reached zero. 

In the following partial listing, some 
presently existing code is shown to aid in 
locating where changes and additions are 
to be made. 


<u 

E 


co 


o. 


g £ 


g 


a< 

CO 


ac 

8 

X 

o 


CJ 

U 


W g 
fc 8 g 


m 


g 


U J H 


a tx ce 

X Eh X 8 X 8 

M CJ m U 5T u 

m u m o m o 


ID 

•—* X CC H 

CM >« CO Q Z Cx* 

cm e-* co h h x h J jic; i 

** •* k* 

caucD<su<s:uuxa4u<co 


CO 


X CO 
X CO Q DQ 


a, n a. n a. n 
U ^ U 1 U 1 


t-1 G4 


hi ^ 5 


h h J J H 


CO 


B§3§ 


* 

uJ 


CJ 


Page 32 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

339 







ADDENDUM 


Dear Editor: 

Thank you for your kind letter 
of April 21 concerning the publica¬ 
tion of my changes to Titus 
Purdin’s X-Ref program. 

The reason for my previous com¬ 
ments was that I run both double 
and single density North Star and 
CP/M systems in my IMSAI 8080 
(Z-80 CPU) and the changes were 
needed in order to allow me to best 
utilize this fine tool. However, I 
also run both 80 X 24 and 64 X 16 
formated monitors (along with four 
5 l A inch and four 8 inch drives) and 
I find that the X-Ref program was 
designed for only the 80 X 24 
format, which makes it difficult to 
read the last of the eight columns 
on the smaller formated screen. 
I can also see where this format 
would cause problems with those 
who have printers that cannot 
accommodate 80 characters on a 
line. Accordingly, I have set forth 


below a simple solution which may 
be incorporated as a post script to 
my previous letter, if you wish. 

In the subroutine labeled 
‘LSTN1the MVI A,8 should be 
changed to MVI A,7 for a 64 char¬ 
acter line, and MVI A,4 for a 40 
character line. The former change 
will provide seven groups of line 
numbers per line, while the latter 
will provide four groups per line. 
Nothing will be lost, but the 
columns will become longer. The 
purest may also wish to shorten 
the dedicated length of PLINE: and 
the number of blanks (20H) 
deposited therein, etc., but the 
saving in program length will be 
minimal. 

LSTN1 XRA A 

STA TAB 

MVI A.7 ;7=64 CHAR’S/LINE: 4=40 CHAR S/LINE 

STA L1NCT 

I have also noticed that the 
program, as it stands, will not work 
in systems which check the A 


register to see which input device 
is being used. An example of this is 
the standard North *Star Horizon 
system. A solution to this problem 
is to add MVI A,0 for the standard 
input device (video terminal) and a 
1, 2 or 3 etc., for other input 
devices, immediately before a 
CALL CIN. The locations of these 
additions are as follows: 

INFIL: MVI A.O ; 0-STANDARD VIDEO TERMINAL 

CALL CIN 

INUNT: 

LXI H,DRIVE 

MVI A,0 . 0=STANDARD 

CALL CIN 


GETCR: ANI 0FH 
MOV M.A 

MVI A.O 0-STANDARD 
CALL CIN 

The same general procedure 
should be followed (placing device 
number in the A register) before 
calling COUT, if the output is to go 
to a device other than the video 
terminal. For example, a 1 would 
send the output to a line printer. 


Number 48 

340 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 








HARDCOPY D€nce DRIUCR PROGRAM*? FOR CP/m 


BY STEVE WILLOUGHBY 

Owner, W.E.D. 

Box 87 

Crane, Indiana 47522 
812-854-7434 

The following programs were written 
to add a flexible hardcopy output to a 
CP/M system. These programs may be 
coresident (i.e. punch tape and print on 
tty and also print on daisywheel printer). 
The hardware consists of a processor 
with 32K bytes of contiguous low 
read/write memory, (RAM, with 4 K 
bytes of RAM at D000, a serial inter¬ 
face wherein RS-232 pin 20 (Data 
terminal ready) disables transmit buffer 
empty (TBMT) status to allow high speed 
transfers with buffered printers by hand¬ 
shaking through DTR. The software 
shown uses the same interface for both 
devices, so these routines would not 
logically be coresident without changing 
one interface assignment. 

Each program consists of a relocator 
which uses the CP/M jump vector at 0 
to locate the active BIOS jump table, 
retrieves the current jump link addresses, 
punches them into the driver program, 
relocates it to its place of residence, 
alters the CP/M BIOS jump table entries 
to point to new driver, performs initiali¬ 
zation of device and driver, and reboots 
CP/M. 

My system has aVDM and parallel 
keyboard for the system console. When 
the driver program is run (as any other 

CAM file), the device becomes the 
system printer and console output is 
intercepted and printed, or not, depend¬ 
ing on the position of the associated 
sense switch. If additional drivers are run, 
the last one is the system printer, all 
others being lost; however, the console 
output print/no print is stacked up 
through each successive driver. The 
Diablo driver also has provisions to re¬ 
place the parallel keyboard by the serial 
keyboard of the diablo printer.. 

Caution!!! If a driver program is run 
twice it will lock everything up; if run 
immediately after itself, it will return 
to itself after the output; if run at any 
other time (intervening drive(s) run) 
it overwrites the valid CONOUT return 
and forms a loop through the intervening 
drivers. 

For those who don’t have sense swit¬ 
ches: write a CONIN intercept routine 
to intercept normal keyboard input. 
If a control P (CDOS convention) is 


detected, complement a location. This end of the page, prints a cut mark ( — ) 
location would then be read instead of between two blank lines. A count of char- 
sense switches. The control P could be acters per line is maintained and an auto- 
passed along or suppressed (not recom- matic CR/LF is generated to prevent 
mended.) overprinting. Tabs are expanded to spaces 

No longer does your console output and occur at positions exactly divisible 
scroll off the screen to oblivion, yet by 8. A form feed mark routine is done, 
neither are you a slave to pulpmills and All other control characters are ignored, 
slow printers when hard copy is not (Thrown away.) 

needed. You have hardcopy of listings, The daisywheel printer must have its 
DDP disassemblies, ED text while in e- tab stops preset by a character stream, 
ditor, and system journal when you It recognizes form feed, and does not 
can’t stay and watch things grind. require delay after CR. The printer re¬ 

ceives commands in the print stream with 
DEVICE PECULIARITIES: The teletype- escape sequences, of which is added two 
writer is of the kind that has no tabs, no to allow resetting the carriage and top of 
top of forms, and needs a delay after form (Esc — R/r) and reset the tabls 
carriage return, and overprints at the end (Esc - T/t). 

of the line. The programs are highly commented 

This routine counts lines and, at the and should be self-explanatory. 



? 


AljTYPE DIABLO.PRN 


DIABLO 1650 I/O DRIVER FOR CP/M 
Revision level 2.1 2-28-80 

Steve Willoughby 
Box 87 

Crane,IN 47522 


D400 


i 

DESTIN 

EQU 

0D400H 

(Driver destination address 

0004 

* 

STATUS 

EQU 

04H 

(Status port 

0080 


MASK 

EQU 

8 OH 

(Printer ready bit 

0040 


INMASK 

EQU 

4 OH 

(Keyboard ready bit 

0005 


PORT 

EQU 

05H 

(Printer port 

0000 


SENSE 

EQU 

00H 

(Sense of data 

0004 


JSENSE 

EQU 

04H 

(Sense of status 

0001 


SEN SWT 

EQU 

01H 

(Sense switch port 

0002 


SENMSK 

EQU 

02H 

(Printer on bit 

0004 


KEYMSK 

EQU 

04H 

[Keyboard substitute bit 

0000 


SENSEN 

EQU 

00H 

[Sense of switch register 

0100 


START 

ORG 

100H 


0100 

317F00 


LXI 

SP,7FH 

(Set up stack 

0103 

2A0100 


LHLD 

0001H 

[Get warm boot address 

0106 

110400 


LXI 

D, 04H 

[Point to console status link 

0109 

19 


DAD 

D 


010A 

E5 


PUSH 

H 

(Save constatus address 

010B 

7E 


MOV 

A,M 

[Put it in program 

010C 

321B02 


STA 

CON1+1 


010F 

23 


INX 

H 


0110 

7E 


MOV 

A,M 


0111 

321C02 


STA 

CON1+2 


0114 

23 


INX 

H 

(Step to conin link 

0115 

23 


INX 

H 


0116 

7E 


MOV 

A,M 

(Get conin link 

0117 

320702 


STA 

CON2+1 


011A 

23 


INX 

H 


01 IB 

7E 


MOV 

A,M 


one 

320802 


STA 

CON2+2 



Page 34 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

341 





U « bi ui 

w w wo-*-* 

k4 m U 1-1 0) 

o o o o 

4-1 4-1 4-1 4-1 C 

O 01 

44 44 44 c 3 

m w w cr 

01 01 01 44 01 

H E-* H Hi to 


01 

M O 
H44Z 

•H O 

4-1 u CJ U) 

o 01 

W 44 c -C 
ItJ flj H U 

* g 12 

C M 3 
O 01 Oi (0 
•H U £ 

44 44 01 

<TJ 01 10 

U JC O c 

o 44 44 01 


cq w w 

<00 CO I 

5 5 5 

3 + + 

H Eh 

fa D fa 

y ouswsi 

CO X » CN fa CM I 

fa < U < in fa r* I 


' fa * Eh p CO 

CO ffl 3 Eh Z 

i as eg x m o < w 

lOhMOUUtDWo 


33 Eh 33 Eh 
Q D u D 
o O o O 

33 U U CJ U CQ 


S 33 33 Eh 

fa 00 O D 

< O O CN O 

Eh - - - 33 


8 2 2 

2 33 £ 33 H 

+ 03 DH D 

r-t H O ^ O 

fa - fa * 33 


CQQCCOQfaUOUEHUUUUQEHQGQ 


Z U CO > 

CQ CQ 3E fa 

ills 

CO CO CO fa o 


i fa n q 2 

ua Jo 


33 fa 

> HI M M H CO H fa fa 

>OfaNfaNfaNfaD><Q 

>a:u»- 3 u^u^ufasufa 


33fa 33fafa33 33 fa fafa 

H (fl H fa fa MM >MEH<<EH(OMfaHfafaEHCOCO<EHMMMfaQ5t*MfaMfa03Nfafa 

Sgig2Sg§f?gg3iSSgg5S52Sesl§||S5H?iggga^2g 


M M N fa 

3 g § g | 


Q Q 

oi U 

CJ Hf 

co < < 

U f ' 1 to u 


Q Q Q Q Q 

CN fa CN fa CJ CQ CJ T 'f o u 

m in r- in in so i-* m ooootj* 

(T.W<W<W<WinWQMCQWv£>< 


Q Q 
Q U U U 

O ^ O Hf 


<QWOM'*rinco<T»cQWoroinco<: 
coaococTia'cria>cria\cncT'<<<<< 
MMM'—tr—If—If—IMf—fMMMMMMM 

oooooooooooooooo 


wniwmwnwinwuriffl 

faUfaUfaUfaUOUUO 

OMOUomna>4tQQOH 

ascria><<<<<<<cQco 

MMMmMMMMMMMM 


Q Q Q Q Q 

- - -- — www -fa co cj m cq cj m cj ro 

oocotj- oo cj OHfOHf ooomh* r—i m tt r~ 

CQWvo<asWcofaoiosinwawQMosinmfacosowwaQoiWQWQinoiMM 

QfafaCJO>faQ<| f r iuuocjocjuuuQ^QHHouJu 0 UO(J r, UQU 

Mcomr'-<cQQfaoro-<rinr^<CJfaOMCNcoTrsoao<(jfaocoinoo<QW'-icN 
CQCQCQCQfaCQOQCQUUUUCJUUCJQQQqqQqQaqfafafaMfafaUfafa 
MMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMM 


MMinr^ccQQfa oco^inr-*<cjfaOMCN 
CQCQCQCQ 33 CQCQCQ UUUUUUUUQQQ 

I 1 f—t f—t r—t i 1 r—t f 1 t 1 «—1 r-H rt r-t r“l r—1 r—1 f—1 1 ,—1 ,—1 


ooooooooooooo oooooooooo 


oooooooo 


HT Hf rf 'T O 

a a a a o 

CJ M CJ CO MOCNOO 

^ n >» r~ ooooo 

QWQincNMMc^CQWcO^m 

cjocjmqjqucjqwwcju 

inoo<qfaMoiro^vooo<Q 

WWWWWfafafafafafafafa 

MMMMMM mmmmmmm 
ooooooooooooo 


o o 

0 44 0 44 

44 O 44 u 
ai ai 

M > 41 > 

ai ai 

44 Eh 41 44 

C D C 3 
-H O H 0 

&g &§ 


£ 

S 

z _>J 

M > J 

Eh 03 fa 

M CN CO Q Q 

+ + fa fa Z 

3 EZ SZQfafa < 

I 33 < U I < U 33 Q OI Q X Q 




u 



fa 


CQ 

w 


CQ 


3 

+ 

CQ 

u 

3 


3 

CQ W 
< CQ 

+ 


> 

♦ 

cq < 

Z 


fa 

> 

+ X 



Q 

fa 

W H 

z 


Z 

a 

o 


o 

fa 

CQ W 

u w 

a 

u w a 

fa u 

Q CD CQ 

* * 

* 

. * * * 

* * 



X fa + + CQ + 

O Z fa QO + co 

OMU33<X<!XEHXyXEHX 
O fa * fa *OXO\D03tS<DQ 
o <r'CjoicjoOMWooo 


XX><X><mmm2>X 

S5gSSgS3333gg 


j j g 

S * ><Sftw^S^SX M > > <>X : *< M >X>XX M >X>fafa fa<>M>MClM M M M M CN fa M 

yQ*ZpXOZOZZ><OZOZZXOZQZZ><OZO<< £EHOZOfaZfaMfaNfaNfaNfaZZ> 
MOSO^fafaSMXMMfaSMSlMMJzMaEMMJSMJuU ^ M £ < 2 U ^ U ^3 U 1 U ^ U U 2 ^ I 


W 

fa 

ro co fa cn 
cn cn r- ro 


O Q 
fa O 
fa o 
CO W OI M 
oi r- ro cn 


u' uw <_» \o ui u 

iCOcOMCOCOCNCOPOMCOCOOIfOCOMfOCOCNQQ CO 

• oicNMr^cNo*oioiMr^oir«.<NCNMr^oir'UCJ U 

i'»iniooi<aicjQWHOtfn^init)(ji<fflnfa cn 

I M r —t M M M M M r—1 r—1 i—1 H M M MMMMMM M M 

>00000000000000000000 O 


Q Q Q Q Q 
fa O*0\U01O<UQU 

r- OIOIOCNMCNOCNOCN 

CTSi£>faW(NW<U<U<W< 

o-W^faQfaUfaUfaUfaCJ 

msocooscQWoroinao<Qfa 

'OlOiO'OlO'OOOOOOOO 

MMMMMMMMMMMMM' 

OOOOOOOOOOOOO 


Q 

U Ufa 

O OI fa 
M O CO fa 
fa U U n 


Number 48 

342 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 







<u 


s: *j 
-*-* C r- 
O 3 ■»-» 

O <U 
-H U >1 


e o 

u c *J XJ 
0 O' 41 3 
fr. M O L> 


QXffl<u3xaXXXXXQXXXu5 


Q D 3 
Q O O E-* 

I u u 8 


u X < X 3 X 
- Cl, * O I S' 

< hUN U o 


! s g 

X X X + X + X 

o> ^ ^ bj Q Qi n 

o E-« o 3 o u o 


w w w w w 

W >-l CO CO W CO COCO W 

w I < < W < < < CO 

<1 ffl ffl < CD w co m < 

D h + + ffl + CO + + CQ 

£gg3Sgggg33 £5 

q 9 B g 3 s °. i g § -i q ° 

wxwowcjcjuuoocwo 


H 

S5Hgl^23g52553S5g|ggls;5g^g 


q W W W W q 

> M > ^ W ^ M M M N < M WOiM.Jm.JWWM<MHmW H N H 

ozoa<Zft<c^a-NO < csicu 2 qcua.< 2 :><><<<>E-t>u>< zz> 

X3xo»-3U>-sU'-JCJ>3u2JcJ'-3O'->XUXOUUXc0x2xu 3 b X i 


o Q Q Q O Q O O 

9 VO o Q r» I- ro CQ o 

< o oaoovcQCuo 

cocoaacOMCNrHrHcococNcocorHcococNW Q Q t, in n n (*> 
fHCNor'ffluW'Hr^<Nr^cN(NrHr^tNr^ocJU< r ^^ rr >U 


H(N(N(N(NtN(N(NINtN(NfN(NrOi 

HHHHHrlHHHHHHHHi 

OOOOOOOOOOOOOO' 


I CO CO CO CO CO CO CO CO if ^ 
I H M rH H rH «-H r-I rH rH i-H H 
>00000000000 


V ^ ^ »f 'f ^ Vf ^ ^ »f 

Q Q Q QQQ Q QQQ Q 

< CQ Q v© U CNMo\WcQQr-Qv©WWrHCN(j O 

o “] o *5 o O'fMvrHNOJOiCvf vrofllo CM 

W<W<WO<W<NQCOWQWQQQWCMWOVW 

wuc^uwcjcowwcjcjocjouuuc^coouo 

r-o>yW'HcoTfr'cr.ywcM'« , p^o\ufecM^r^ov< 

minininvavovovova&sor^r-r-r-r-r-aoaoooaoao 

H H H H rH rH rH rH rH rH rH rH rH rH rH rH rH rH rH rH rH rH i 
OOOOOOOOOOOOOOOOOOOOOO 


O HJ (A >i >i 

O H -o T3 
4) J5 rH flj flj 

w >i -h a» a» 

C 0) UH u u 


4 J o •*-» rH ra -U 

■U 3 4-» «J -H 4J 3 

U O 10 TJ *j fl o 

a> y v 

u o 4J Q, -* 

U U) rH W O *J W 

O fl II Cl Q 11 Kl 

u x as h 3 e> x 


W .O 0 I 
c c I 
01 111 >1 
CO 3 TJ 
*J H (Q 

W is <v 

O *J C u 
Cl 10 H 

n 3 5 
U *J 4J O 
O II Cl £ 

u o « co 


w p X c c 

3 a 4J U r« **H 
<0 4J 

4J <0 J3 -H 


o o w u o a> a» 


C C C -rt c o» c 

Cl D O U Cl IS -H 

CO CO CO X C /5 On W 


w 

CO 

< w 

CQ CO 

Z X CO ffi 

W CO H + 

CO X CO CO H 

is g § g i 

CO >iC O U U CQ I 


(0 CO K O CO O H 


M > 

X X fH OS 

o WXX rH CM CO Q 

o X r~ rH < + + W X 

'O’XXXXXXXX 0-00 x Z. XZQW 

Q'TOino^J'r-ICNOvOCNOXO- -O - O - - 

OOCOOOOOOOvOr^rHCOOaaX<UX<UXQ 


w 

H H W M £-« mm mm m H DQ 

OS ZN<oaZZWZXZNZXZN>wmQiZ 

X SouOM^XmX^OmX^XXXQWW 


h 10 Cl 00 Cl 

W -H > c 

w > a> x <o 

W 4) 4J Q u 

H as co m y 


D O Q Q D : 
pOOQQK 
w w w w w c 


iOm9mQW><X><mmm5> 

f§333gggg38g3333§ 


CO < CO X 

W H < O 

. Q CO X X 


X X 

W EH X Z 6-t Eh 

WCO^COWOOEh 

wcoQwQwwh 

coocococoxwco 


o ^ -r o 

o Q Q O 

o-row-^mw Hovrowo 

o o o < o r-~ oooooo-^ 

w v£)<Q<ajvoovcQWv£><mwooo 

W WUUUQWUQWWUQWWU 


o w 

IO CO U O' o 

W U CO CJ O II 


CM N , l00\y|i('HC0^'0C04lQ&(HON l '0r*DC0 
O OOOOOrHrHMrHrHrHrHrHfMCMCMCMCMOvCN 
CM CMCNCMCMCNCMCMCMCMCMCMCMCMCMCMCMCMCMCMCM 
O OOOOOOOOOOOOOOOOOOQO 


OOO rH H H O 

OOO O OQOO 

W >-h < <y» < o ov -r 

r**oo w w o cq 

H<HO'inWNnM(MHHH<h 
II II II H II II II II II II II CO CM M r! w P- CO CM r* CO CM M O M r- 

OM , OvnOM , rHCMOCMOOOCOVOOV<myWOrHVr-<QW 

OOOOOOOOOO^^OOOOOOOOOrHrHrHrHr-HrHrH 

■^•OOOOOOOOOOrHrHrHrHrHrHrHrHrHrHrHrHrHrHrHrH 

QOOOOOOOOOOOOOOOOOOOOOOOOOO 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 










u 

U a) 
<U -n 


0) 


4J (0 


u a 

n> h a> 
u j <4H c 
<0 \ H o 
x: a 'o 
o u a» 
no a> 

« fl'H i 

> o 

«o Q a> o 
w a t) 


a> > io 
JC « c 
o n 

4J 3 

•H o 4-> 
> 

w a> .c 
0) u 
a» c -u 
w a» -h 
c w * 


o 

CJ 



TJ <0 ■ 

* u 
o 

C f—i 

O a> 


(0 <u 

85 


8 . 3 ! 


E-* t* 

35 


2 0 - « Cm 

o aa u u m 



i 


mOMww jo 


5h 

p 

W H 

O O Q C/5 


H H N CM 


sgdssisgggi? 


« 

Q 

Z 

o 

u 


z 

o 

o 


Eh 

W CM 

s 

u 

W Q 

$ s 





a a a 

mm q xi 03 

opq ovom u o o 

n < ai ifl WQQrHfOCQW — ... 

QrouU©OOUUaWW(JU 


'O' o 
Q O 
O CM O O 

o o o 


y WriNniflcoay hnnino 

SqWWWWUWWUCmCmCmCm 

HriHHrHHHHHHrHHHri 


OQ y r* Q 
Dm Cm CQ Cm 


OOOOOOOOOOOOO' 


*0 

4 ) 

01 



a 

u 


o 

•H 

jC 


o. o 

4/ T3 

C I 


T3 

a 

D 


C 

<0 

pH 

OQ 


*J v -U u 


A c 

s s 


4J pH 
a, o 
O Dm 


c > n 
a «a *j 
o w w 
o 

'O *J 

a c a) 

3 < U 


(0 IQ 

a f-n 

T“» 0 


£ -4-1 

o 


0) -H 

O X 



o u u u < u 



Eh W 

5 - « D C/5 

z < a w o u § 

u < w 


►J *J 

J H J H fl! < 

< > < > 2 H 

o as u z x c/a 


I < M 05 < MM > 

g CUNZHZaJZNO 
U^HtOHXS^J 


Eh 

o 


Eh 

D 

§ 

o 


X 

I 

o 


Q Q Q 

„ _ 03 < r*or»Q 

M'HjirHO CO O CO O 


S £Q M’Hj-rHO CO O CO O 

U^oQWUWO^QWQWCm 

mmmcjo&MCJouuouoS 


Q Q 

m Cm 03 

X r* r* 

cm <y» w hJ> a\ 

n U h U U 


,om"«*>r~<y>cjWCx ) cN'<j‘r~<r>< QMom 

>4;<<«£<:<<;<(aiaBifljcQBjcQuu 

I r"H pH rH f“H rn rH rH H H pH pH H pH pH pH pH pH i 


3 03 

U fM 

U m m 


Q Q 

“ o r» 

O O 00 00 
CQ W x> 

Q W W 


< ^ I 

U r- . 


I rH pH 

ooooooooooooooooooooo 


O' U Q 

u y u 


o o o o o o 


VO O' < 

Q Q Q 

H H H 

o o o 



Number 48 

344 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 37 







THE 

L 

O 

y 

E 

P 

R 

O 

G 

R 

A 

M 


PR. 
D 
D 


R. 
R. 
R. 
R. 
R. 
R. 
DR. 
R. 
R. 
R. 
DR . 
R. 
R. 
R. 


H 


D 


DOBBS*DR.DOBBS*DR 
OBBS*DR 
♦DOBBS*DR 
D R.DOBBS*DR 

D R.DOBBS#DR 

D R.DOBBS*DR 

D R»DOBBS#DR 

D R.DOBBS*DR 

D R.DOBBS*DR 

D R•DOBBS *DR 

D R.DOBBS*DR 

0 R.DOBBS*DR 

D R.DOBBS*DR 

D R.DOBBS*DR 

D R.DOBBS#DR 

D R.DOBBS*DR 


. DOBBS*DR. 
. DOBBS*DR. 
. DOBBS#DR. 
. DOBBS*DR, 
. DOBBS*DR. 
.DOBBS*DR. 
.DOBBS*DR. 
♦DOBBS*DR. 
.DOBBS#DR. 
• DOBBS*DR. 
.DOBBS*DR. 
. DOBBS*DR 
»DOBBS*DR 
. DOBBS*D 
.DOBBS* 
.DOBB 


DOBBS*DR. 
DOBBS#DR. 
DOBBS 
DOB 
DO 
0 
D 
D 
D 
0 
D 
D 
D 
D 
D 

DO 

DOBBS 

DOBBS*DR. 


DOBBS*DR,DOBBS*DR.DOB 
DOBBS*DR.DOB 
S*DR.DOB 
DR.DOB 


R. 

DR. 

DR. 

R. 


*DR 
BS*DR 
BBS*DR 
OBBS*DR 
DOBBS*DR 
DOBBS#DR 
DOBBS*DR 
DOBBS#DR 
DOBBS*D 
DOBBS* 
DOBB 


.D R.DOP 

.DO .DOB 

.DOB .DOB 

.DOB .DOB 

.DO .DOB 

.D .DOB 

. .DOB 

♦ DOB 
.DOB 
.DOB 
.DOB 
R. DOB 
S*DR.DOB 
DOBBS*DR»DOB 
B 
B 


DR, D R 

• dobbs*dr. 

DO *DR.DOBBS* 

BS*DR.DOBBS* B 

DR ♦ DO 

• DOBBS*DR♦ 

D S*DR.DOBBS* 

BS#DR.DOBBS#DR B 

DR. DO 

. DOBBS*DR. 

D S*DR.DOBBS* 

BS*DR.D0BBS*DR, B 

DR.DOB 

DOBBS*DR. 

BS*DR.DOBBS* 

BS#DR.DOBBS*DR.D B 

DR.DOB 

DOBBS*DR. 

BS*DR.DOBBS* 

BS*DR.D BBS*DR.DOB 

DR.DOBB 

0BBS*DR 

BBS*DR.DOBBS* 

BS*DR. BBS*DR,DOB 

DR.DOBB 

OBBS*DR 

BBS*DR.DOBBS* 

BBS*DR.DOB 

DR.DOBBS 

BBS*D 

0BBS*DR.DOBBS* 

BS*DR♦ BBS*DR.DOB 

DR.DOBBS 

BBS*D 

OBBS*DR.DOBBS* 

BS*DR.D BBS#DR.DOB 

DR.DOBBS* 

BS* 

D0BBS*DR.DOBBS* 

BS*DR.DOBBS*DR.D B 

DR.DOBBS* 

BS* 

DOBBS*DR.DOBBS* 

BS#DR.D0BBS*DR. B 

DR.DOBBS*D 

S 

D0BBS*DR.DOBBS* 

BS#DR.DOBBS*DR B 

DR.D0BBS#D 

♦ 

DOBBS*DR.DOBBS* 

BS*DR.DOBBS* B 

DR♦DOBBS*DR 

R. 

D0BBS*DR.DO 

B 

DR.DOBBS#DR 

R. 

DOBBS*DR.DO 

B 


DR.DOBBS*DR.DOBBS*DR.DOBBS*DR.DOBBS*DR.DOBBS*DR.DOBBS*DR.DOB 


BY G. GAUGLER 

5706 Seascape Ct. 

Citrus Heights, CA 95610 

The enclosed listing is an assembly 
language (PDP-11) version of a program 
I originally saw in BASIC somewhere. 
The program was interesting, not terri¬ 
bly useful, and quite slow. However, 
this is exactly the kind of program one 
needs when trying to demonstrate a com¬ 
puter sytem to a non-computer person. 
I have found it rather successful for 
nocturnal social acquaintances, etc. U- 
sually they would lose interest by the 
time the BASIC version would finish. 
This implementation will be as fast as 
the output device. An obvious advantage 
in such situations. 

The fundamental principle of the pro¬ 
gram could be extended to other types 


of figures or drawings. The byte table 
contains the counts of characters and 
spaces (blanks) in an alternating order. 
A byte with the sign bit set (hence a 
negative quantity) indicates that the 
count is for characters at the far left of 
the figure; meaning that it starts a new 
row. The next byte would be the count 
of spaces. The following byte would be 
for the count of characters, and so on 
until another negative byte is found or a 
zero byte. The zero byte signals the end 
of the table. 

The program prompts for a characters 
string which will be impressed into the 
figure. Character positions are preserved 
across blank fields (as can be seen in the 
enclosed example). 

For any interested readers, I also have 
the same program coded in 6800 assembly 
language. A SASE will prompt me to send 
it to anyone who wants it. 


Page 38 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

345 











(J z 
« o 

Cl U 


« A 
I *- 
u >- 


. ♦ O O Z K 
■ <L CC <C 
: z a.uju >- 
i « uj a — 
: h m h 3 t 


<1 A W C 

K K H 
t- V) A Ui 
3 O >- K 
Cl CC UJ 

l-UQI-W 
3 Z Z O UJ 

O h UI z CC 


UJ 0. 
(J Cl 
« 3 


a z 

h- 
3 ^ 
3 3 


»- a a 

CC *-« 3 

« 0) K 
H- UJ A A 
« >- A A 




O CC J 
Z UJ cc 
3 • 
UJ z - 
UJ o <r 
tfiuac 


CD O CC A 
VI OC 3 ♦ 
UJ O - 
-J -J 

J UJ o 
uj h 3 in 

z f- « re 
o in cn * 


AAA 
<x x a 
3 3 
CO Z A 


CC UJ C 
U J- 
V) 3 ► 


A013UK 


) CC CC 3 
[ « 3 O 
110 3 
> U >- ' 


^ 3 
A A 
~ 3 Z 

O © A *-h 

t O CC u. J 

♦ A ~ 3 * 


CC © 
- © 
<r 


3 Z 

N UI O 

oc z a 


~ - © *• 
Cl J - CC CC 
COW ‘ - 

»H W 3 ■+• OC 

O I h A lk 

a - x a 3 

w 3 © UJ Vi A 

A A A ♦ • 


I X •-« *h ft. I I 
K«I33J-J- 

\\\\\\\ 
A A A A A A A 

in in in in in m m 


) v v v v v v v 


3 U 

c *-< 

C A 


>- -< C5 K 
CO X A A 
J- A A OC 


3 ~ - O 


3 3 
CL A 
f- J- 3 


mi O 

a oc ® 3 

3 w 3 a 


O O N O "0 N h 
o ~ © © o ^ m 
cm iv o rs m rv 
in m »h cm is © 
OOOhONO 
© -4 © O © O © 


CM CM © CM CM IS Pl 

© O © © © © 

,h rs cm 

(M N NI0 O h o 

-4 ▼ N © O © © 

-H © ^ ^ © © 


CM © © «0 •C 
© © © « CM 

r» cm rv rs 

CM © CM »h JO 
*■©-«©© 
-4 © © © O 


© © © cm >o 
•o o rs rs is is 

rt rt H H H H 

© © o © o © 
©©©©©© 
© o © © © o 

cm po * in •« rs ® 
■O d d 4 d-0 >0 


CM + 
O © 
CM CM 

o © 
o © 
o o 


■0-00 
© © -4 

CM CM CM 
© © © 
O © © 
O O © 


* O © CM 
*4 ~ CM CM 
CM CM CM CM 
© © © © 
© © © © 
© © © © 


© © 
© © 


o- © *h cm n «r in 
m> rs is rs n rs rs 


NNNM8 0D0D® 


* 'C -o *0 
w ro 

CM CM CM CM 
O O © O 
© O © O 
O © © © 

m-OMDD'OHCMMT 


▼ © * ^ 

© © © © 

IS © M CM 
CM *4 © >0 
*4 © 'O © 

© © -4 © 

© O © O *■ >« © M) 

'O'ONO © © »4 ^ 

cm cm cm w po ro m ro 

©o©© ©©©© 

©©©© ©©©© 

©©©o ©©©© 


U UJ 3 OC 3 3 
UJ Z O 3 O O 

a a x • c r 


m a 3 3 3 a 
A OC * * * * 
« O 3 3 3 3 
A 3 A A A A 


uj J— x A 

r W 3 *• 3 

<X 3 Z OC A •• 

Z K 1C u. z o 

(L Z 3 3 -4 V) 

-3 UJ A A 3 r 


PO -o -o 
© CM *■ 
MOO 


O » -O « O N 

© © -o © © © 

■O N t N O CM 
CM CM O CM »h © 
^ ^ © ^ © O 


O O O 00©©0© 

'O'OOCMtT'O 
in m >o -o >o cm cm 
ro po po po ro ▼ 

© © © © © © o 
©©©©©©© 
o © © © © o © 


© o 
© © 
*0 © 
<0 © 
© 

© © 


mCMCMCMCMCMCMCM 

©©o©©©©© 


o«©^cMM^in>orv©o. 

cp©oo©©©©©©© 


o ©CM5r<r-<j'0O©CM(MP0^n«0C'j 

0 M'W-O'O'OHHHinH'ON'OI*) 

r *<r<r*-M-*'0'0'©M>rvrv©o.-i 

> OOOOOH«HHrtHH(M(M(M 

> ©©©©o©©o©©©©©©© 

> ©©©© 00 © 0 ©©©© 0 ©© 

■4CMW*-in'Ors®&.©^cMfo*-W'Ors®<>. 

HHHfHHHiHHHCMCMCMtMCMNCMMCMCM 


« P- 
I CO 

u z 


3 Z O UJ 
O UJ Z OC 


AO- *-< * 

UJ © 3 0 

3 UJ J- J- O 

CO A X CO 3 

3 <t O • • 

« u •-« - - 

O © UJ j- X 

« X z u 

• UJ Hh 

A © © A UJ 

3 A A 

>- M> A 

CC O b- 

« rs -i 

CO © O 3 3 

3 3 

>- « « 

A U O 

z X 


O A 3 A 
« 3 3 Z 
ZOCUJ 
• X O • 


A 3 
3 O 
O X 


A A 
3 3 
A A 
Z Z 


UKUJ A 
Z © Z X 
Hl-AO 


A h- t- J— 

© *- X -h 

X 3 A 3 
♦ O ♦ <3 


A © O © 
A O 3 O 
• A - A 


3 1C 
O © 
3 X 


A A 

*“ P- A 3 
3 © Z O 
O K A X 


NOCMt-OMOHN 

•O-OOO-OOOON 

o<rorv*-rs,©rv.rv 

©0«CM©CM^CMPs 

OOOHOH©rtN 

©©oooooo^ 


O'O'-omrvn-iN 

© >o © CM IV cm rs ^ 

NfNMlHOn 
IN h ^ ^ rt o O M 

’-«©o©©r'j©© 

©©O-h©©©© 


o © 
o © 
© © 
o © 
© © 
© © 


^ >o 
o © 
© o 
o © 
o o 
© © 


<NPM-||l-ONCD&-OHCNnVin-OMDO'0'<( 


© 

o 

o 

© 


o © 
o © 
o © 
© © 


MJ © CM V 

<r m in in 

© © © © 


o o o <r 

»-< © -o © © 

in rs v rs cm 

ro cm -«CM CM 

© -< o o 

^ © © © © 


■o 

© 

© 
o 
© 

N®>0< 

i-)Mn<r 


CM ▼ >0 M) © 

>o rs rs ^ cm 

o © © ^ ^ 

© o o © o 

© © © © o 

© o o © © 

i CM P) ^ W >0 


o o 
© o 
© © 


© cm © >o © rs *0 

hOO-Oh^N 

is o rs t cm rs o 
in -m cm rs © 
© © © n © © 

-« © © © © © © 


© o © © © © © 
© © © © © © © 
© o © © © © © 


Number 48 

346 


Dr. Dobb’s Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 










Page 40 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

347 










A PROBLEM WITH 


LOGIC PROBES 






BY DAVID N. BERTOLLO 

89 Westdale Avenue 
Hillsdale, NJ 07842 

ABSTRACT 

While debugging a TTL system using 
the Micronta Model 22-300 ‘'multi-logic 
compatable ” digital logic probe, I discov¬ 
ered that this probe will only give a cor¬ 
rect high level logic indication in fifty 
percent of the cases of a true TTL logic 
high. A TTL circuit is herein described 
which will operate properly when testing 
TTL logic levels. 

The Problem 

A few months ago, while debugging a 
new Z80 system, I decided a digital logic 
probe would be useful to have and 
that it would be much easier to purchase 
such a probe than to design and build one 
from scratch. Several digital logic probes 
are available from a number of manufac¬ 
turers, ranging in price from $25-100. 

On the surface, it appeared that the 
higher the probe’s cost, the lower the 
value received. In the end, I decided to 
purchase the $25 variety: a Micronta 
22-300. It seemed that this probe would 
suffice for all but a few fast pulse points 
in the system for which it would be used 
(the probe cannot indicate a pulse of 
under 300 nano-seconds duration). This 
probe also had the advantage of being 
advertised as working with several logic 
families. 

After spending several hours trying to 
diagnose the ills of the new Z80 system 
with the Micronta probe, it seemed that 
more of the Z80’s data lines were in an 
open state than seemed reasonable. Being 
suspicious of the probe, I studied the por¬ 
tion of the probe’s user manual devoted 
to verifying the probe’s correct operation. 
Using the test set-up shown, I determined 
that a logic low was being indicated for 
voltages of from 0 to 1.8 volts, and a 
logic high for inputs of 3.4 through 5 


volts. Input voltages of 1.8 through 3.4 
indicated an open condition. The manual 
indicated that these levels should be 
within 30 percent and 70 percent of Vcc 
and with an error range of ten percent. 
As a Vcc of five volts was being used, the 
proper voltages should be 0 through 1.5 
for a logic low indication, 3.5 through 5 
volts for a logic high indication, and 1.5 
through 3.5 for an open indication. Thus, 
the probe appeared to be operating with¬ 
in the manufacturers specifications. 

Wondering whether all those data lines 
were in their open state after all, I con¬ 
sulted a specification sheet for a 7400 
TTL NAND gate. This told the story. A 
TTL logic low is defined as 0 through 0.8 
volts and a logic high is defined as 2.4 
through 5 volts. Further, a typical TTL 
gate will produce an output of between 
3.3 and 5 volts. Therefore, fifty percent 
of all good TTL outputs will test properly 
with the Micronta probe; the other fifty 
percent, although perfectly good as far 
as TTL logic levels are concerned, will 
show up on this probe as opens. 

In order to see if the Micronta’s opera¬ 
tions were typical of multi-family logic 
probes, I examined the specification sheet 
for the Heathkit TTL/CMOS digital logic 
probe (model 7410). When in TTL mode, 
this probe will indicate a logic zero for 
voltages of 0 through 0.8 volts and a logic 
high for voltages of 2.1 through 5 volts. 
When in CMOS mode, zero through thirty 
percent of Vcc gives a logic low; while 
seventy to one hundred percent of Vcc 
give a logic high indication. 

Apparently, the Micronta probe will 
only operate properly with CMOS logic, 
even though it is advertised as having 
“multi-logic compatibility.” In actuality, 
the only TTL compatibility this probe 
has is accidental. 

At this point, three options were avail¬ 
able: 1) Purchase a new probe, such as 
the one from Heathkit; 2) Modify the 
Micronta probe to operate properly with 
TTL logic levels; and, 3) Design and build 
a new probe for TTL logic. 

As I did not desire to spend money on 
another logic probe, option 1 was quickly 


discarded. The Micronta probe did not 
come with a schematic. Having no love 
for tracing the probe’s circuit, option 2 
was swiftly discarded. This left only op¬ 
tion 3. 

Circuit Description 

The circuit for the new probe is shown 
in the Figure. It uses two inexpensive TTL 
chips, 1 diode (for polarity protection), 
two capacitors, three LED’s and 3 resis¬ 
tors: a total cost of under $3 for parts 
(less a case to house them). This probe 
will resolve TTL levels properly, and will 
also detect pulses as fast as 40 nano¬ 
seconds. Its two disadvantages are that it 
may only be used for testing TTL logic 
and it will not detect an open line condi¬ 
tion (which will show up as a logic high). 

The first hex inverter provides one 
TTL load to the circuit under test. In¬ 
verter stages two and three drive the high 
and low level LED logic state indicators. 
IC2 serves as a pulse stretcher. Any nega¬ 
tive transition on the input line results in 
an output pulse of about 150 milli¬ 
seconds, which lights the LED pulse indi 
cator. For pulse trains slower than about 
seven pulses per second, the indicator will 
blink on and off. For faster pulse trains, 
the indicator will stay on continuously. 
For single pulses, it will blink once. 

In order to make the indicators easier 
to differentiate, a red LED was used for 
the logic high indicator, a green LED for 
the logic low indicator and an amber (yel¬ 
low) LED for the pulse indicator. The cir¬ 
cuit was housed in the Micronta case, 
with the Micronta’s innards now living in 
the junk box waiting for the day a CMOS 
logic probe is needed. As only a small 
number of components were required, 
the dead bug method of construction was 
used (i.e., the two IC’s were glued to one 
side of the case, with direct solder con¬ 
nections made to their exposed pins). 

Conclusion 

Using the new TTL logic probe, those 
open state data lines were not open after 
all, the processor clock was no longer 
clocking and those 40 nano-second 
pulses looked fine. Within ten minutes of 
using the new probe, the Z80 processor 
was starting to respond to instructions; 
within four hours it was fully opera¬ 
tional. 

David Bertollo is a senior programmer 
for Information Sciences Division, 
Rockland Research Institute, Orangeburg, 
NY. He is involved in the development of 
both applications and systems programs 
for a network of mini computers feeding 
a maxi host computer. Before rebirth as a 
programmer, he was an electronics design 
engineer. -SR 

(Continued on pg. 45) 


Page 42 Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 Number 48 

348 




To enable a program or operating system to verify and 
correct errors in the pointer links of linked record chains, a 
redundant set of links is necessary. This compact method 
uses a ‘forward’ link from each record to its successor record, 
and a ‘cross’ link, which is the XOR product of the previous 
record address and the successor record address. These two 
links are stored in each record. With a typical disk sectoring 
arrangement, they should probably be stored at opposite 
ends of the record, to minimize effects of recording medium 
flaws. 

The major advantage of this method, compared to direct 
forward and backward links, which take the same space in 
each record, is that this algorithm can determine which link 
is wrong, and can correct it. Every record contains, in effect, 
two independent forward pointers (one based on the know¬ 
ledge of the previous record address), and a back pointer (the 
XOR of the two links). 

Because of the asymmetry of these links, verification and 
correction is best done during forward sequencing through the 
chain. Verification consists of: 

Determine the next record address by XORing the 
previous record address with the cross link in the current 
record. This should be identical with the forward link in 
the current record. 

(Note that the XOR of any two of the above values should 
be equal to the third one. The procedure above yields an 


alternate successor address, if it is needed). 

If the test fails, either the forward link or the cross link is 
wrong. The error can be corrected by examining both possible 
successor records, to determine which points back to the cur¬ 
rent record containing the error. The XOR result of the for¬ 
ward link and the cross link in the successor record should 
be the address of the current record. If one of the two tested 
successor records points back to the current record, the er¬ 
roneous link is changed to point to that successor record. 
If the cross link is wrong, it is reconstructed by XORing the 
previous record address with the correct successor record 
address. 

In the first record of a chain, the forward and cross links 
are equal, so their XOR result is 0. The logical address of the 
first element of a chain therefore must be non-zero, since the 
“previous address” is 0. In the last record, the forward link 
is 0, and the cross link is equal to the previous record address. 
Correction of links in the last record is a special case; if one 
successor address is 0, the non-zero successor record is exam¬ 
ined to determine whether it points to the current record. 
If it does not, the current record is the end of a chain. 

This link verification and correction algorithm can be done 
“on the fly” during any file read or write operations, so that 
randomly caused errors in the links can be routinely cor¬ 
rected without any error messages or significant overhead. 
No extra disk accesses are needed, except when an error is 
found 

LINKS.N 


Number 48 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 43 

349 










m > /> o 

’ /UU 


ip |i jif m / 


addend 

M 





BY DENNIS ALLISON 

Many software systems need some 
sort of a symbol table. A symbol table is 
simply a mechanism which associates a 
name with some information. A name 
can be a string or a number. Normally 
one expects the space of possible names 
to be represented as much, much larger 
than the number of table entries. Further, 
there is usually a premium placed on 
finding entries efficiently. 

Just what kind of mechanism is best 
for any particular application will depend 
upon the way the table is to be used 
and what information is to be stored 
in it. Let’s presume we have an applica¬ 
tion where the entries are of fixed size 
and deletions will not be made. An 
assembler is one such application. The 
data can be represented by a structure of 
the form: 

struct | 

char name [8j ; 
int val; 

i symtab [256] ; 

One could, of course, fill this table 
from its first entry and determine wheth¬ 
er a key is present by searching for it 
linearly. If nentries is the number of 
entries in the table, and match is a 
predicate function which returns non¬ 
zero if the keys match and zero if they 
do not, then one can search the table 
with the code: 

lookup ( key ) char * key ; j 
int i; 

for(i=0;i<nentries;i++) j 

if(match(key, symtab[i] .name) 
return (i) ; 

/* here only if fail * / 
return ( -1 ); 

! 

Here we have chosen to return the value 
— 1 if the entry is not in the table. The 


average number of matches for an entry 
in the table is nentries /2 and the re¬ 
quired number of matches to determine 
an entry is not in the table is nentries. 
We can improve upon this considerably. 

For this particular situation a closed 
hashing scheme is effective. We provide a 
special function, hash which maps the 
key into an integer between 0 and 255. 
This function is chosen so that, on the 
average, for any large set of names all 
values will be generated the same number 
of times. As there are many more than 
256 possible names, there is no guarantee 
that the hash value of two names which 
are themselves different is not the same. 

The lookup algorithm then proceeds 
as follows: First, hash the key and find 
an index into the table. If the key 
matches the name stored at that location, 
we have found the entry. If the slot in the 
table is empty, the key does not appear 
in the table. Often, as we do below, the 
key is entered into the table at this point 
and the table index returned. If neither 
of these conditions hold, one must ap¬ 
peal to a collision resolution strategy. 
This key potentially hashes to the same 
value as some other table entry. 

The traditional collision resolution 
strategy is to search the table linearly 
forward (or backward) modulo the table 
size. This is simple but tends to produce 
dense clusters of entries which degrades 
performance. 

The scheme I like uses some properties 
of residue arithmetic and depends upon 
the table size being a power of two. 
An auxiliary counter is used which allows 
one to generate a sequence of values 
which steps through every element of the 
table, but the order of search is dif¬ 
ferent for every initial value. This helps 
prevent clustering and improves the 
performance of the table. The particular 
algorithm used here was published by 
F. R. A. Hopgood and J. Davenport 
in The Computer Journal (15:4, No¬ 
vember 1972). See their article for a dis¬ 
cussion of the theory involved. 


A program which implements their 
algorithm is: 

lookup (key) char *key; j 
int i, j; 

i = hash(key); /* value is 0 to 255 */ 
j = 1; /* used for collision resolution */ 

for (;;) /* infinite loop */ 

/* test for empty */ . 

if(sym [i] .name[0] == ’ ’ )i 
scopy (key, sy m [ i ]. name); 
return (i) ; 

I 

/* test for match */ 
if (match (key, sym [i] .name )) 
return (i); /* found it */ 

/* resolve a collision & test for full */ 
i=(i+j)& OxFF; . 

if ((j = (j + l)&0xFF)==0) | 
error (“symbol table overflow”); 
return (-1) ; 

t 

( 

( 

The function scopy copies the key into 
the designated table location. The logical- 
and operations are used to provide effi¬ 
cient arithmetic modulo the table size. 

Performance of this particular table is 
very good when it is only partially full. 
When the table is less than 70% full, 
entries which are present can be found 
with an average of three probes. As 
the table fills, the performance will 
eventually degrade to a linear search, 
but full utilization of the storage space 
will be made. 

There remains the problem of choos¬ 
ing the initial hash function. What one 
wants is to ensure that the information 
is spread pretty uniformly. One would 
like the string “ab” to generate a dif¬ 
ferent hash than the string “ba.” Lastly, 
one wants the operation to be efficient 
to implement. 

One possibility is 

hash (name) char *name; j 

int v,i; 
v = 0; 

for (i=0;i<8;i++M 

v = v + v — *name++; 

retumtffv^^S)+v) & OxFF); 


This function gives fairly good results. 
On a base of 5000 words it gave fre¬ 
quency values ranging from 10 to 43 
about two-thirds in the range of 15 
to 24. 

Now that we’ve got a mechanism like 
this, we can make a dandy little program 
which counts instances of words. We need 


Page 44 

350 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 






a procedure to fill the key array, call 
it getword. It reads a word from a file 
and places it in the buffer pointed to by 
it’s argument. It returns non-zero as long 
as the buffer is valid, that is, as long as 
the end of the file has not been reached. 

The main part of the program becomes 

wordcount () j 

char the word [ 8 ] ; 

while ( gotwoid ( the word ) ) 

sym [lookup (the word) ] ; 



sym [ i ] .val); 

} 















etters 




THE DEBATE ON TOP-DOWN CONTINUES 

Dear DDJ: 

In DDJ #43 I stated that top-down programming is 
easy in COBOL but impossible in PASCAL. Mr. David 
Rowland contests this admittedly provocative statement 
(DDJ# 46). He challenges me to define top-down program¬ 
ming in a way that excludes PASCAL and to defend that de¬ 
finition in a multi-lingual environment. 

Top-down programming is an approach to programming 
that results in a particular structure in the finished product. 
The process of “stepwise refinement” cited by Mr. Rowland 
should be reflected in three ways: in the logic flow of the pro¬ 
gram, in the physical structure of the source listing and m the 
sequence of preparing and testing modules. 

Necessarily, a program prepared by the top-down method 
is both modular and hierarchical. There is a main module 
where the program begins and ends. There are subordinate 
modules called by it. These may in turn call still lower level 
modules and so on to as many levels of hierarchy as the com¬ 
plexity of the task requires. There are also (in the real world) 
some little utility modules that are called all over the place 
and hence to not really fit anywhere in the hierarachy. In very 
large programs (compilers, operating systems) we may be deal¬ 
ing with hundreds of modules written by dozens of program¬ 
mers. 

I will use as an example a short program consisting of a 
main routine 000 which calls modules 100, 200, 300 and 400. 
Module 100 calls modules 110, 120 and 130. Module 200 
calls modules 210 and 220 and so on. The program also uses 
utility routines 900, 910 and 920. 

Proceeding in top-down fashion, after the general structure 
of the program has been roughed out we write module 000. 
We then write the modules subordinate to it, proceeding from 
left to right and from top to bottom in the hierarchical se¬ 
quence of the program. After the main line module is written, 
there are two acceptable sequences for writing the remainder 
of the program. Usually it is best to sequence the program 
level by level. Our example program might be written thus: 


ooo 

100 

200 

300 

400 

110 

120 

130 

210 

220 

310 

320 

330 

340 

410 

(900) 

(910) 

(920) 


Some programmers would find it convenient to put the 900 
series modules early in the program, perhaps just after 000. 


The second common sequence is the indented order. It 
is useful if the programmer likes to pursue a particular func¬ 
tion to completion before proceeding further. It is also used 
where either the programmer or the operating system is going 
to do overlays to save memory space: 

ooo 

(900) 

(910) 

(920) 

100 

110 

120 

130 

200 

210 

220 

300 

310 

320 

330 

340 

400 

410 


Note that the physical sequence of the modules is also the 
order in which they are written. Note also that the whole 
program is not written at one sitting. There are compilers 
for errors and test executions early in the life of the program. 
Modules called but not yet written are inserted as “dummy” 
routines. 

Now let me offer a nonsensical sequencing of the same pro¬ 
gram, given our top-down approach to its construction: 


900 

910 

920 

110 

120 

130 

210 

220 

310 

320 

330 

340 

410 

100 

200 

300 

400 

000 



This is the sequencing required by PASCAL, XPL and most 
other languages designed for use as teaching tools. In this class 
of languages a procedure must be defined before it is called. 
The main routine that should be written first must occur 
last in the source listing. Given a program of non-trivial 
dimensions this is an almost impossibly clumsy way to pro¬ 
ceed. It also makes the finished program very hard to read 
since you must start near the end and jump around in the list¬ 
ing to follow the source text in any logical sequence. 

Bottoms-up sequencing makes sense if you are writing an 
extensible language. It also allows implementation of a simple 
“one-pass” compiler. But for the serious programmer who 
is trying to produce a good product within a reasonable 
time span it is a miserable restriction. I have never seen a top- 
down program written in any commercial language that did 
not also order the program in a top-down sequence, with the 
main line routine first, followed by its subordinate routines 
in one of the two acceptable sequences described earlier. 
Languages such as COBOL, FORTRAN, PL/I and even most 
assemblers allow top-down sequencing of source code. PAS¬ 
CAL, unfortunately, does not. 

I stated three ways in which the stepwise refinement and 
top-down programming approach should be reflected: in the 
physical sequence of program text, and the order of progam 


Number 48 

352 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Page 49 



development and of course in the logic structure of the pro¬ 
gram. PASCAL prohibits the first and thereby inhibits the se¬ 
cond. I stand by my earlier assertion. Top-down programming 
as I understand the term is virtually impossible in a language 
that requires a bottoms-up sequencing of source modules. Mr. 
Rowland feels that he programs top-down “on (his) best 
days.” I understand how difficult this must be in an inherently 
bottoms-up langauge like PASCAL, and I offer him my sym¬ 
pathy. In my experience, languages developed as classroom 


tools usually do not make good production languages. There 
are too many restrictions (such as the bottoms-up sequencing 
of PASCAL) which make sense only in the classroom. Indeed 
I question the utility of “upside down programming” even in 
an academic environment. Perhaps some knowledgeable 
reader can enlighten me on this issue. 

Sincerely, 2401 Haight Avenue 

John R. Culleton, Jr. Sykesville, Maryland 21784 



Page 50 


Dr. Dobb's Journal of Computer Calisthenics and Orthodontia, Box E, Menlo Park, CA 94025 


Number 48 

353 




Dr. DoBB'S loURNALof 

COMPUTER 

(Calisthenics ^ Orthodontia 

Running Light Without Overbyte 

Number 49 October 1980 Volume 5, Issue 9 

A REFERENCE JOURNAL FOR USERS OF SMALL COMPUTERS 


Even Further with Tiny BASIC 4 

Robert Hudson 

CP/M To UCSD PASCAL File Conversion 16 

Tor Sjgwall 

Extended Source-Text Area and Label Capability for SC/MP NIBASM 20 

W.F. Long 

MFT: A Multiple File Transfer Utility 24 

Lawrence E. Hughes 

A Cross Reference Program for Northstar BASIC 32 

Larry Hudson 


and more ... 


355 





Even Further With 


tiny BASIC 



BY ROBERT HUDSON 

1315 August Drive 
Austin, TX 78753 

No —not full floating point math, which is unnecessary for 
a control language or string functions; but extended —yes, 
indeed. The original Tiny BASIC for the Motorola 6800 
as implemented by Pittman is an extremely small (2K) and 
powerful BASIC ideally suited for a minimum system or 
control application. The original Tiny BASIC has the following 
commands: 


LET var GOTO expr REM 

IF ... THEN GOSUB expr CLEAR 

INPUT var RETURN LIST 

PRINT END RUN 


Variable Names A — Z. 

Operators: 

+ Addition 
— Subtraction 
* Multiplication 
/ Division 
() Parentheses 

Functions: 

RND 

USR 

Relational Operators: 

= Equality 
< Less than 

> Greater than or equal to 
<= Less than or equal to 
>= Greater than or equal to 
<> Not equal 

As illustrated above, Tom Pittman has performed a fantas¬ 
tic feat of programming, considering the interpreter only re¬ 
quires 2K bytes. You may wonder what extensions are pos¬ 
sible for such a colorful and rich minimum implementation of 
BASIC. 

My extensions are: Logicals: 

SET AND 

SET& OR 

GET NOT 

GET& 

CHR 

NEW (CLEAR) 

INPUT “TEXT”” var 
FRE 

The above extensions require only an additional 128 bytes of 
memory. 


Tiny BASIC was originally a concept of Dennis Allison’s 
and was actually the foundation which helped to create Dr. 
Dobb’s Journal. The first few issues of Dr. Dobb’s covered 
the theory of the tiny interpreters. I became intrigued with 
Tiny about a year ago, but had time to delve into it only 
recently. What really intrigued me were the two levels of 
interpretation. By this I mean the tiny BASIC interpreter 
is written in an Intermediate Language (IL), not machine code. 
The Intermediate Language is interpreted (read and decoded) 
by machine language routines. And since the IL is well defined 
with operation codes and addressing schemes, all the user has 
to do to change, alter, or add to a particular version is to re¬ 
define the IL program. 

In Figure 1 is a program written in MITS 6800 BASIC 
(written by MICROSOFT). The program is an assembler for 
the IL code of Tiny BASIC. Because I did want the ability to 
redefine, expand and enhance Tiny, I had to write the as¬ 
sembler to facilitate this. This was necessitated mainly because 
the IL relies heaviliy on relative addressing. A great help in 
understanding the operation and mnemonics of the IL pro¬ 
gram was a book published by Tom Pittman, “Tiny BASIC 
Experimenter’s Kit,” which sells for about $15. If anyone 
wishes to pursue experimenting with Tiny and Pittman’s IL 
program, then this book is a must. In the book Pittman 
has an assembler for Tiny IL code written in Tiny BASIC, 
but it was inadequate for my needs. Therefore, I developed 
my own assembler. In the book Pittman completely explains 
the operation codes and the addressing modes. 

Also included in this article is a listing of the assembled 
enhanced Tiny BASIC IL code to implement the above 
additional functions. This can be found in Figure 2. In Figure 
3 is a 6800 assembler listing of the machine language routines 
necessary to implement some of the additional functions. 
In Figure 4 is a hexadecimal memory dump of the installed 
enhanced IL interpreter. 

I will briefly explain these: 

IL BASIC ASSEMBLER PROGRAM (Figure 1) 

A two-pass assembler, the first pass being necessary to re¬ 
solve forward referenced labels. The source code file is part 
of the program being stored in DATA statements. A leading 
“*” asterisk indicates a comment line. A leading “>” greater 
than indicates a label. The source file is stored from line 90 
to line 840. Following the source file are a group of DATA 
statements which define the operation codes of the Tiny IL. 
The main program loop is entered at line 1030 where an 
option menu is presented. “Assembler pass 1” must be se¬ 
lected first, followed by “Assembler pass 2”. Pass 2 generates 
a .paginated listing as can be seen in Figure 2. The assembler 


has complete error trapping c»«cpt for tiro “SJO 1 op - — t « 

Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 4 

356 


Number 49 




This op code normally has a maximum argument of 7. I de¬ 
cided not to check the argument in order to facilitate imple¬ 
mentation of new op codes. Also the mnemonic for jump was 
changed from “J” to “JP”, therefore making all the op codes 
the same length. The only other alteration necessary was with 
the circumflex or up-arrow. This is normally used to generate 
ASCII control codes by subtracting 64 from the preceding 
character—this is implemented. However, because I store the 
source file as DATA statements it was not possible to use 
the comma in a source line of code because my BASIC 
interprets the comma as a delimiter in the DATA statement. 
I therefore used the circumflex to also generate the necessary 
ASCII code for the comma (lower case L— 64 = 44). The same 
is also true of the colon I had to use the lower case Z. 
This brings up an interesting point also, in the IL code the 

symbol is used in conjunction with the circumflex to 
generate the ASCII null code. There was a slight problem with 
this because my BASIC interprets the symbol as an input 
line delete code. Because of this the user will find in line 70 
four POKE commands which are used to NO OP the area 
of the BASIC interpreter (KCBASIC) which honors the 
as the input line delete code. Therefore, if, when using a 
similar but different BASIC **please**, delete this line or 
change the POKE addresses to agree with your BASIC. 

ASSEMBLER OUTPUT (Figure 2) 

The BASIC Assembler program produces a titled and pagi¬ 
nated listing of the assembled IL code. The listing is complete, 
even including the error code numbers which are generated 
by incorrect operation. The listing provides a self documenta¬ 
tion of the TINY IL code. After assembly the IL code is com¬ 
pletely position independent and only one pointer need be 
changed to point to the new IL code. In other words, one 
may have several IL interpreters in a computer at one time 
and switch back and forth between them just by changing a 
pointer to the beginning of the IL code desired. 

Changes and Extensions: 

Prompt Character — changed from a colon “: ” to the 
greater than symbol “ > ”. 

New — the “CLEAR” command was changed to “NEW” 
to agree with other common BASIC interpreters. 

SET — stores a one byte word in memory. 

Syntax: SET address expression = expression 
SET& — stores a two byte word in memory. 

Syntax: SET& address expression = expression 
GET — returns the value of a one byte word from memory. 

Syntax: GET (address expression) 

GET& — returns the value of two bytes from memory. 

Syntax: GET& (address expression) 

CHR= — outputs the ASCII character indicated by the 
evaluation of an expression. If the expression is greater than 
255 then output is mod 256. 

Syntax: CHR= expression 

INPUT — now allows an optional text string to be printed. 

Syntax: INPUT “text” variable 
FRE — returns the number of bytes remaining in memory 
in which a program can be stored. 

Syntax: PRINT FRE 

Logicals: 

AND — returns the 16 bit results of a logical AND opera¬ 
tion between the two arguments. 

Syntax: AND (first expression, second expression) 

OR — returns the 16 bit results of a logical OR operation 
between the two arguments. 

Syntax: OR (first expression, second expression) 


NOT — returns the 16 bit complement of the argument. 
Syntax: NOT (expression) 

MACHINE LANGUAGE ROUTINES REQUIRED (Figure 3) 

Machine language routines had to be written in 6800 code 
to implement the logical operators and also the two byte 
commands (SET& and GET&). The other commands were 
implemented without additional machine language routines 
being necessary. However, the following is very important 
for custom installation and understanding. 

SET uses the built-in POKE function located at 0118 
HEX. This should be the same for all Tiny BASICS. GET 
uses the built in PEEK function located at 0114 HEX. This 
should also be the same for all Tiny BASICs. 

CHR bypasses the regular output routine in Tiny and 
goes directly to your system output routine. The address 
which points to your output routine should be inserted on line 
37 of the IL listing (Figure 2). Since my system is not MIK- 
BUG, this address currently points to my output routine. All 
that is necessary is to change the source code to LN 265 which 
will produce IL code of 0A0109. Location 0109 being the 
tiny BASIC jump to the character output routines in MIKBUG. 

FRE was implemented wtihout any problem. However, 
for other Tiny BASICs using different MPUs the storage loca¬ 
tions for the limits of memory may be different. As can be 
seen in the IL listing (Figure 2) for the 6800 version these 
are defined as 34 HEX and 36 HEX in lines 224 and 226. 

Logical functions are defined in the IL code (Figure 2) 
from line 196 to 213. They call the appropriate machine 
language routines as found in Figure 3. 

INSTALLATION 

Load your Tiny BASIC by Tom Pittman. Now using your 
system’s appropriate memory change and examine commands, 
enter the code found in Figure 4 starting at 07A1 HEX. This 
will overlay the previous IL code with the new IL code. 
Change location 07F2 HEX from 07 92 to 01 09. This will 
permit the CHR function to use your output routines which 
location 0109 HEX should be pointing to. 

Now change the breakpoint jump located at 010C HEX 
to contain 097A HEX. Add at 097A HEX the following: 
7E 07 6A 7E 07 8D. 

Now change the following pointers in the Tiny BASIC 
program: 

location 01FE HEX change to 07 BC-points to IL code 
beginning 

location 0201 HEX change to 09 08 - points to program storage. 

This concludes the installation procedure. Now begin the Tiny 
BASIC interpreter at 0100 HEX and have fun. 

REFERENCES 

1. TINY BASIC User’s Manual. Available from ITTY BITTY COM- 
puters, P.O. Box 32189, San Jose, CA 95153. 

2. Doctor Dobb’s Journal, Volume I, No. 7 

3. TINY BASIC Experimenter’s Kit. Available from ITTY BITTY 
COMPUTERS, P.O. Box 23189, San Jose, CA 95153. 



LISTING 



Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 5 

357 




H CO* > 

<n a a 
z a a - 

i-3 a X) 
*05 n 
: Oh 
-a * 2 n 


<Ti s E-* * Cm 

a «H a * 
n t OJ O "T 

‘ 2 fN a r Jxn 

X J a X U 33 X 

a E-< - a a o a 

XK r 25 ‘Fn Z J 


s £h 05 Ph £-« s 
05 q, X 05 || 

« - X ‘ *r 

r U vo cn 


J 

-2 

*— 

33 33 2 

M 

O 

- 


n 

X 

a 

a 

£> 


C/3 — 

C-H 

‘03 fn 

U 

2 

2 

in 

* - 

a 

- 

u a 

a 

C/1 

D * 

3 

03 U W 

u 


a Eh 

a 

2 


2 

a a xr 


n 

- 

2 

-O 2 u 

A 

a 

2 2 

A 

U 4-2 

II 

‘ - X 

u 


r 05 

2 

‘Os 

- 

a 

a ‘ 

- 

O rH 

w 

2 

= 2 A 

a 

m 

— 0- 


05 Q 

nD 

2 

* > 

H 

‘ 2 

2 


V A ‘ 


fN 

s X 

Eh 

04 < 03 

r- 

a 

a 

2 

05 


O S s F-» 

m fh 

Cl4 

w 

J 

X 2 

fN 


n « 


a o 

« 

X 

X 

a a 

A 

* 

u 

33 s Cl* 


03 

a 

in 

x < 



m - 

A - 

- 

2 


— 

2 


a a 

a 

u 

u 

05 a rH 

‘ H 1 

O 

U 

u 

03 HJ U 

J 

2 

u 


u 

a 

a 


Fh 

■o 

33 Eh 

33 

n Eh 33 


0 

33 > 

2 

o) a 



u u a 

a a 


(7\ o 03 H Ei a a n u 0 a a 
u 2 a 

CN 2 tN fM: aaaan-»r,^a0aOrH' 

2 h a a U U aaaa<aa 05 a 

J A « A A * A A * AAAAAAAAA 

<<<<<<<<<<<<<<<<<<■ 

EhEhEhEhEhEhEhShchEhEhchEhShEhEhEhchI 

<<<<<<<<<<<<<<<<<< 

000000000000000000 

000000000030300300 
n^in£ir'XaiO’Hr\n'^in c h b ^ 3 , 

^vo^o^vO-o^r'r'r^r^r^r'r^r^r^r^x 


■q^' 

2 Eh 

h a O 
+ * Eh 

O 2 A 2 

II UJ II V 

2 2 <A =h I 

a a 2 

£h < Eh m : 

oj y a a a : 

j a j w a 1 

3 0 0 0 0 

x x j\ o ' 

ao x qo go <y\ < 


UH2H, 
fN a h 1 

a a ‘ a < 
0^0 Q 


‘HW>Eh DH 
04 K Q a X 
a * * * * </> 

I - 0 X5 n m q 
HtMfNn'f Q 




tN 


_ 



- 


fN 



a 


\ 








t/> 


o> 

o 


a 


H 

n 





o 


v> 


rr 

rH 


Q 


a 



M 


a 

o 


z 

o 

«— 

Eh 


II 

r- 

+ 

c 


l/> 

(N 

u 

o 


X 

rH 

ii 

•• 




u 



Eh 

o 


2 


a 

Eh 

Eh 

M 


a 

5 

a 

a 


•• o 

o 

a 

a 


O 30 

•• 


•• 

2 

oo m 

o 

o 

Eh 

2 

00 rH 

00 

CO 

2 

II 


00 

o 

M 

<A 

a 

rH 

m 

a 


a 0 




a 03 
03 3 3 

Q 03 UJ 

OOO 
U O U 


rH 

<H 

W rH u 

a 



an 

II 

H || 

X 

a 

2 

U A O fN 

a 

o> a x 


o 

a 

a Z rH 


EH O 0 O 



a 

ZD *H 1/3 

Eh 

a CO to 30 H 

rH 

0 

Eh 

O « -H U3 

a 

a fN o :n a 

rH 

2 


mo » < 

a 

a ^ u ^ a 

V 

£ 

in 

S O 0. 

•• 

ii a •• 

n 


in 


• — H J D J, 

in .. a, 03 03 

S 2 : II O 03 o 

2 O 03 II 

• Eh Eh -3 < U 

:2 a) 5 

J M 04 Eh 2 : :-l 

• X 2 03 2 03 03 

. a M 0 O a J 


iaz2zo« 1 

O 4 03 03 03 O ->0 O 4 i 

H H H ? ^ ' 

03 O 4 < o 

Jr 2 2 0 Eh <"'■> | 


H H Eh Eh 
' O 03 

1 » J * 2 2 

fN •• * A 03 

I tN </>! 2 2 

03 II II II 
1 03 </>'•/></> 

0 0 O 4 O 4 O 4 
; 03 < 

1 O 03 O 4 O 4 O 4 


03 II II II 03 
3 <✓> v> ca 0 Eh 03 : 

D 0 04 O 4 a 2 3 

03 < S h w : 

0030-040403050; 

o2MMt-.2a,0; 


>0000000000000000000000000 
i^uOsOr^oocyiOrHCN n n o r-' :o o .—i n n h- ..0 o p" co 
• OOOOOOr-Hr-HfH HHHrHHHHNN N .N N "N tN N N 
IHHHHHHHHH HHHHrlHHHHHHHHHHH 


ii 

g 


u 




2 

3E rH 


M 




a 

Eh ‘ 







Eh 'T 


< 




Eh 

M -T 


a Eh 




a 

a o 

oi 

a 




a 

rH 

r- 

a Eh 

2 


X 

•• 

Z a 

o> 

o a 

II 


rr 

n 

o X 

»H 

00 

s a 

X 

m. 

v£> 

Eh O 

s 

X 

a S 

2 

a 

11 

a 

sO 

a 

* X HI 

* 

a 

a 

0 .. 

rH 

a ‘ 

a S 

a 


a — 

a rH 

\ 

Eh O 

u 

a a 

a 

m 

w - 

a 

m a 

a S rH 

a ‘ 

0 

Eh rH 

a n 


s 

‘ II Eh 

x a 

» 

a — 

M T 


a 

* X e a 

a 0 

a 

a o> 

0 O 


2 a Eh 

2 a 

- 

0 

•• a 

O rH 


M - X 

> -a 

a * 

4. 

in - 

s a 

U 

a Eh 

a > a u 

n 

* 


II X M 2 C/3 03 

2! O Q o C/3 2 03 - 

EHO204 <OEhJ25 

rH < •• 33 C/3 Eh 0 03 

Eh rO Q M - - 

a 0 0 ‘0X0X2 J 



rH 

a 

- 

a 

fN 

a 2 

a 54 w 

01 

X 


•• 


U 

M M 

_ 0 

- 

X Eh 

a 

Eh 

in 

o 


O 

a Eh 

h a a 

Eh 

‘a 


a 

n 

o 


rH 


a a t 

z 

3i a 

2 

u 

X rH 


a 

a 0 

a a 


2 

a 

M 

a 

>— 

2 

X 

0 a 

a a u 

in 

‘ u 

Eh 

a 


o> a 

O o m 0 z a 


a a 

Eh 

X 

Eh 

a 

2 

a 

u a 

a a 

2 

a 

M 

a 

a 

- 

II 

•• 

M 

a Eh 

a 

Eh 

a 

o 

a 


'/> rH 

a a 

x a a 


u z 

3 

U o 

•• 

rH 

a 

‘ 

y o 

a < Eh 

O a Eh 


03 X 33 b 

* 03 - Eh 5 

« s 03 

03 Eh 03 5 

03 03 J Eh U C 

33 03 C/3 03 A 3 

‘2 ! 03 * 5 

05 Q U O 


* 05 

* G 4 : 

II 03 x X 1 

05 03 0 03 

J ‘U 5 

U 05 2 03 . 

2 04 n : 

05 X Eh * 1 

O 4 O 03 2 s ! 

X E- «0 

03 O 03 0- Eh ■ 

On s 




2 

a 






n 

4— 

a 



m 



M 

rn U 








4- a 

a 


o 

X 

2 


a 2 

n x 

n 


Eh 

a 

*-r 

a 

a ♦— 

4- 

- 



- 

a 

< 

— rH 

o. 

2 


05 

m 

o 

> 

2 

4- rH P3 

II 


a 

a rH 

2 


M 2 

^ a ‘ 

2 

2 


£ a X 



o 3 rr J rH 35 2: 03 J X 03 

II — fn ^ 3 * * A A A A 

X X O </v m o O * 
2XQ504CEHrH03 <<<<<< 
<<< 03 < Eh cH Eh Eh H T-h 

Z:S 0 EhZEhXZEh<<<<<< 
y x ja]Hyo4<oaoQQQ 
22u jq jii,2a 


= r-< 2 
M H 

E u S 

2 33 

-H M - U 
O 4 05 33 
U O 4 

35 33 X Eh 
3J 03 04 
- O- 2 
2 H 03 M 
04 a n a 


* ir» - < 

O tj- m . 

1 O4 M A 2 

- 03 2 * : 

: 2f- 
1 - * -H 03 ■ 

33 s 33 

1 ai yj : 

m c : 

I * M M 
I 'J A I 

33 > U - ! 
a a fN 

1 in *—1 ■ 

I M M M 05 , 

A A A 33 


C/3 ^ 05 2 

S 4- 33 5 

- ^ - 05 
*2 n 2 

J 

U U 05 

33 O 4 03 03 

- 33 J 

X rH -U 

0 J X 

2 A a U 

03 - X 33 

s fN 0 

J 2 

Eh 03 3 

01 03 n 0 ^ 

H 3) A Eh 

J ‘fN - Z 

: J N » 
U Eh A J 2 

0 0- 5 

H X 05 03 
0 J 2 33 2 
2 = - - = 
03 J * 

a 2 2 4- Z 

- 0 - rH 03 

X 05 r 2 05 
2 4- 

- U 03 * U 
03 33 s 33 

05 U 

- Eh U 33 05 

* 03 O 4 03 

t-H «■ 'A 

03 J 03 J U 

33 A J A A 


fc = g 5‘ 

Eh n 
n U fN !N E 
03 < Eh : 

A (14 A 2 t 
- »JC 
•H 03 O ‘ 

03 n Eh > c. 

- 0 - I- 

05 2 05 ‘ 
33 * 33 ^ t 
‘s ‘on : 
D > CO 
03 H D fN 3 
‘Eh -ns 

$00^0 
a a < J r 
Eh 0- ‘ r* 


05 n a 

O 4 «N 

X 0- Al 

Eh 02 Al 

05 05 

- 01 Eh 2 31 A 

03 n * — ‘ * 
2 ‘ ‘2 n 2 

-ro) Ol 

O 4 —' D fN <3v r 

O 2 - 05 rH 

‘ s O 4 <N 
o « — X 2 05 
= 03 J CL 
2 'J ‘X 

J 3) * 2 r 03 


<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<C 
EhEhEhEhE -, EhEh&hchShEhchEh Eh ™h Eh Eh Ph Eh Eh Eh Eh Eh Eh Eh Eh Eh Jh Eh Eh Eh Eh »H 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
0005000000000000000000000000000000 


O O O O t 

H N n . 


o o o o 
I OH N 


OOOOOOOOOOOOOO 0300 O 000300 0 00D0003 
’ftiivor^cocNOH'Nf r )’Ti/iXf N x^3-(N rr ''T'.n 3 r* x t r h fN n t 1/1 r 

HHHH-H-H'NfN'N'NrNfN'NfNfN'NXnX'XXXnXXXT'r'T'JT'TT 


= 03 Eh Ex4‘rHO)_33)*tr3iJ 

S n -T 02 - - - —r 

33 ‘ 03 rH 0) Eh 03 o -a 0) o * Ur Os 

25r A 03 n A n 2 ^ 05 33 2 

s I - - - * Q5 - 3)03‘rH< = 

s 2 05 2 '-4 2 2 > rH J 0 U 05 = 

Eh +33 I f J \ 03 Cl- ‘X 05 o, -H 

JOS -2 <2 0 -A 03 < X <N O. 

t4&3 Q C 14 U 4 O-QO 33 fN N5 
Q ■*T<n fN < fN - fN 0) a a 
U 03 ‘ 03 01 Eh U -O 4 OO 4 - 3 S 
U 33 X n 3: as 01 -'—Us 

32 u 2 u u cox -uuaa- 

0533U31S33EHr-33043105z 05 

21 Eh 2 U-0 z <<00 

33X0 fN w H < O-OJ = rvj r 
iJU03JEHEHCi42b4>Ci4 03 d- 
AAAnAAAAjA0An* A * 

Eh Eh Eh Eh £h ch Eh E-h Eh Eh Eh [h E-J Eh £h Eh 
<<<<<<<<<<<<<<<< 
OQQQQQQQQaQQQjaQ 

OOOOOOOOOOOOOOOO 

r- co :n o r^ r\j m tt ;n X) r» T) o\ o h (\j 
'TTr^-nminmoiinuninininvO^CJ -o 


Page 6 

358 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 




00 

fN 


+ 

X 

II 

X 

2 

x 


3 

2 

5 


o 

u 







■^r 



0 H 
















a 

















s 0 yy 






























— 



s M 3 
















< 

















II Al || 

































yy — 






2 



2 





0 
















yy 



Eh 2 M 






X 



2 





II 














0 


C 



X * 






3 



3 
















0 



0 


0 



Eh 2 fN Z 






Eh 



H 





x 


u 









U"1 



0 


v 0 yy 



X H + X 






X 



X 





3 


2 









a\ 

2 


CN 


O Q 



X 2 3 






2 



2 





Eh X 


o 









H 

3 




fN M 



•• HT * H 






•• 



•• 





X •* 












h 


O 


Z 



m o' yy x 













2 

X =_ 


in 









c 

X 




2 



+ 11 x 2 


M 




3 



3 




2 













2 


O 


X X 



2 x 


+ 











D 

M 3 











0 

•• 


O 


2 < 



11 yy 00 7Z 


O' 




s 



X 




Eh 

+ < 


X 










H 


•• 


Eh > 



H 2 3 fN x 


II 




II 



II 




X z OX 



s 








•• 

+ 


M 


II 



M M M 3 


O' 




2 



3 


O 


2 

1 2 


M 




s 





H 

X 


+ 


— O > 



Eh - Z + Eh 














= II s 


X 




Eh 





+ 

II 


2 


cn r" 



X — 2 X 


H 




Eh 



H 


O' 



3 - 






2 





X 

X 


II 


» ov H 



X — m 11 r— 


X 




X 





M 


X 

Ch 2 — 






x 





II 



2 


— MX 



•• M •• X fN 


X 




X 



X 




X 

2 — 










s 

04 

Eh 




3 X 



— * ny M 


•• 









O 


Eh 

m Eh yy 






Ip 




3 


2 


Eh 


w 2 •• 



M 2 vO H A 


0 

0 



2 



2 


H 



2 3X0 


u 




~ 





Eh 

X 


X 


A3- 



- * 1 X X 


O' 

O' 

— 


X 



X 


O 


X 

2 X X fN 


M 




3 




—t 

X 

•• 


X 


O X — 



2 y> x x 


O' 

O' 



2 





3 


2 

•• •• [-H TT 


cn 









X 

M 




— O M 



- x 11 2 


M 

M 

X 


Eh 



H 




V 

3 3 M fN 


<e 




3 






•* 


2 


yy U - 



yy —' x 2 m 




1 


X 


X 



O 



Eh * 


3 

3 



2 





2 

r 


X 


H •• 



x yy 2 X •• 


2 

— 3 

2 


H — 


X 



II 


z 

Eh Ph —' O 



O 



3 





X X 

** 


2 


2 **• «■ 



3 x 2 yy 


3 

X 3 



< 3 



3 


3 


Eh 

X X 2 O' 


>4 

3 







x 

2 O 



O H 


X = — 



yy m re h x 


X 

1 X 

X 


3 — 


< 




X 

+ 

X X X f~i 


2 




X 





frH <5 2 


CN 


X X »-3 



3 z Eh + 


O 

2 O 

*. 


DA 


X 

yy 


H 

O 


2 2 X fN 


M 

j 



3 





X 

Z 


O s 


II 3 ^ 



m * vy yy 


3 

-3 

yy 


X 0 



X 


X 

s 

3 

•• •• 1 


Eh 

M 



3 



s 

M 

X s X 

M 


CN 


yy O yy 


0 

Z U <- X H 



X •• 

X 


II 


2 

II 


X Eh 

+ 

Eh Eh O O 






3 



X 

3 

U X 

X 


s 


X u 0 


2 

II X = II II 


2 

- 2 

— 


Z yy 


O 

yy 


•• 

-T 


2 2 vo m 






O 



X 

X 

< S z 


X 

2 A 


*—* 


M 

yy < 11 — yy 


II 

y> 11 

y> 


0 X 



X 



O 

3 

M M —* CO 


3 X 






3 

3 

2 II 

2 ^ 

X v 


X 2 2 yy 


2 

3 II — M H 


X 

X X 

3 


2 

O 

T 



s 

u 


2 2 u fN 


X 

3 






< 


X — 2 

M < 

2 — 


Q M 0 3 


Eh 

X M •» 



— 

M 


2 2 r* 

O 

2 


X 



2 2 2 - 



3 

2 



-r 


Eh 


rv ^ 9 


2 

H ■■H 


0 •• = M 

5 

X 

H ‘H H 


Eh 

yy h 

z 


M 

fN 

M 

M 


3 

2 

2 

•• •• in 0 



< 2 



X 




X *■ x 

2 

X 

* 


Do Z 

2 


y h h + 13 


X 

3 X 



X •• 

fN 

H 

•• 


X 

0 

M 

z z ^ 




3 



3 


3 


2 04 a. 0 


— 2 


^ H — 

3 

Eh 

X X 2 X 


X 

M X 

X 


3 3 


< 

< 


2 

M 

• • 

3 Eh yy cn 


2 


Eh 



Eh 



3 

- X 

2 

O 

yy * 


£ ^ 55 X Eh 

X 

•• X 2 ' •• 


•• 

z •• 

< 


X 

O 

y 



> Eh 

M 

X <N 


O X 

X 


X 



3 

X 

O 

fc-4 

X </y 


C O m <1 X 

X 

0 •• * yy 0 


X 0 

II 0 

> 


< 0 

H 

0 

O 



< 

+ 

O O X 


2 

3 

X 


2 

X 



3 

„ W H 

X 


w X 


Eh 2 > 

X 

Eh 

fo m yy x 0 

O 

H fA 

— rr 

II 


> Eh 

O 

X 

Eh 


O 


2 

EH EH Eh 0 


2 

O 



M 



>4 

s 

2 2 


2 

2 w 


3 2 + 

•• 


O' + X — Ji 

O < J' 

D O' 




3 




2 

M 

X 

m 


x 3 cn 


x 

N 


m 

X 

HA M 

s 

M 

X yy 


2 'H •• U > H 

M2'— y> m 

M 

3 M 

—* M 

O' 


H M 


H 

M 


s 

3 

II 

M M Eh O 


s 

- 

II 


s 

|| 


s 

s 

X Q 2 2 


X 

X Q 

*4 

M II II 

II 

X 

II yy 3 

fN 3 

yy 


2 

X II 

3 

X 

II 

3 


< 


II II 3 

2 



2 



2 




X M 2 O 4 

Eh 

X 

A M 

2 

2 >-D U 

X 

3 

2 2 3 m X 


X 3 

O' 2 

O' 

3 

3 3 


3 

3 


Eh 

X 

X 3 3 r-H 

2 "-H 

Eh 

r_, 

X 

Eh 


X 

=h Ph 

Eh 

Z 3 

2 


2 Z 

3 




X m Z 3 O 

3 

3 


3 


Eh 



H 

2 



2 Z 

3 2 

pF 

2 



2 


2 

2 

2 

Z HZ 

y 

z 


H Z 2 X H Eh Z 

X H Z X 

H 

Z X 

Eh X 

Eh 

H Z 2 

X 

Z 

2 

X 

M Z 

Eh 

2 2m 

Eh M 

M 

M 

Eh 

M 

M 

Eh 

M 

M 

M 

y jj y y 

2 

a 

2 2 

X 0 X X 

X 

a 

3X220 

3 y 0 

X 0 

X 

X 

X 0 

X 

X 

O X 

2 

X 

X 

0 0 2 2 

X 2 

2 

2 

X 

2 

cz 

X 

X 

2 

2 

2 M 2 2 

2 

2 

M M 

2 cz. Cm 2 X X 

2 

O X M M O 

023 

X 3 

X 

X 

2 2 

2 

2 

2 

2 

2 

2 

X 

2 2 2 0 

2 x 

2 

2 

X 

2 

X 

X 2 

2 

2 


§ 

3 


[-4 

x 

x 


oooooooo 

W O' ^ (T\ OO 

HHHHHH(N(N 


3 0 0 0 0 0 0 
-\i o o .o r~ :o 
o o o o o o o 

IN IN (N| fN (N fN N 


oooooooo 

O'OHfNM^O'.O 

O M H H H H H H 
*N 'N (N (N IN fN (N 


OOOOOOOO 

r^xoioHN fV ''r 

Hnn-N^N^r^oj 

rN<N<->jrM(N?N(N<N 


o o o o o o o 

3 i 0 D J\ O H 
m n in in in n n 
fN IN <N IN <N IN IN 


o o o o o o o 
in ^ l'i o r- oo 
ro n f’l 1*1 n ro 
IN IN N N IN N N 


o o o o o o o 
O' o H IN ^ t ^ 

NINNININININO 




H 

2 

H 

2 

04 


E-’ 3- 

3 


23 

— H 
U 

3 Eh 
< 2 


. 2 
i a. 


a 

3 

3 

o 

3 


< 

e 


II 

.3 


• X m 
•*</> X O 
-tfl-ao: 
-i *2 OS 

^ a x x 
~ < 

§S Q 

E-» 


. Jd 

• < H 

M M «g 

O S S ’ 

■n x 2 h 

■^2X2 
3 •• w 
< V> Ch m 
E-* 05 3 0« • 
M •• 
H H J H 
2 2 2 
H M Z M 
X X X X 

x x X x 
o o o o 

O'OHN 
N ro m m 


r—4 





Eh 

3 



< 


2 

Eh 





H 

M 





yy 

y> 


3 

X 





yy 

Eh 


3 

Z 


M 

M 


z 

2 


II 

2 


yy 

•• 


X 

— M 



M 

3 

Eh 

Eh 

Z 

X 

X X 

M 

X 

II X 

3 


X 2 

3 

O 

•• 

X 

O' 

Eh O 

3 

Eh O' 

X 00 

Q 

Z M 

X CN 

2 

X 

.. rN 

2 

Z 3 

< 


3 3 



ii 










O 



Eh 


3 










Eh 



z 

O 

Eh 










O 



X 

r-' 

X 










3 



X z 


2 













-2 

M 

•• 










• 4> 



+ 3 


yy 










S 



U Eh 

c 

X 







X Eh 



X 



II X 

£ 

II 







a 2 

O 


X 



3 2 

0 

yy 







0 x 

r* 


-y* 




3 




O 




u 5 

O' 





H X 





r- 





M 


X 


O 

X - 

0 

Eh 



in 




2 O 





r- 

X * 

M 

X 



■ — 4 

O 



O 3 

3 


X 

3 


•• II 

fN 

X 


O 


r- 




3 

O 

Eh 

II 

M O 

0 3 

fN 

•• 



3 

m 


O 

X X 

3 

r* 

< 


m 

ao 2 


0 

3 

3 2 

3 

M 


II 

3 3 

c 

O' 

3 

< 

O O O' 

O O 

3 

0 

X 

M 2 

3 



O' 


3 

M 

M 


Eh cn M 

fN 2 

3 

O' 

3 

3 

O 

3 



Eh Eh 



X 

X 

0 0 

2 

3 

M 

3 

3 Eh 

3 

3 


Eh 

3 3 

2 

3 

2 


3 ai 3 

3 X 

O 

2 

2 

3 X 


3 


X 

— 3 3 

X 

3 

3 

Eh 

•• 3 

3 

3 

2 3 


3 2 

2 

0 

O 

X 

M Z Z 

3 

3 

O 

X 

0 3 3 

3 X 


II A 

Z 2 
X 
H 

X X 
X w 


O U 
H'J X 
II "2 3, 
HHiu] 
2 3 

Xh^S 

sras 



_i 

U U5 tn EH 
o as o ui 
n < j at 
O' •• 3 * 

H H ^ O : '-4 > 

X II a! II o X II o 
aOHXv>Ay a ii 
^ _ x > x > 

3 Z 


'A M X 
II ^ 04 

Z c“4 Jh 2 W £h t— Z-t X - H [q 1,4 r-i 'h XZ 

aaxxxaxxjiyoxxAxaxaaoyxxaoxaoxaaoxyiaxaa 

X2MMMXmmX2 3MMMMX22XX2mmX3 1 -'XXm2X3mXXmz2 
oooooooooooooooooooooooooooooooooooooooooooooo 

“'^jiJp‘X3\o^|'| p ''^lfl'Ol x M5\OHN |y l'Tiflai N S3'OHrN r ^'T-flOr s Xj\3HNn’j ^ fs x 
i*n , 'n(*'f>ii»)i^4j^Tr^N , 'rNi'i"ijN , tni/'i/iina„'ii/' ni/'ina'asO O ooo o-oor^r^-r^-r^r^r^r^r^r' 

—l -—4 ,—i —I < I.—lr-4^H 


O WJZ 
II 

03 || -— 2 2 v> 
m 04 yy •• •• 3 

H HOO'— 
3 X Eh Cm 'n 2 
in j 03 03 r- 03 
< •• J J h h a 
2 O •• II A 

II M </> 2 2 04 

3 I O4 03 03 

2 xrti4 

Eh Eh E- Eh H 

03 o 03 

J E 1 Js S M 

.. .. fN. A + 

OHV>j s O, 
II II 3 A V || 

< M (AWO, 
3 Cm X 

Z-H * < Eh 

03 O 03 O4 O4 03 

X X 2 


o 

3 


03 !N 
2 I 

£h 04 


l </> 2 

— 3 Eh 
yy ~ < 

3 yy y> 
o — a o x 

O 2 H tn H 
3 03 Z — 

H 4 || H 3 
y> 11 — x 

2 a x x yy 

3 2 J Eh 

3 Eh X X 

O X 03 3 X X 

3 X X m 2 


+ O' 

< H 

II 

< 3 
3 

h in 
X o 
2 3 


un o O 

H I/J O 
(N O 
3 2 
2 •• X 
0 — 2 
03 fN Eh 

O * 

C H 00 
*■ rsj 
2 'AH 
03 C/3 II 
2 X 
Eh y> 

> Q X 

r S 4—4 4—4 

X z •• 

S II > 

H v> II 
(A X X 
X 


o c 

O H 

o 

2 Eh I 
X X . 
2 1 
Eh eh ; 
2 
CO M 
cn X 

M X 

II » 
x EH 
2 
X M 

c x 

X 


X 

3 

3 

8 


Eh 

II 

X 


X H 
3 X 
Eh X 




3 

a 

O 

3 


a 3 
z 0 


00 


< 3 


M 


•• 

X 



x — 


Z 


•— VO 

yy 

X 

3 

yy m 

3 


3 
Eh 

§ 

w 03 

x 

eg 

2 <A W Eh 
< X *‘2 0 
Eh^: .. O 

yy v> X 
hnAh^i: 73 2 
II X X o 
M2 Eh X Eh Eh X 

0 2 2X22 

X 2 < M M M X 

032X2X03 
2 x m 04 x ai 


2 - 


O o 

Eh 03 


o o 

X o 


•* \ 

— Eh 

10 Eh 
M 2 
\ M 
X II 2 

— x X 

Eh O 
2 H Eh 
M 03 g 

<J> •• •• 

2 X Eh 
II II 
H Eh X 
2 

M Eh Eh 

2 X X 
xxx 


o 

Eh 

X 

2 

v> Eh 
X II 
II X 
</v 

Eh Eh 
2 X 
2 Eh X 
O 03 •• 
Eh X W 

So5 

•• o </> 

— OH 
T» M || 
M <A 

2 H 
O 

X Eh 
O X 
O X 


— \ 

— Eh 2 

VO O 

M H X 
\2 O 
X M 0 

— || .. 

H X X 
2 * 

M H VO 

-X AO 
v> x <N O 
2 •• I o 
II X H M 

y> 11 11 
X H x 2 

o 

Eh H Eh X 
X X X g 


XXX 

OOOOOOOOOOOOOOO 

3'OHN' v 'Tji/'vOr'Xa'OHN' v ' 

r'00i»co»xcocoa3»coa'3'0'0' 

1 4 1 4 1 1 4 1 4 1 4 i 4 1 4 1 4 1 4 * 4 I ■ 4 I 4 I 4 .—4 -1J 


Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 7 

359 





_ FIGURE 2 _ 

Enhanced and Modified 
TOM PITTMAN’S Tiny Basic 































£h X 

a < 
















§ 






X 






X 

























a 

> 
















X 



s 



Eh 






X 

























2 

















Eh 



Q 



X 


X 




X 



















X 






M 

X 
















y 



2 



M 


X 




X 



















a 






X 

Eh 
















X 



a 



X 


a 














X 



X 






M 







X 










X 






X 



X 



X 


a 




X 




X 


• 




<- 



46- 






X 



X 



2 

a X 





X 




4- 














X 




M 

X 





X 




rH 



N 









2 



Eh 

Eh 

- 





<- 




a 






Q 



Eh 



2 






X 

Eh 



X 


“ 



a 

X 



X 




X 


Eh 



a 



a x 






a 




x X 



X 



2 



X 



D 


« 




a 

2 








M 








a 


a 



X 



X 


fN 









a 



«- 



a 



M 



X 



X 




M 

a 


■<T 

a 





a 



sO 




X 


2 



Eh 




X 

H 





fSr 




a X 



a 






X 





U 



u 

X 

a 


a 

a 

a 



X 

a 



a x 

« 



a 


M 

X o 

X 

X 



Eh CJ Eh 






X 




a a 



X 


* 

u 






L) 


X 

x 



X 









X 




<- 







a a 

a 




s x a 

u 















X 



u 



X 



X 

a « 




o 

a 

O 

u 

a 

u 


H 


u 


fN 

U X 

a 



X 

a CJ 

* y 

X 

a a 


Eh 

a 

X 


> 


T 

U 


H* 

a U X 



sO 

fN 

a 




X 




fN 

X 



H 

a 

X 

a 

X 

X 

X 


a a 

X 


a 

X x 

X 



•o 

a 

X 

a x 

a 

M 

U 


X Eh 

2 



X 


a 

a 


a 

a 

x a 



a 

a 

X 

2 

« 



« 


Eh 

X 

a 













H 
















a 

M 

a 















Eh 



Q 



X 


o 

a a 

& 

o 

X 

u 

o 

X a 

fN 

X a or X x 


Eh 

X a u so a 

X 2 

X 

a 

X X 

X 

U a X 

a 2 

X 

a O' fN 

X 

a a a 

a 

X rr a 

> 

§ 

U X so 

x a 

a 

RS 

x 2 a 

X 

a 

a 

o 

^ X 

O 

u a 

X 

a 

x a 

a 

2 a 

a 

X 

X 

a 

a 

x a a 

a 

2 2 a a 

X 

M 

•O 3 

X 

M 

2 

a 


a 

a 

M 

X 

X 

a 

sJ 

X 

X 

a a 

X 

X 

X 

a 

2 X 

X 

2 a 

X 

2 

X X 

A 




A 


A 


A 

A 

A 



A 

A 



A 

A 



A 


A 




A 


A 

« 

A 


A 



A 




A A 





A 

A 



A 



A 












































o 

a 

fN 

a 

h- a 

sO 

r- 

CO OS 

o 

a 

fN 

a 

•—1 

fN a 


a o 

r* 

00 

OS 

o 

rH fN a 


a 

SO 


00 

Os 

O rH 

fN 

a 

•4T 

a so 


00 

os o a 

fN 

a 

■*r 

a vo 


00 

Os 

Q 

a 

fN 

a 

TT 

a 

so 

f" 00 

Os 

o 

o 

O O 

o o 

O 

o 

o o a 

a 

a 

a 

m 

a a 

a 

a 

a 

a 

a 

a 

SO 

SO 

so so 

sO 

SO 

so 

so 

VO 

VO 

r*. r- 

r» 



r* r* 


r* 

r» oo 

00 

00 

00 

CO 

00 00 

00 

00 

00 

OS 

os 

Os 

O' 

OS 

os 

os 

O' OS 

os 

a 

a 

a 

a 

a a 

a 

r J 

fN 

a 

a 

a a 

a 

a 

a 

a 






























HT 





















































Q 

















a 


































a 



a 

















a 






-=r 




























U 



a 

















a 






Q 


fN 





'T 





















a 



o 







a 










hT 



T 



a 


u 





Q 





















N" 



a 







O' 










a 



U 



a 


m 




fN 

a 


















so 



00 



a 







o 










a 



a 



os 


in 




Q 

N* 


















U 



HT 



T 







fN 










HT 



H 1 



■«r 


a 

a 



o 

Os 



X 


fN 




U 



< a 




a 


os 

a x 

a 

N 1 



Q os 


fN 





a 




U a 



U 



fN 



a 



U 


in 

a 



a 

nr 



X 


< 




< 



X os 




a 


H 1 

a os 

a 

a 



O H- 


< 





a 




< a 



< 



a 








o 

o o 

■o 

•o 

o 

a 

a 

H X H Q [k H 

oo 

a a 

fN 

a 

a rr 

o 

a 

Q O O 

00 

a 

o a 

o 

•«T U Q 00 Q 


fN 

a 

O 

o 


H 1 


a os 

a o 

a 

a 

fN 

Q O 

Q os o 

a 

Q a o 

X co u 

00 

a a 

rH 

rH 

os 

00 

a 


oo 

WHOO 

fN 

a 

so 

00 

fN 

a 

00 fN 

a 

fN a 

a fN 

■o 

os 

a a 

a 

00 

a 

a 

a os 


CO 

fN 

< a a fN cn 

a a 

oo a 

a 

a 

30 

H 1 

aacoyaacox 

fN 

Os 

a 

X 

a a 

CM 

a 

T 

r* 

X 

U Q X o a a 

H 1 

a 

SO 

X 

os 

< U 

a 

a o a a 


a 

oo < u 

Matr 

a 


a a o a fN 

a 


00 

os 

< o a 

a 

O 

fN 

a 

n 1 a U 

Q 

as 

a 


a < 

T 

r a 

a 

a a 

a 

a 

a 

a 

a 

SO sO 

sO 

SO 

so 

so 

SO 

vo 

SO SO 

sO 

so 


r* p* 

r- 


p* r* 



00 

00 

CO CO 


00 

00 

OS 

os 

Os 

os 

os 

os 

os 

os os 

Os 

OS 

<<<<<< 

< 

X 

X 

X 

X 

o 

o o 

o 

o 

o 

o 

o 

o 

o 

o 

o o 

O 

O 

o 

o 

o 

o o o 

o 

o 

o 

o o 

o 

o 

o o 

o 

o 

o o 

o o 


o 

o 

o 

o 

o 

o 

o 

o 

o 

O O 

o 

o 

o 

O 

o 

o o 

o 

o 

o o o 

o o 

o 

o 

o o 

o 

o 

o 

o 

o 

o 

o 

o 

o o o 

o 

o 

o 

o 

o 

o o 

o 

o 

o 

o o 

o 

o 

o o 

o 

o 

o o 

o o 


o 

o 

o 

o 

o 

o 

o 

o 

o 

o o 

o 

o 

o 

O 

o 

o o o 

o 

o o o 

o o o 













o 

rH 

IN 

N- 

a 

so oo 

o 

a 

fN 

a a 

vO 

JH- 

O fN 

•o 

sO 

a 

fN 

a a 


a 

a 

N- 

a 

sO 

r- 

rH 

fN 

a 

TT SO 

00 

OS 

o 

fN 

a 

■*r a 

*N 

a 

t a 

os 

o 

a 

so 

m 

OS rH 

fN 

a 

■*r 


•H 

fN 

a 

a 

so r* 

OS 

o 

o 

o 

o 

o 

o o 

a 

a 

a 

a a 

a 

a 

fN fN 

"N 

fN 

a a 

a a 


■sr 


HJ* 

HT 

H- 

N* 

a 

a 

a 

a a 

a 

a 

vO 

>o 

sO 

sO so 


r- 



00 

00 

CO 

rn 

oo 

00 

00 

00 

00 

OS 

OS 

OS 

os 

os os 

OS 

rH 

rH 

rH 

H 

rH 

a a 

a 

a 

a 

a rH 

a 

a 

a a 

a 

a 

a 

a 

a a 


a 

a 

a 

a 

a 

a 

a 

a 

a 

a a 

a 

a 

a 

a 

a 

a a 

a 

a 

a a 

a 

a 

a 

a 



3 

X 


X 


X 2 
< 2 W 
X O Eh 

S Eh 

M 

2 3 X x 
H X 5 4- 
H 0» 

h K A 
Q X X x 

a a □ 


Sc 


E-» 

a 

J 


H 

a 

X 


x 

x 

X 

a 


x 

X 

X 

a 


X 

X 

X 

a 


X Eh 

x a 

a." 

Q X 

QK 4 
< X x 

u 


o x 

CO X 
fN W 


X 

X 

u 

X 

a 

£g 

a o 
o 


o 

o 


E-* « 

Sg 

a. x 



a 

X 

3 

U 


Eh 

X 



U 


II 



* a 

a 

Eh 2 X 

II 

X 





* 


oo X 




U X x 



a 

a 

Q 

2E. 

X 


X 


X 

X 


* X 



-8 U Eh 


a x a 

s 

X 





II 

U 

a tx 




XXX 



u 

a 

X 

a 


o 

Eh 

2 

Eh X 






Eh x a 

Os 

X 


X 





X 

X 

os X 




o X 



X 

Q 


X 

E-J 

X 

X 

X 

X 


Eh 

« 

* 

■w 


a x 

a 

U a Eh 

« 

a 

« 




X 


a a « 




o x a * 



D 

O 

X 

X 

X 





u 

£ 


Eh 



X Eh 


Eh a 







r J 

X 





H 



O 

£ 

X 

< 

Eh X 

x a 

X o X 

X 

a 

X o Eh > 

u a 

a > x 

* a u 

2 x a x 

U X 

a 

X 

XX* 

X 

2 x a 

X X 

X 

x o u x a 

X 

X o 

X 




X O 

X X 

X 

X a 

X 

X 

XXX 

X X X X 

X 2 

X X 

X 

X X u 

X 


X 

3 

X 

2 


u 

x a x 

X 

3 

X 

2 O X 3 X 

X 

X o 


* 

« 

« 

A 



A 


A 

A 


A 



* A 


A A 







« 

A 





A 



a 

2 







O 

a 

fN 

a tt a 

so 

r*» oo 

os 

o a 

fN a tt 

a 

so oo 

os 

o 

a 

fN 

a 

'T 

a 

vo 

r* oo os 

o 

a 

fN 

a rr a so 

00 

OS o 

a 

X 

♦ a 

fN 

a 

a 

so r~ 

00 

os a 

a 

a 

a a a 

a 

a a 

a 

CN fN 

fN fN fN 

fN 

fN fN fN 

fN 

a 

a 

a 

a 

a 

a 

a 

m n n 

HT 

T 

■’T 

t rr T sr 'T 

■»r 

■^T a 


< a 

X Q 

o 

u 

2 

m a 


Os 

a 


a 


■O O a 
fN fN a X 


Q 

m 

■o 

U Qn 
"T X a 

osa<sooaUXooooaQ 

J3UtNinHH(N»<®naHH 


Q 

m r' co 

*o X *H 

a vo a a 
in < o o a 

so in < a < o 

OS CO o O CO 


X a 
X a 
o o 
oo a 


o a u a 

a M O rH 


a 

x 

fN 

in 

co fN a a 

'T os U U 

n r' n r>» rr a 

'T o a 'T m a 

a<ooxaDO^xooo*Hso 

SO^MOfNOHOsCOnUHHH 


XX on 

a a o o 

x a o o 

< o o 


'T in ^o r' x os < x 
oooooooo 

30000000 

oooooooo 


UQHlNrf^MD 

OOHHHHHH 

OOOOOOOO 

OOOOOOOO 


o\ a a aj nio 

H H H fN rN fN 
O O O O O O 

O O O O O o 


oo < u a a a 

IN IN N (N (N fN 

o o o o o o 
o o o o o o 


o m m < a r j a 

nnnnnnn 
o o o o o o o 
o o o o o o o 


aaNinr'Xji< 

oooooooo 

oooooooo 


X 

o a 
x a 
x o 
a u 


oarsiar^aoofNa^y 

On'Tin^r'X^-HHHHHHfNfNrN'N 


j^as<HH , -nooofN'Tin > orH* 

(Nf'innnnrj’T'f'Tsj 1 ^ 


an^aa^oHNn jjoMNnrr 
**• in a in in '■o so so -d .o so p* r-- r-* r- 


Page 8 

360 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 




o 

PM * l 

Cm ^ 0C ^ 

* o,UUt 

u x x x 

X « X < < * 


Ol 

AI 


X 

X 

X 


04 

w 

Cm 


X 


X 


w 

X X 

X 

t 


—* 

c 

X '— 

cn * 

* Q 

s w 

— E-* 

C/3 H 

Z 

X 

s O 

Cm3 Cm3 

rH < 

x O 

2 

2 u 


^ Cjmnr U x so O O 

QamfM'-a^hKa 
25 HCkK -h < 


K x 

cu a 

X t-t x 

y y x 

o x 

s r- 

U x c/3 
E-« 25 <y> *-j 
O ■h 

Zvfl co 


— -H O H 2 U 2 

t Jflooau 

fN H 3 y a\ U 'N D 

Cm X OHUHhhH n 

ueh h x y w 


^y 

in 

t 

&. 

AO 

Cm 

Cm 

* 

X — 


> 

2 

U 

s 

03 

y 

23 

33 

33 

•"> * 


m > t 

-i 'T e 

i in 

X U F; 

,a 

Cm Cm £ 

SC Cm - 

2 x 

Cm X 0 

< < 


«oo cq « x «*; < * 2 h y « rH o *h y y OHUHHbh n 23 33 a ^ * 

_ <0 o ai m ,y z x co uh h y y y o 

^QjDpZMI^tJUlUJUlUWH: (NZ«S fs Z (N W -N U) H : N Z M y] K s yUZ«UUKo:aa>i>Dhn>f4^u l nvoUFH3: 

Qzwoxxuzoccmxo'-aoxoa: cm x x y Jy^yDc: yyyoi o a y 3 o u a yyyjyxayyb:yi:yyaS< 

A -HA * A A A * A A * A A A * A A AAA A 

^OHr\in^i/i^r'co(j\oH(Nn^'inu)r^coi^o'^'^'3Trinvor'X(TiOH^n-Ti/i^|vxcr>oH^f y i'q'in.or'xa\oHtNn^in^r'coc^ 

r^coaDcoxcocococDcocoa\a\a\a\ai(^c^cT\ascj>ooooooooooHHH'HHHHHHHfNr'jrNf\jfN(NjfNfN , NfNnnr , io^nn' , inro 

HHHHHHHHHHHHHHHHHHHHHfN(N(NfNfN(NfNf>lf>|f'4(NPI(N(N(Nf^NfM'N(NfN!NN l , Nr>j(N!N(NfNj(MM04(N[N!Nr'|rN(NfN!N 


X O lD CO n H H CT> 

00 in < x <r> a» < 

mna<i^a^<ur^yyooHHoyy 
OOHHHOOOHHMC03)'»)! , ina(M!N 

r'CX5^<33^Q[t,r\jrn T fLnc^23Qy < ^Hf v 1'«T 

Ai(N(NfMfNfNfMAimmrnmmromro^r<«Trr 

HHHHHHHHHHHHHHHHHHH 

0300000000000000000 

iOvOP-®(J'OH'3ior>coa\<3inr'(j\Hn»r 

3\0'31U'3\OOOOOOOHHHH!N(NN 

(NNN^fNnnrnnrnnnnfnr'innrnn 


< 

AJ X 

in < 

Cm cn .h <y\ 

■<r o X <r> < 

y < oh o y y 

x o m m x ai ai 


X ai in ^ X U 
rr m in in n m in 


0 0 0 0 3 3 0 


’I M 1 —< 3 1/1 A CD 
3fn T ^ ^ ^ 

ronci^ronn 


Cm Cm 

ry < 

y a n 
o y 

5 <030 
x o rn o m 


D !N in A D 

n x x x x 


O' a a\ 3 

n n n x 

ncirnmen 


^ 03 rH 

A lO A rH X 

< o o < 

Cm m < m < o U 

X X O X O X TT 


<y> Q Cm ai m x x 
x x x r* a* 


3 3 3 0 0 0 0 


HinAOH t X 
xxxr-A-r^r- 
x m m m m ro m 


xcn ^ x m x U 

'T m ai < x < < 

fflOiAI 3 \rNO>Cm(NCN[mHCmOOOCm^ 
X O »H 3 ■—1 A| <HAJ'J(NXnX(Nffl 


01 Q Cm 3 (N n 'T .n x A x oi < 'J y o H 

r^r^r^xxxxxxxxxxxxcnoN 

H <-H rH i-H H »H >H <H i-h H fH >H <H H 'H rH >H 

30030300030033003 

AH3«TDAXOlO'H(N f n-T>flO)OH 

AX»XXX»DJ'0'0\Jl0'!Ti0'QO 

(nmfnn'nrnronmncnnmfocn^'j 


«- 



c 

s 

s 













2 

SB 

£ 









X 

«— 



5 

U3 

w 









Q 

<a> 



oc 

2 

2 


X 







2 

<- 



c 

s 

c 


I 







2 

ca; 


X 





s 

s 


s 

X 

f- 1 * 

r 

X 

♦— 


<- 

X 

S 

H 



+ 


+ 

1 

u * 

\ 


<z> 

oc 

r—i 

U3 

o3 



o 

t 

X 

X 

K 

< s 

s 

O 

H— 

04 

X 

m3 

a: 

Cm 

« 

W 


2 



X 


X 

3U 

X 


u 


Q 

c 



X 

AI 

m 

rH 

AI 

X 

c s 

w 

« 


u 


> II 

u s 

X 

H 

x s 

X X 

c/3 H H 

H H 

U cr» 

H— 



U U 

X 

U 

X * 

H X 2 



X 

X 

*3 y 

L> 

X x 


^4J3J 
x ai u ac m a 

z job js 


CO CO 
H * X X H 


rH u cn u co 
y a a h 


U Cm 

2 _ 

dh a w 

CmyaQfNTrtNn 


a. r ^ooa J x x h « 0 * h y a 'o a h x x E-« yasay £-• x cm ai x rH cmCmXQAi-ynicn 

_ z x 2 : x o* 2 u 

HwuoxtNyanaDo < yHyxy , 'jyxwyao'tHaQa(Na3Knyowy2Hw>afN<z>zyzQ>a>aa£CoHXXXx 
jyazzjaajaa^us:«zQa^y^zayyy^<ay^waytHH'o2:ah3QaHyoyy2J<aoya^ayyawaa 

A A A A A A A A AAA A AAA A A A A A 

^inXAfflJlOHA|( , l^inXAMOlOH(Nfn’Tl'1XAfflOlOH(Nn^inXACDO\OH!NnxjiinXACDO\OHA|ni'tinXAO(JiOHCNn^in^ 
HHHHHHAiAifNAjAifNAiAjAjA^^nnronnnrnrnn^Tr^Trrj^T^^^in ininninnnnnnxxxxxxxxxxr^r^A'r^r^A-r' 


o 

X 

< 

o 

o 



U 

co o cr> in 

T X CM X 


o <~n m U m < X ai Q rr o < X < X < Q< cn < cn Cm ca ai o a\ < o r» 

O <T> X < aO'T a 03 rH < Cm < Cm <! Cm < Cm O <0 <! O in 00 O -H X (J\ 

tr[m'T' , iaoHooaunD'T2i'faooiD‘noA^Hoinoco<inoai'jyH/irH <<inHa^ , CmA<'N<<<oonAAiyHHi y i!aAi'j'Ain 

AirHAicNrHfnyinxinxmxAiXrH<xmxrn^HXxrnxrorHinxmrHinAiroxrn^iinxmrHinAi<TiOrHOrHOrHrHOrHOcnxr^oooo3 


a. , NninxAai<aQyni'rxa\ayyHninAcoa'3jQ[mHAininAMiji<utOOHfN^^AXj\aoHiTincoij\<uayoHnrn^in\o 
au'j'juuu'JUU'jaaQaQQayyyyyyyyyyyyyyyyyyyoooooooooHrH-HyyHHHHrHCNfNAiAiAitNN 
00000000000000000000000 0 0000000000030 »H >—I'—C'—IrHrHHrHrHHrHHHHHHrHrHHrHHHH'HHH 
0000000000000000000030030000003000000 00000030000003000000000030 


a<j in AXcj\H m^inx 
MaujiaiOM^ooooo 
HHHHHHiNAIAIAIAI 


OAiXAH^nmAai 

rHrHrHrHA|A|A|A|A|CN 

A|A|A|Ai|A|AIAIAimA| 


HnininAaiHoininA 
m ca m m m m ^ rr rj 
A|AlAiA|A|A|(A|A|A|Aim 


X CTN O AI ry Xr^XOAl 

ry ry n n in nnnxx 

AI AI AI AI fN A| A| A| A| A| 


f n'yinaiAjcnior , *oH 

xxxxr^r^r^A*xx 

NCNNAIAIAINlNAIN 


aj ^y in xxtjioHnirnTr 
XXXXXX<TiXO>(Tia\ 

A|AJAIA|A|AIAIA|A|A|A| 


Number 49 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 9 

361 




C/3 


2 



2 


2 

2 


2 

Eh 

S 

Eh 

2 

Eh 

2 

13 


2 

o 

Eh 2 

2 

o 


w 

Eh 

2 2 

M 

Eh 

2 


O 

< 

2 X 

O 

< 



2 

2 

2 D 

y 

2 

U 


2 

2 

o 2 

2 

5 

M 



£ 

O 2 


X 

3 

•• 

X 

D 

« < 

X 

5 

2 

2 

U 

< 

2 

O 

2 

2 2 

Q 

U 

Q 

Q 

u 


2 O 

2 

< 

H 2 

2 

< 

X 

2 W 

M 


2 O 

X U 

M 


2 



2 


2 

M 

— 2 

2 

M 2 

2 

2 

Eh 

2 2 

O S 

■P 2 

Eh 

2 2 

— 2 



C H 



•P Eh 



£ 

2 2 


2 

O 2 

2 rH 

X 

< Eh 

•H < 

2 2 

3 

o r* 

M * 

O H 

o o 

Eh 2 

2 2 • 

to- to 


< 2 * 

2 2 Eh 

2 2 



2 2 2 

D 2 

3 2 

2 2 

Ot « 

2 O 

ME* 

2 H ^ 

U Eh 

2 O 


<02 



2 Eh O 

$ 


OX* 

2 


2 « Eh 

M < O 

Eh 


2 2 2 



O 2 

2 2* 

2 U 2 

2 


X Q Q c /3 
Eh Z Z Eh 
C/1 < < x 


QUQUQ 

3£3£3 

"S CH "■«« CH 


Cl* ^ on 
Q o\ Q n 

h n in 
< < < < 
r* r* r* r* 
o o o o * 


X < < co 
^ K K h 


~ a a a a 
« s 2 2 2 
o Eh < c-* < 


U* < < <3\ 
Q C\ Q r*) 


< < < < 

r- r* r* r* 

O O O O i 


r- i>* « ... 

««««««««« *oooo«***«**«« ooo©*«**««*ooo*«««**ooo**** 

HNn5finior'Coa\OHiNrnTrin'£r^X(T\oH(N'nTfiniDr^coc^oHtNn^ , inu5r N -X(j\oH(NnTrininr'Coa'OH(N'n^Lnvor^coa'oHfN 

oooooooooHHHHHHHHHHiN(N(NN(NNiN(N(N(Nnnnnnnnnnn>nr^^TfTr'TTr'r’Tininininininininininioy5^ 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo 


AAA 

AAA 

A A 

AAA 

AAA 

A A 

W m? 'vtpJ’yBSP WF'WF’WF r WFWF r WF'WF r WP'ww'WFWl r II 

LABEL 

DECIMAL 

HEX 

EO 

233 

OOE9 

STRT 

0 

0000 

E4 

! 35 

OOEB 

LO 

7 

0007 

El 

237 

OOED 

XEC 

10 

OOOA 

E2 

243 

00F3 

STMT 

13 

OOOD 

E3 

249 

00F9 

LET 

20 

0014 

TERM 

250 

OOFA 

SET 

25 

0019 

TO 

252 

OOFC 

SE'i’l 

35 

0023 

T1 

258 

0102 

CSET 

38 

0026 

T2 

264 

0108 

CHK 

48 

0030 

FACT 

265 

0109 

GOTO 

63 

003F 

FO 

289 

0121 

GOSB 

75 

004B 

FI 

290 

0122 

PRNT 

84 

0054 

F2 

309 

0135 

PO 

91 

005B 

F20 

32 5 

0145 

PI 

93 

005D 

F22 

334 

014E 

P2 

95 

005F 

F23 

341 

0155 

P 3 

97 

0061 

F2 4 

34 5 

0159 

SKIP 

101 

0065 

F26 

349 

015D 

P4 

102 

006b 

F28 

357 

0165 

P5 

106 

006A 

GET 

361 

0169 

P6 

110 

006E 

GET1 

371 

0173 

P7 

113 

0071 

CGET 

374 

0176 

IF 

117 

0075 

FRE 

377 

0179 

11 

131 

0083 

F3 

389 

0185 

INPT 

135 

0087 

F4 

392 

0188 

IIS 

141 

008D 

F5 

394 

018A 

12 

144 

0090 

F6 

396 

018C 

13 

147 

0093 

ARG 

401 

0191 

14 

154 

009A 

AO 

405 

0195 

15 

156 

009C 

FUNC 

407 

0197 

16 

163 

OOA3 

RELO 

411 

019B 

RETN 

165 

00A5 

RO 

416 

01A0 

END 

175 

OOAF 

R1 

423 

01A7 

LIST 

181 

00B5 

R3 

428 

01AC 

Ll 

187 

OOBB 

R4 

4 31 

01AF 

L2 

199 

00C7 

R5 

438 

01B6 

L3 

203 

OOCB 

R6 

443 

01BB 

RUN 

206 

OOCE 

1) ASSEMBLER PASS 

1 

CLER 

212 

00D4 

2) ASSEMBLER PASS 

2 

REM 

217 

OOD9 

3) LIST 

SOURCE FILE 

DFLT 

222 

OODE 

? 



EXPR 

227 

00E3 

OK 




SYMBOL TABLE 


« x 

S 


: s 



*T II 

ro 

II VO 


u u 

a: t 

X 

•H * £ X rr 


2Q 03 





vO 

U rH 

U 

33 U in U 21 


U C* O <N 

33 x 

m S3 in 

m3 33 X VO 33 in J 


2 LJ 





D*haaiHo'j 

23 Eh r-j 33 

EHnH^UcQEHmaH^E 

H Q 

Cn 2J X X J 

X X 23 

m3 X X 3 

xxxxx^xx^xxc 

C 2 

/\ A 

A 

A 

A A A A 

Ji 


OH^n^ini)r'Ma\oHiNn’Tin'ur'coa\oHfNnTrinii3 

'T'frr'jT«t«r»f'<jnfininini/iLninininininvovovoiflioinifl 

iNrNnj^!N(NrM(NfNfN(Nf>ICMfN(N(NfN(Nni(NfN(NtN(NfNfM!N 


m 30 a (N U Q r ' 1 W in rH U Q « u in 

2 < 20 220 20 O 220 20 O 

X2i,0'NU,*r;r»u«uj' t TO>&« T * , <y'Du<7\Ci40'*TcT>Ci**rcr>ki<TNCi* 
'*10f'jXi/lN®3^XSO(NCOO(NOMXCOOf')XO(NOIN 

, nin^Nji<aa^oN , *"-o rs U'aU43tijH'nin'Xico<33a 

ai3M3>^3'OUJ\^(j'<<<<<<<<^<22Sa22221 

hhhhhhhhhhhhhhhhhhhhhhhhhhh 

ooooooooooooooooooooooooooo 

rv "> .n j r» o h ^ n xi-oorN'^Lor^-coo'—^^Lnr^-aootNrom 
OOOOOHHHHHHJNN^'NNlN'n^fOrnn^'TTV'T 




Page 10 

362 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 9402S 


Number 49 








co 


Q 

< CM xt v£> 

rH 

o 

U XT 

c 

o 

M 1 

< in uo 

a 

O' CM 


a 66 

< O' a Q O' 

Q 


xT 

CM 

23 

O 

in in h 

CM 

CM 

<-H 

CM 

a 

a 

CM 

o a a < 

CM O 

rH 

CM O O 

o 

rH CO a o 

a 


O' 

<H 

O 

co 

00 

00 T 

CM 

CO 

a r- 

a 

XT 

a 

a xt < uo o' a 

Ua<<COCMUxr Q 6 


co 

O' 

CO 

'O 

XT 

00 rH 

< a 

u 

a xt 

U 

rH 

CO rH uo 

a 

O O 

rH 

< o o 

a 

rH < a a 

o 


a 

a 

o 

c^ co a o 

a 

o 

m 

o U 

a 

o 

a a a 

< < co 

o 

o a a 

CM 

T CO U XT 

a 


H 

co 

< 

cn 

XT 

u a co 

CO 

xr 

rH 

< 

XT 

a 

U co H 

uo 

o 

o a < < 

a <n a a a c* 


< XT 



a r» co 

a 

Q 

a 

O CM 

m 



Q cm 

Q 

o 

00 a rH rH 

xt 

< a 

t 

o 

m 33 a rH rH VO 

o 

O' in uo o 

o cm a a a 


a a m 

<QtroHCi 

xr 

rH 

•H 

m 

O CM O O 

O' 

o r* 

< rH a a < cm a a o c* 


>H 

co 

xT 

o 

rH 

O' CO 

a cm 

in 

CM 

rH 

a 

o uo a co 

o 

a o' 

O CO XT XT 

o 

rH < cm a 

o 


< o 

U vO 

u a cm 

a 

o 

xt 

CM 

a 

a 

o 

uo o a 

rH 

O rH 


rHtdfcdvOCMOCMa 

a 


a 

O 

xT 

S O H U 

a 

a 

a < rH 

•H 

o a < < 

CO 

a co 

o 

O' a xr 

<cMaofMC 


a 


ffl m 

a u m 

00 

CO 

CO 

CM 

CO 

uo 

o 

oiQin 

< 

< 23 cr. rH 23 m 

a CO ON rH 

a 


H 

a 

CO 

00 

CM 

o m 

a 

O' 

a 

a 

a 

rH 

o 

uo rH a 

< 

o o 

o 

co vo a 

a 

o a o o 

CM 


a rH 

U 

XT 

O 

a co 

•H 

xT 

o 

T 

o 

O 

o 

u a < uo xt cm 

a 

co rH a 

xT 

in o Q o' xt 


Q 

o 

CM 

a 

a 

cm m 

c~ 

CM 

co 

a a 

a 

o 

< u a 

M UH 

o 

a < cm 

Q 

U co a o 

O 


O' 


H 

in 

CO 

a o 

m 

< 

a 

in 

u 

a 

xT 

O uo o 

O' 

a o 

O' 

oc am 

CM a XT a 

a 


CO < rH 

xt 

a o oo 

a 

a 

a 

in < 

U CM 

a xr co 

o 

xr a 

rH 

co o CM 

XT 

in < co cm 

o 


a 

O' 

O 

co 

o 

O 'O 

T 

CO 

rH 

o 

rH 

CM 

U O CM 23 

rH 

CM O' 

< 

a < a 

a o a uo 

a 


rH 

co 

H 

in 

CO 

a rH 

a 

a 

a 

m 

a 

m 

a 

U0 UO < 

CO 

uo o 

rH 

< o < 

XT 

xr a CM o 

CM 


xT 

o 

i O 

\D 

a 

CO rH 

a 

m 

a 

a o' 

uo 

xT 

rH xT rH 

a C* co 

a 

o a o 

a 

a a cm a 

UO 


Q 

o 

in 

O' 

a 

a rH 

xr 

m 

a 

XT 

UO 

uo 

a 

a a a 

CM 

O' rH 

rH 

a < a 

a 

a cm uo o 

o 


a 

vO < 

a o 

o o 

O' 

CM 

o 

O' 

rH 

xT 

CO 

co 23 xt 

XT 

a a co 

CM XT <H 

o 

U rH a a a 


•h 

a <n 

H 

00 

CO rH 

TT 

CM 

CO 

■o 

a in 

UO 

a cm io 

UO 

CM rH 

o 

Q XT O' 

uo 

xr u < a o 



H 

m 

CO 

CO 

CM O 

CO 

U 

kO 

a r> 

uo 

O' 

o 

O' 

xr UO 

m 

CO a rH 

a 

a a o xr 

u 

u* 

O' o U -* 

a 

O' a 

a 

< U O' 

CM 

xT 

xT 

CO Q rH 

rH 

uo a 

o 

in XT CO 

o 

< cm a a 

a 


a a 

O' 

O 

o 

p» co 

CM 

CO 

O' 

a -H 

CM 

U 

a m < 

< 

a < CO U 0 rH co 

CO 

o cm a a xr 

ON 

H 


a 

CO 

o a 

a 

a 

xt 

o 

O' 

in 

xt 

rH XT a 

a 

rH *H 

o 

uo xr a 

a 

a rH 'M CM 

a 

C* 

a 

O' 

•h 

CO 

00 

< o 

o 

a 

rH 

a 

o 

O' 

a 

co a o o 

a < CM 

a 00 O 

o 

XT CM 23 CO 

a 


Q 

co 

a 

a rH 

O CO 

uo 

M3 

a 

co 

CM 

a 

O' 

CM XT CO 

co 

O O 

o 

aacocOrH<oo 

CM 

< ON 

co 

o 

o 

r—i 

a a 

o 

a 

a 

a 

a 

a 

a^’»aQH<tf 

a a a 

a 

•h a co a 

a 

f" 

co 

in 

H 

CO 

O 

a u o' m 

T 

rH 

a 

rH 

CM 

Ti a < < co H 

o 

CM CM < 

< 

o cm a o 

o 


<fflUOyu«OHfNnrrin^r*co^<3jUQau < oHf^n'TLnvor' 

Qr-r'r»r'r'f^»»Mcococo®coco»coooooco®cooMT»a\o>(yia\5\(^('* 


FIGURE 4 



Number 49 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 11 

363 








Microcomputers 

... as they should be [ 


BY OLAV NAESS 
Welhavensgt. 65 
Bergen, Norway 




The microcomputer has great potental for interacting with 
the real world as well as for expanding into a large computer 
system by addition of various storage units, computing units, 
interface units, etc. 

But the microcomputer systems of today are far from able 
to realize the potential for interfacing and expansion, or at 
least they implement such potential in an unnecessarily awk¬ 
ward way. It seems to me that the main reason for this is bad 
mechanical design. The mechanical problems evidently tend 
to escape attention. I will therefore try to throw some light 
upon these problems, and suggest solutions for them. The 
intention behind this article is to create widespread dissatis¬ 
faction with present designs, so that those with powers to 
bring about such reforms will be induced to get moving. 

Now, let’s take a look at the common mechanical design of 
a non-trivial microcomputer, i.e., one that can be expanded to 
a multi-module system. The modules, each normally one PC 
(printed circuit) card, are usually plugged into connectors 
which are situated in fixed positions on a rigid motherboard, 
and the whole assembly is mounted in a box. The box is a 
typical afterthought. It does protect the cards against dust 
and damage, but also hinders more constructive interaction be¬ 
tween the computer and its environment. The few simple 
controls and connectors that can be placed on the edge of a 
PC card are difficult to use when the computer is on, even if 
the cabinet is opened. 

Cables to the outer world must find their way out of some 
opening in a rather disorderly manner, and heaven knows what 
traumatic experience the modules are exposed to as some 
creature passing by in the external world gets entangled in one 
of the cables. 

In my own mixed X-100 system, the keyboard communi¬ 
cates with the internal video terminal card through a flat cable 
that plugs into DIL (dual in-line; IC) sockets on each unit’s 
PC card. There was obviously no standard for such a connec¬ 
tion, so I had to identify the signal lines and resolder one of 
the DIL plugs. The crossing wires on this plug made it impossi¬ 
ble to close its lid, which had to be left floating over the plug. 
If the keyboard is moved, the flat cable sweeps over the com¬ 
ponents of the video card. Disconnection of the keyboard 
necessitates opening the computer’s cabinet, unplugging the 
video card, and then carefully wriggling that fragile DIL 
plug out of its socket. Those who enjoy dancing with an oc¬ 
topus can try to move the computer system while the external 
units are connected. 

On the top of the video card sits an edge connector to 
whose solder lugs various other external connections are sol¬ 
dered, amongst them the video cable! This thick, rigid coaxial 
cable should certainly not be allowed to sweep across the in¬ 


terior of a computer and exert its powers upon some poor 
little solder lugs. Breaks and shorts have again and again caused 
a blank screen in my system. Conclusion: Video cables can 
only be connected with (coaxial) connectors properly 
mounted on a rigid external surface. Letting external con¬ 
nections go directly to the PC card is a dubious practice. 

More thoroughly designed computers employ cable assem¬ 
blies divided into an internal and external cable, the two meet¬ 
ing in a connector pair on a cabinet surface. This is safe and 
covenient, but an expensive solution which also imposes 
restrictions upon the types and number of connectors that 
can be used. 

Is there any solution to our dilemma? Yes, and module 
systems with the desired properties are even commonly used in 
all sorts of laboratories. A PC card for such a system has a 
narrow plate mounted vertically on the card, running along 
the card edge that is opposite to the edge connector. When the 
cards are plugged into the system’s frontless enclosure, these 
narrow plates, whose two ends may be screwed directly to the 
enclosure, constitute a front panel. All connectors, switches, 
indicators, etc., needed by a module may thus be mounted on 
the module’s own piece of front panel, and their connections 
with the PC card can be short and fixed. 

This packaging system does, however, still have some an¬ 
noying shortcomings: the enclosure has a fixed size which is 
quite likely to be too small or too large. And modules are not 
accessible for testing and adjustments unless they are un¬ 
plugged. 

I will therefore suggest a further improvement: the front 
panel plate should go all the way around the PC card, as shown 
in Figure 1 and further illustrated in Figure 2. That is: the 
cards are mounted in frames which are attached to each other 
by separable hinges. When end-plates are hinged to the first 
and last module, the modules are completely enclosed: no 
space is wasted, and the enclosure can be expanded to any 
size. Such an assembly can be opened like a book during oper¬ 
ation for testing or adjustments. 

A hinged-frame microcomputer, which could have frames 
designed to hold S-100 cards, should have a flexible mother¬ 
board passing inside the hinged edges (which might be detach¬ 
able from the side edges, too). Such a motherboard would 
restrict expandability somewhat, but the unused part could 
run along one or both endplates. Modules hinged together this 
way may be virtually anything from a framed PC card to large 
units like a power supply, a disk drive or even a video monitor. 
A frame for PC cards could have several small cards mounted 
side by side —useful for sub-modules with perhaps just one 
LSI IC. Heat-generating components could be mounted in 
perforated frames, and circuits requiring screening could have 
screening plates adjacent to their frames. 


Page 12 

364 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 







Figure 1. Hinged frames with PC cards, and one detached 
end plate. 



Figure 2. Section of frame-mounted PC card with controls 
and flat cable connections. 


Frame-mounted cards are less vulnerable when removed 
from the system than unmounted cards are. If frame dimen¬ 
sions are standardized, cooperating systems like a computer 
and an audio system can be merged to a single unit. 

Figure 3 shows what a large hinged-frame system may look 
like. The keyboard (in a wedge-shaped module) is here opened 
180 degrees relative to the next module. 

A small computer may have just one or a few thin modules 
just below the keyboard module, and resemble a TRS-80. 
If the user of such a small computer wanted to use control 
panels designed for special applications, he could mount them 
like a PC card in a frame anywhere in the computer. 

Imagine sitting down in your easy-chair with your book¬ 
like microcomputer in your lap. You leaf through pages of 
control panels until you find one for a game you would like 
to play . .. 


Enough about the enclosure; now let us look at the external 
cables and how signals are allocated in them. 

Regarding external connections, there prevails an unfortu¬ 
nate tendency towards unnecessary splitting-up; by using 
separate cable assemblies for the various types of signals and 
power, and by splitting multiplexed (bus) signals into separate 
digital ports or analog channels at a too central site. The circu¬ 
itry required for decoding/latching signals from a bus is cheap 
compared with a decent cable assembly. A universal I/O bus 
which can be extended out into the real world can greatly 
increase the controlling power of the computer, decrease costs, 
and decrease confusion caused by lack of standardization. 
The IEEE-488 bus is such a bus for peripheral units but is 
too specialized. Besides, its communication protocol is rather 
complex. 

To illustrate my notion of universality, I would like to de¬ 
scribe a universal I/O bus system I have just constructed. It 
communicates through a 25-conductor flat cable with stand¬ 
ard DB25 connectors, but a stackable connector would be 
preferable. The conductors carry: 

1: Power from the computer: 5 V stabilized. 8V and ±18 
V unstabilized, plus ground. 

2. The 2 MHz clock from the X-100 bus. 

3: Two analog lines: Output from a D/A converter and input 
to an A/D converter (placed between filtered power lines). 
4: Count and gate inputs to two counter-timers (Intel 8253). 
5: An interrupt input. 

6: An 8-bit digital data/address bus with control lines. 


(CLOCK, ADDRESS COMES) 

Even though hundreds of external units can be addressed, 
the I/O system occupies only a sequence of four ordinary 
I/O ports: 

First port: Address of the external unit (output). 

Second port: Data to/from the external digital data bus. 

Third port: Least significant byte to the D/A converter or 
from the A/D converter. 

Fourth port: Most significant byte to the D/A converter or 
from the A/D converter. 



Figure 3. Small computer made up from hinged-frame 
modules has one cabinet rather than four. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 


Page 13 

365 



(Continued from page 13.) 

Ports required for the counter/timer and any interrupt 
controller are additional. 

To operate the bus, an I/O transfer is initiated by output¬ 
ting an external address through the first p ort. When this one- 
byte address goes out the external bus, the ADDRESS COMES 
line goes active (low), and CLOCK goes active (high). This 
activates the external address decoders and loads shift registers 
associated with these address decoders. Each parallel output 
of these shift registers will activate an input or output data 
transfer if it has a 0 (low). When an address decoder reports 
an address match, it loads a 0 into a certain shift register bit. 
All the other shift registers along the bus are filled with non¬ 
activating 1 ’s. The transfer activated by a 0 may be in or out, 
digital or analog: 

Digital in: An eight bit tri-state buffer puts its data on the 
external bus. 

Analog in: An analog switch connects an analog input to the 
analog input line. 

Digital out: An eight bit latch takes data from the external 
bus. 

Analog out: A sample-and-hold circuit samples the analog 
output line (analog outputs need periodic refreshing). 

Between each such external transfer the data byte is read 
or written through the second, third, or fourth port. Immedi¬ 
ately after an I/O through the second or fourth port, a pulse 
emitted on the CLOCK line causes a shift in all the peripheral 
shift registers (with a 1 -bit entering), so that the next transfer 
is activated by the 0-bit in the active shift register (besides, 
an A/D conversion is started). 

The external address can indicate the entrypoint anywhere 
in a sequence of assorted-type transfers. Because time-con¬ 
suming processes like A/D conversion and stabilization of long 
signal lines occur between the computer’s I/O-operations, the 
computer is never forced to wait provided the intervals be¬ 
tween I/O-operations don’t become too short, like during 
DMA bursts. 

Well, folks: if these things sound interesting, don’t expect 
real products or properly tested designs to come from an 
amateur like me. I can only hope that manufacturers can be 
enticed to move along such lines, and that they will establish 
useful standards. 




Page 14 

366 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 









































































































BY TOR SJ0WALL 

G-15 

N-7035 Moholt 
Norway “ 


CP/M TO UCSD PASCAL EEIttEE 

-— file conversion 


We were all very pleased with the article on PASCAL to 
CP/M file conversion in Dr. Dobb’s, but there is also a need 
to go the other way; to use CP/M 2.0 files in the PASCAL II.0 
environment. 

In order to get at the CP/M files, you have to access the 
diskette on a direct track/sector basis because of the differ¬ 
ence betweeen CP/M and PASCAL file formats. This is not 
possible under the PASCAL system as described in UCSD’s 
manual but there is something they have not told us about 
the UNITREAD and UNITWRITE intrinsic procedures. The 
parameters to these procedures are according to the manual: 

procedure UNITREAD (unitnumber, array, length, block- 
number integer); 

Unitnumber integer name of an I/O device 
Array packed array for transfer 

Length number of bytes to transfer 

Blocknumber absolute PASCAL block number on a diskette 
Integer optional (1 indicates async transfer) 

Disassembly shows that the integer parameter has more op¬ 
tions 


Values may be added to combine options. 

4 & 8 only workonCONSOLE:, PRINTER: and REMOUT:. 
Direct track/sector I/O do not use the ordinary block- 
number parameter. Instead a blocknumber is calculated as: 

track: 0 . . 76 ; sector : 1 . . 26 ; 
blocknumber : = (track * 26) + (sector — 1); 

NOTE: Length parameter is ignored 

Array parameter has to be at least 128 bytes (1 sector) 
IORESULT is never set, always 0 

I don’t know if this option will work on all PASCAL 
systems, but it is likely since it is the only way to get at the 
bootloader on the diskette. The P2-code interpreter addresses 
in our implementation are: unitwrite 22A8H and unitread 
22ADH, with direct option at 230CH. 

The GETCPM program uses the direct sector option to con¬ 
vert CP/M textfiles to PASCAL .TEXT files. Datafile con¬ 
version is also supported. Random access CP/M files are not 
properly converted, but this is easily implemented in COPY- 
PAGE by sending IK of null or space when cpmpage=0. 


1. Asynchronous I/O, not implemented in our 8080 system 

2. Direct track/sector diskette I/O 

4. Text file indent code expansion on output activated 
8. Automatic linefeed append after return 


Tor Sjowall is a student at the Norwegian Institute of 
Technology who will soon be a professional engineer. Tor 
works mostly on microcomputer systems but his main field 
is digital switching in telephone networks. 



■a 

t- 

O L. 
(0 


03 0) <D 
- OT OT 
*—* OJ 03 
O O 
C s- £- 

• H 8.8. 
L Q. Q. 
(U 3 3 


bO-r 

■Q 


■o 

(D 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

367 







Number 49 

368 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 17 








Page 18 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 49 

369 





a 

o 


rH P 
•O P 

co a) 

0 ^ 


si 

c_>: 


0 ) •- 
sz ^ 
P 0 


0 0 

S 

0 

a 

3 

Cm 

0 

3 

£ 


P P 

€ 

o 

P 


§ 

o •- 

o 


P P 


co 

P 

2 ^ 

CO rH 

•H 


0 0 

/\ 


•H 

O 

\ 0 


- 0 

P 

0 

z* J* 




0 

CP E 

0 

0 bO 

CO 


CO co 

i 


Cm 

P 

U 0 

O 

E 0 

0 rH 



•H "H 


3 

•H 


fe 

•H 


T3 T3 

p 


JO 

TJ 

0 0 

P rH 

P 

P 


O O O 0 H 


i a) a) 
• -p p 

•H tH 


fe a 

-p o 

o co 

0) -H i 


a 

0) 

p •• 

•H C w 
TJ -H 
P CD CD 
P P P 
P -rH - H *H 
•H P P P 
bO O. 5 3 
<U 


38 


sz - 

-p 

bO 0) 


a; ai i-h 

jc a -h 
■p >» cm 
-p 

O 0 «-H 

r-H CO 
II bO 

Cm ,H 0 
- CO rH 
0 0 b0-H 
E E 0 ► ■ 


0 

bO 

0 0 


P P 'H 
CO CO 

0 0 II r 

•a td 


0 I 

>> p p ' 
) P 0 H 

\X afe 
> d £ 


a; 

is asfe 

b0 >> 0 

« P P rH P 
< 0 -H 0 
M O Cm £ 
1 0 , P 

llr£(w 
r-H O -H 


•H 0H 

;0 S 

1 at 

i >> 

, P 0 

: 0 5 . 

rH >, 


life 


H •—*> 0 
H 0 Q. 

- Si? 

H P 0 
X P .H 
j] W'Hrv 
H 0 <P ^ 

- *o - g 

- 0 O 
P E rH 

c co cO - 

H 0 p p 
0 T3 0 CO 
P P rH 0 

t 

s 

• ~ 0 p 

P 0 rH— 

—• P i-i 
•H«w 0 
P >, CO 

5 Q. o 

0 O rH 

p o o -a 


0 


E-» P 
< CO 
Q 0 

- -o 


0 

rH 

•rH ' ‘ 
<P ^ 

0 O 


P 0 H 0 
•H P -H TJ 
P 0 «m 0 
3 -o^ P 


.fefefe fefefe fe 


C 0 r 
rH P • 

0 -H 

C H ^ 
•H P 0 
bO 3 P 
0 0 


>. CO 
Q. O 

O rH 

o oo 


•o 

p 0 

0 co 


■8 

x: 

o 


- 0 

p 

X 

0 




Number 49 

370 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 19 




Extended Source-Text Area 
and 

Label Capability for 
SC/MP NIBASM 


BY W. F. LONG 

Naval Medical Research Institute 
Bethesda, Maryland 20014 

Are you using Roger Marin’s SC/MP assembler (SL0060) written in NIBL BASIC 1 ? 
Would you like to be able to expand the source-text RAM area beyond one 4K page 
for larger programs? Do you find that 26 labels aren’t enough or that you need to 
begin two with the same alphabetic character? If you answered “yes,” read on. 

The following modifications are simple and brief. Together, they affect four exist¬ 
ing lines and add one new line. Separately, the two extensions affect different lines 
and do not interact. They may be added singly if desired. 

Expanded NIBASM reads source text across any allowable number of 4K pages 
consecutively from the starting address. (NIBL defines page 7 as the upper limit and 
you must remember to save space for generated object code.) Label capacity is dou¬ 
bled by permission of the entire lower-case alphabet as beginning characters. 

Source-Text Area Expansion 

Existing program line 120 begins the text search for each line of source: 

120X=«L*256+«<L+1 >: N=L+4: IF<X=-1 >OR(W=4!>PR" ": PR"END RSM": END 

where variable L points to the current line number stored in NIBL format; N is the 
text cursor; and W is the pass counter. In the first statement, variable X is set to the 
current line number converted from base 16 to base 10. The first test in statement 
three looks for X equal to the NIBL program-page-end flag. A true result terminates 
the assembler. 

Program line 120 is rewritten to cross 4K page boundaries with NIBASM: 

120X=«L*256+«<L+l>:N=L+4:IF«CL+2>=#FF L=<#0FFF OR L>+3:GOTO120 

where the conditional portion of the line has been replaced. Now the test is for a new 
user-set flag in the byte following the two line-number-storage locations. If the flag 
tests true, variable L is advanced to the first line-number address of the following 
RAM page, and line 120 is re-interpreted with the new L value. 

New line 130 tests for source-text end with the omitted portion of old line 120: 

1301F<X=-1 >OR■;W=4>PR" ": PR"END RSM": END 

NIBL shares the new NIBASM user-flag position described above without inter¬ 
ference NIBL uses it within program text as the line length indicator, storing a maxi¬ 
mum possible value of 48H. At program-page end, it is the address of the NIBL 
function TOP. 

Label Capacity Expansion 

Original NIBASM scratchpad-RAM occupies the top 200 bytes of page 1, from 
IF 38H to 1FFFH. The label-table takes 52 bytes (2 bytes per upper-case alphabetic 
character) from 1F3EH to 1F71H. Variable I is designated the label-table pointer in 
program line 20: 

20PR "SC-'MP ASM":PR"OBJCT CODE RflM="j:INPUTD:H=S100:1=7993sW=1 

where 7998 is the first character-A address in base 10. All but the last two statements 
of line 30 comprise a label-table initialization loop: 

30FORX=0TO51:«<I+X>=#FF:NEXTX:U=8050: 2=-l 


Page 20 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

371 





After the first statement of line 200 normalizes the beginning character value of a 
suspected label, statement two tests character nonvalidity: 

200X=<«N-65'.>*2: IF<X<0JOR<X>50>GOTO220 

where N is the text cursor; X is set to the normalized character value; and a nonvalid 
character is outside the range of capitals A through Z. 

To double label capacity, one must double the label-table. But, what about the 
first six scratchpad bytes 1F38H to 1F3DH used elsewhere by NIBASM? Six special 
ASCII characters separate the two alphabetic cases. If label-table pointer I is moved 
lower in memory by twice the number of lower-case and special ASCII characters 
combined, a version of the original label text/storage method can be devised that will 
skip over those original first-six scratchpad bytes. New program line 20 reflects the 
altered label-table pointer, I: 

20PR " SC ■•’TIP ASM" : PR"OBJCT CODE RAM=" INPUTD: H=8100: 1=7934: W= 1 

The modified second statement in line 200 still tests for character nonvalidity: 

200X= < «N-65 > *2:IF < X< 0 > OR < X >50 > AND <X<64>0R(X>114> GOTO220 

Lower-case alpha characters are no longer invalid, however, while the six special 
ASCII characters remain invalid. 

Now when unmodified program line 210 indexes from pointer I by normalized 
valid-character X to store the label value, lower-case labels are stored in the original 
upper-case table. Upper-case labels now occupy the new scratchpad range 1EFEH 
though 1F31H, automatically skipping the originally allocated first six bytes (six 
free scratchpad bytes from 1F32H to 1F37H are also created.) 

Label-table initialization adjustment is all that remains. An added loop-statement 
to program line 30 accesses the original table area by indexing from the new pointer-1 
address: 

30FORX=0TO51:«<I+X>=#FF:NEXTX: 

F0RX=64T0115:« <1+X > =#FF:NEXTX: '3=8050:2=-1 

The old loop is retained for initialization of the new table. 

Using Expanded NIBASM 

When writing source for expanded NIBASM, you may include the entire lower¬ 
case alphabet as beginning characters in 26 extra labels, while otherwise following 
Roger Marin’s original rules. 

Following the final source entry on a page, enter an immediate statement of the 
form: 

JSTOP*tr. HH 

where hh = FF when source to be assembled with the current page is contained on the 
next higher page or where hh = any lower value when assembly is not to be continued 
across a page boundary. 

There are no other procedural differences between original and expanded NIBASM. 

Incorporating the Modifications 

Assuming packed entry, the source area expansion changes add 42 bytes to the 
original program. The label capacity expansion changes add 48 bytes. Either modifica¬ 
tion will fit if entered alone without further packing of Roger Marin’s NIBASM 
source. NIBL may flag AREA ERROR during combined inclusion however. 

Packing is one optimizing technique for interpreted programs. A line is read and 
executed more quickly when it contains no unnecessary characters or spaces. Packed 
text also allows more program within a given memory space. 

Original NIBASM is well-packed as published. Still, I reduced its total size by 71 
bytes as copied into my system. All eliminated bytes were spaces. Probably a reduc¬ 
tion by half that amount would comfortably accommodate both modifications. 

Addendum 

I have just executed a test assembly with Expanded NIBASM on source text con¬ 
taining all SC/MP mnemonic/pointer permutations. This test assembly uncovered the 
only “bug” I’ve been able to find in the original program. The last statement on line 
4525 tests the assembled opcode value in order to flag two-byte instructions for 
further processing. Unfortunately, the value tested for “greater-than” is the DELAY 
intruction opcode (mnemonic DLY), so the instruction is assembled incorrectly. 
The “bug” can be fixed by changing the test reference value from #8F to #8E. 


Acknowledgment 

Naval Medical Research and Develop¬ 
ment Command, Work Unit No. MF58. 
524.015.0018. The opinions and asser¬ 
tions contained herein are the private 
ones of the writer and are not to be 
construed as official or reflecting the view 
of the Navy Department or the Naval 
Service at large. 

Footnote 

1 Both NIBL BASIC and NIBASM 
are available from NSC’s user group: 
Compute/5226, National Semiconductor 
Corp., 2900 Semiconductor Dr., Santa 
Clara, CA 95051. SL0042A, NIBL-N — 
paper tape, SL0060, NIBASM —Listing. 


Mr. Long accumulated 10 years of 
hardware experience in design, 
development modification, fabrica¬ 
tion, and repair of analog and 
digital medical research instrumen¬ 
tation for the Naval Medical Re¬ 
search Institute before including 
microprocessors and software 2-14 
years ago. 



Number 49 

372 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 21 






BY H. T. GORDON 
College of Natural Resources 
University of California 
Berkeley, CA 94720 

In an elementary essay on micro¬ 
processor instruction sets ( Kilobaud 
Microcomputing, March and April, 1980), 
I tried to “read” the complex minds of 
the elite few who design them. Although 
I have met in person (too briefly for 
significant interaction) only two of them, 
I was not surprised to learn that they 
comprehend instantaneously not only a 
question but its implications (in my 
experience, a rare thing). But I know 
them by their work, unquestionably great 
art, as I know Aeschylus, or the architects 
of the great cathedrals of Bourges and 
Chartres, or certain poets who have used 
the more elusive constructs of English or 
German. As Juliet says, what’s in a name? 
What matters is the profound structural 
diversity of human minds — and the 
possibility of symbolic intercommunica¬ 
tion not restricted by time or space. 

This prolegomenon has served only as 
a “signature,” and I shall now lapse into 
rationality. The rational purpose of this 
note is to explore in depth a problem 
lightly touched on in my Kilobaud essay: 
how can one create, for an 8-bit CPU, 
more than the 256 possible one-byte 
opcodes? It is well-known that the Z-80 
was the first design to use a “leading 
byte” (one of four different bit-patterns 
unused by the 8080) to endow the next 
byte with an utterly different meaning 
(from what it would have had standing- 
alone). The effect is to create 1024 
possible two-byte codes, most of them 
not defined at the higher level of Z-80 
assembler language. It is not surprising 
that the CPU circuitry nonetheless “runs” 
many of the undefined codes (cf. the 
letter by D. R. Lunsford, DDJ #44). The 
6502 also runs most of its undefined 
(one-byte) opcodes, some as “nopcodes” 
(cf. my note in DDJ # 28, p. 29). I 
assume that it would complicate the 
microcircuitry if designers tried to 
“block” this (as big CPUs now do). 
Designers probably see undefined codes 



as a “reserve” that could be used for new 
instructions. In fact, the brief preview of 
the 6516 by David Kemp (BYTE, May 
1979, p. 213) states that this upgrade will 
define the 105 8-bit opcodes not defined 
in the 6502 set. It also implies that the 
6516 will go no further. That’s a tenable 
position, but I wonder. The turmoil in 
the 6502 upgrade is indeed great (so 
much so that Chuck Peddle quit for a 
while!) but there are not enough bright 
people involved so that the number 256 
cannot be an uncrossable limit. In reality, 
the limit must be already crossed, since 
the 6516 is not likely to discard the 
“decimal mode” status bit of the 6502. 
This bit, when set, redefines the 6502 
arithmetic opcodes from binary to 
decimal operation. 

We have now struck the alternative to 
the “leading byte” concept: the “ninth- 
bit” expansion (that the Signetics 2650, 
with its two status registers, uses very 
freely). This kind of expansion has its 
peculiar trade-offs. For example, if a 
programmer needs only one decimal- 
arithmetic instruction, this must be 
preceded by an SED (becoming in effect 
a two-byte opcode) and should be 
followed by a CLD to cancel the effect 
(effectively three opcode bytes!). How¬ 
ever, the (one-byte) arithmetic opcode is 
normally inside the loop, and the two bit- 
control codes are outside. If the loop 
iterates the arithmetic code 20 times, 
the overall effect is to create a “1.1 byte” 
opcode with faster execution. Were it 
done by a “leading-byte,” the program 
would have to load forty bytes during 
execution instead of only 22. On the 
other hand, since a “leading byte” is a 
one-time control, there is no need for an 
extra program byte to cancel its effect, 
and there may be less chance of error by 
careless programmers. The 6502 decimal 
bit does not, of course, eliminate a 
leading opcode byte, but the following 
“decimal-adjust” byte used to decimalize 
arithmetic instructions in most designs. 
However you look at it, no design creates 
a set of one-byte decimal arithmetic 
opcodes. Most use what is in effect a two- 
byte opcode to convert the binary arith¬ 



metic codes to decimal operation. This 
means they cannot have dual-purpose 
arithmetic programs, as the 6502 can, 
since the same program can be made to 
work either in binary or decimal 
depending on whether the decimal bit 
is set or reset before the call. 

In my Microcomputing article 
(accepted by then-editor John Craig early 
in 1978) I express admiration for the 
2650 and the belief that future designs 
will be influenced by its many innova¬ 
tions. In fact, the 6809 did adopt its 
flexible status-bit control, and its pro- 
gram-counter-relative addressing mode. 
However, this pioneer third-generation 
chip rejected the “ninth-bit” concept 
and imitated the Z-80 by creating multi¬ 
byte opcodes. Since the 6809 is based on 
a lot of thought (cf. BYTE, Jan. 1979, 
p. 14), this would seem to be a strong 
argument against the “ninth-bit” ap¬ 
proach, that is not even mentioned 
in the BYTE presentation of the 6809. 
The brief discussion of “design decisions” 
for the 6809 does not say who made 
these decisions that to me sound like 
restrictions ( I must emphasize that I 
am not acquainted with any of the 
restrictors or restrictees in this case, but I 
assume the universality of restriction.) 
One can speculate that Motorola execu¬ 
tives imposed restrictions, and try to read 
their minds! It is my vague impression 
that these “practical” men fostered 
(tolerated?) the radical imaginings of 
Chuck Peddle that are the 6800, in the 
hope of overcoming the early lead of the 
8080. They were justifiably annoyed 
when it did not, and perhaps surprised 
when Peddle’s more advanced creation 
(the 6502) turned out to be an effective 
competitor. Since an obvious strength of 
the 6502 is its many addressing modes, 
and the success of the Z-80 could to 
some extent be attributed to enhanced 
addressing, a sure-fire response would be 
to endow the 6809 with vastly superior 
addressing power. This needs lots of 
opcodes! Since the Z-80 had succeeded 
with multibyte codes, while the 2650 had 
got nowhere with its “ninth-bits,” 
practicality would demand “leading- 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

373 




byte” solutions. The way of the pioneer 
is hard, and the 6809 shows signs of 
having left room for maneuvering beyond 
its “play-safe” philosophy, should any of 
its coming rivals include some spectacular 
innovation. It retains both one-byte and 
two-byte undefined opcodes. If you have 
lots of opcodes, and the only value of a 
“ninth-bit” is to economize on one-byte 
codes,, why bother with the complexities 
of status-bit redefinition? 

No design has yet used a status-bit 
to redefine completely the operation of 
an opcode bit-pattern (as a “leading- 
byte” does). However, the philosophic 
difference between the Z-80 and the 
2650 extends to the implementation of 
their somewhat similar substitution of 
one set of on-chip registers for another. 
The Z-80 does this by a one-byte code 
that exchanges the information between 
its “on-line” set and its “off-line” one. 
The 2650 uses a status-bit to “shift” 
operation from one set to the other; this 
makes use of the existing two-byte codes 
for status-bit control, so it would seem 
that lower code-efficiency is being 
traded-off to save one new one-byte 
opcode. However, the possibility exists of 
simultaneously altering other control bits. 
It’s hard to tell whether this would be 
useful often enough to compensate for 
the code-efficiency loss, or even how 
often the alternation of banks of registers 
will be used by programmers. Program¬ 
mers are the third group of cooks in this 
cuisine, no less important than the 
designers and executives who can decide 
what the utensils shall be but not how 
they’ll be used. 

The register-interchange example 
shows that a persistent state can be 
established equally well by an opcode 
byte as by a status bit. However it’s done, 
the programmer has to keep track of 
things. The 6809 has opcodes that cause 
exchange between any pair of its regis¬ 
ters. As with the Z-80, the plethora of 
possible codes allowed lots of new opera¬ 
tions ! 

The non-persistence of “leading-byte” 
modification may seem to be an advan¬ 
tage inimitable by status-bit control, but 
this is not so. A status-bit could be made 
volatile or non-volatile by using a second 
status-bit to control it. Consider the 
6502 decimal-mode bit, and a hypotheti¬ 
cal new control-bit. A “set-both-bits” 
code would be the equivalent of the 
present, persistent SED, reversed only by 
a “clear-both-bits” code. One-time 
operation could be had by a “set- 
decimal-clear-control” code; that would 
cause an automatic clear of the decimal 
bit by execution of any instruction 
involving that bit, making it equivalent to 
a “leading-byte” (except that it would 
not have to precede immediately the 
instruction code). Though not useful in 
the arithmetic context, the principle 
might work out well for status-bit 


shifting of operations like 16-bit vs. 
8-bit mode (for which the 6516 seems 
to have created brand-new opcodes). Of 
course, the same thing could be done 
using two kinds of “leading-byte,” one 
non-persistent (as now practiced) and the 
other persistent until reversed. There is 
some value in having a record of the 
status in a register, for debugging use, 
but the price entails having a second 
status register. I rather like this, since any 
otherwise unused bits could be used 
(2650-style) for some kind of imaginative 
application. 

Although the two modes of opcode 
redefinition could be made equivalent, 
the status-bit mode has in fact only been 
used to redefine a subset of the one-byte 
opcodes that is expected to be used 
repeatedly and exclusively in a subpro¬ 
gram. Persistence is desired, and the gain 
is more in faster execution than in 
economy of one-byte opcodes. The 
“leading-byte” mode could not be 
optimized in the Z-80 (because it 
retained machine-code compatibility 
with the 8080), but it is carefully crafted 
in the 6809, that wisely sacrificed 6800 
machine-code to gain efficiency. The 
“leading-byte” in effect “calls in” a 
new instruction set for a “one-time” 
use. Since this is less code- and time- 


efficient than the single-opcode-byte set, 
the instructions in the two-byte-opcode 
set are those expected to have a lower 
usage frequency. This will be a self- 
fulfilling expectation, since programmers 
will avoid using them wherever possible! 
The 6809 designers, well-aware that 
programmers make the ultimate deci¬ 
sions, studied program usage of the 6800 
set. This kind of systems analysis is no 
doubt better than the inner-meditation 
that must have played a major role in 
the 6800 design. Yet, if the inner- 
mediator is a creative genius he may 
impose his will on programmers. I view 
systems analysts as the contemporary 
incarnations of the minor seers of the 
past, and likewise fated to be auxiliaries 
of the modern equivalent of kings. But 
destiny sporadically spawns a major 
prophet who can break into a truly new 
world. What dinosaur, however skillfully 
optimized, can withstand that? 

The third generation of 8-bit micros 
will have to be more prodigious than the 
earlier ones. The 8080 had no competi¬ 
tion. Now it’s rife, and success will 
require a quantum leap in performance, 
not minor enhancement. I cannot even 
hazard a guess as to how close we are to 
the performance Emits of this level of 
complexity! 



Number 49 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 P a 9 e 23 

374 



a Multiple File 


iflH 


BY LAWRENCE E. HUGHES 

Mycroft Labs, P.0. Box 6045 
Tallahassee, FL 32301 


Transfer Utility 




ill 


lllltc 


This article describes the design and 
use of a utility which makes it practical 
to use a single disk drive on the Digital 
Research CP/M operating system. The 
entire source is included in this article, 
and is also available from the author 
on an 8" single density, 128-byte sector 
diskette, along with a few other public 
domain programs, from the above ad¬ 
dress, for $15. I hereby release MFT into 
the public domain, for use on any CP/M 
(or other) system. No right is granted 
for resale, with or without modifications. 

This program is the fifth generation 
of a mechanism which can transfer files 
from one diskette to another on a single 
drive CP/M system. CP/M was originally 
designed for use on a two-drive system, 
and a reasonable mechanism was provided 
for transferring files from one diskette 
to another (PEP). Unfortunately, no 
provisions were made for owners of one- 
drive systems. A temporary kludge is 
possible, which involves creating a “Pseudo 
drive” B. With this DIOS extension, 
anytime a new drive is accessed (via 
SELDSK), the user is prompted to mount 
the appropriate diskette in the one drive, 
and hit CR when it is mounted. This is 
simple enough to implement (if space is 
available in the DIOS), and it allows use 
of PIP to transfer files, but is somewhat 
clumsy to use, especially with PIP, which 
switches drives several times per file, 
times per file. 

Since it was fairly expensive for me to 
upgrade my single drive Imsai FDC2-1 
to a dual drive FDC2-1, I made several 
attempts to solve the file transfer pro¬ 


blem, with increasing degrees of success. 
Since I now have a dual drive Tarbell 
system, and will probably not be making 
any further improvements to MFT, 
I have decided to release it into the public 
domain. There are probably a number of 
good folk out there who are currently 
using a single drive system, or else are 
holding off on disk altogether until they 
can afford two drives—this program is 
for you! Even owners of dual drive sys¬ 
tems may wish to study this code as an 
example of a fairly elaborate utility which 
interfaces to CP/M. 

The following discussion is intended 
to serve as a guideline to reading the 
code, and was never meant to be parti¬ 
cularly useful without the accompanying 
code. 

Note the use of meaningful symbols 
for the system interface addresses, 
BDOS function codes, and FCB field 
offsets. Note further that all I/O is done 
via BDOS calls. 

The first step is to clear the ‘break 
flags’ (IBFLG and OBFLG). These will 
be explained later. The next step is to 
determine how much RAM is available 
for use as a memory buffer. This is cal¬ 
culated by finding the starting address 
of the BDOS (there is a pointer to it at 
0006H), then subtracting from that the 
starting address of the memory buffer 
(which starts at the end of MFT). Note 
that the buffer size is then rounded down 
to the nearest multiple of 128 bytes. 
The user is then notified of how large 
the memory buffer is (in terms of 128 
byte sectors). 


At this point, the user is asked to 
mount the input disk and type CR. 
This allows the user to transfer files from 
a disk which does not contain MFT. 
Once a CR is typed, if IBFLG is set, 
MFT jumps to MFT2A. IBFLG will 
be set only if we left off reading a file 
in the middle at the end of the last pass. 
On the first pass, the routine CFNT 
will be called to create the File Name 
Table (FNT) from the list of ambiguous 
file names on the command line. The 
pointers IFNTP (pointer to the next file 
to input) and OFNTP (pointer to the 
next file to output) are reset to the 
start of the FNT. 

At MFT2A, the memory buffer point¬ 
er (MBUFP) is reset to the start of the 
memory buffer (MBUF). MSIZE is set 
to the total amount of available memory 
in MBUF. If IBFLG is set, the rest of 
the partially read file from last pass is 
set up for reading where we left off. 
Otherwise, the next available file from 
the FNT is set up for reading, and the 
file size (FSIZE) is set to 0. 

At MFT6, the current file is read 
into memory starting at MBUFP. As 
each sector is read into memory, FSIZE 
is incremented, MSIZE is decremented, 
and MBUFP is advanced 128 bytes. If 
MSIZE reaches 0, MBUF is full, hence 
IBFLG is set, and reading ceases. If 
either MBUF fills, or the end of the 
current file is read, MFT8 is reached. 

At MFT8, the current file is closed, 
and the user is told how many sectors 
were read into MBUF. Then the file 
size (FSIZE) is stored in the FNT (along 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

375 





with the address at which this file started 
in MBUF). IFNTP is updated to point to 
the next file name to read. If IBFLG 
is not set, there must still be room in 
MBUF, so we loop back to MFT3 to 
read another file. 

At MFT9, we either have run out of 
files, or MBUF is full, so we ask the user 
to mount the output disk and type CR. 
When the CR is typed, we make the new 
disk Read/Write (via subroutine RESET). 
If OBFLG is set, we are appending to the 
end of a partially written file, hence we 
reopen it where we left off. If OBFLG 
is not set, we make a new file with the 
name from the FNT which is pointed 
to by OFNTP. Note that we force the 
$R/W and $DIR attribute flags low for 
2.0 users (can’t write to an R/O file). 
We fetch the file size (into FSIZE) 
from the FNT (at OFNTP). As each 
sector is written, FSIZE is decremented 
an MBUFP is advanced 128 bytes, until 
FSIZE is 0. At this point, the file is 
closed. We then tell the user how many 
sectors were written, and loop to MFTA. 
If the last file was only partially written 
(IBFLG was set), then we set OBFLG. 
When we finish the last file that was 
read into MBUF, we jump to MFTF. 
At this point, if IBFLG is set, we loop 
to MFT1 and repeat this cycle until 
all files in the FNT have been trans¬ 
ferred. 

The subroutines are not described in 
this article, since what they do is fairly ob¬ 


vious. Pay particular attention to GFN 
and CFNT: all the others are trivial. 

Note that a fair amount of error hand¬ 
ling is included at various points in MFT 
to catch things like ‘No such files’, 
‘disk full’, etc. Note also that as files 
are transferred, the user is informed as 
to what is going on. This is especially 
important in a program such as this, 
where the machine could be busy for 
many minutes. 

As far as style goes, note that the main 
program comes first, followed by all 
subroutines, then the messages, and final¬ 
ly by the RAM storage. The use of semi¬ 
colons to denote comments is consistent 
throughout, and makes it easy to deter¬ 
mine where the different parts of the pro¬ 
gram lie. 

For further information on the con¬ 
ventions of interfacing to CP/M, consult 
the excellent Digital Research manual 
set. 

To use MFT, merely type its name, 
followed by one or more ambiguous 
file names (using ? and/or * wildcards). 
You will be prompted to mount the input 
disk and type CR. At this time the disk 
with MFT may be removed, if the desired 
files are on a different disk. Once the 
input disk is mounted, the directory 
will be searched and a list of all file names 
which satisfy at least one of the ambi¬ 
guous file names will be compiled. As 
many files as will fit into memory will 
then be read. You will then be asked to 


mount the output disk and type CR. 
Note that MFT can write on this disk 
without your having to ‘log it in’. All 
data read from the input disk is then 
written to the output disk. If more 
files remain to be read, this cycle repeats 
until all files are transferred. As an ex¬ 
ample, MFT *.* may be used to copy 
all files from one disk to another. 


Lawrence Hughes is a Computer 
Research Specialist at Florida State 
University by day, and runs My- 
croft Labs by night. He works with 
micro software in both pursuits. 
He is the organizer and current 
director of the Tallahassee Amateur 
Computer Society, and past vice 
president of the Atlanta Com¬ 
puter Society. He owns an Imsai 
with 64K, dual 8” floppies, Heath 
H-19, Decwriter, Hayes modem 
and Hiplot plotter. His computer’s 
name is Seymour and has the dis¬ 
tinction of being the first home 
computer to be listed in the Atlanta 
phone directory (under Computer, 
Seymour T.). 







o 

u 


as 

cj 


O as 
as u 
H H Cx, 
Z Z Cl, 
M O 3 
OUffl 


Cxi 2C 3E 
Cxi Cxi 
CO H H 
O CO CO 


Cxi 

Cxi J H 

JO CO 

OCOiC cxj cc 
CO 2 CO UJ H 

Z o H J H II 

O CJ o H U. 

O Cl, X 

Cxi H Cxi U 

Q H Cxi Z CO 0= 

<H(OUO< 
Cxi OS Cxi flu J Cxi 
K JKOUIO 


a 

H Cxi Q CC CO 

X J K O CO 

Cxi »-) O CJ Cxi Cxi 

Z Cx, CJ Cxi J OS 

Cxi cc n a 

I Cxi CC Cx. Q 
OH Cxi 4 

OS Cxi O H Cxi 

< J < H bC H 

Cxi Cxi Cxi OS 4 Cxi 

CO Q CC 3 X CO 


Cx] 

CO H 
Cx. Cxi 
H H Cx, CO 
Cxi Cxi O Cx, 
CO CO Cx. 
Cl, Cx, OS O 
Cx. Cx. Cxi 

O O CQ Q 
ST OS 
Cxi Cxi 3 O 
SO.ZO 
4 >-. Cxi 
Z H H cc 


H H X Cxi 
Cx. Cx, Cxi Z 




Cx] 

N Cxi 
M N 
CO 

CO 


Cxi CC 
Cxi Cx. Cxi 
Z Cx. Cx, 
O 3 Cx, 


H CO 

u co - 


Cxi 

Cx. 

Cx. 

3 

CQ 

Cx. 

O 

Cxi 

N 


CO 


CO 

OS 

o 

H 

O 

Cxi 

CO 


X 

CO 


o 


Cxi I 
CO H 
Z X 
O Z 
O. 4 
CO 

Cxi Cx. 
OS M 


OS Cxi Cxi Cxi 

H Cxi H H H 

CQ > tH M 

3 4 OS OS OS 

CO CO 3 3 3 



Q O. 
<c O 
Cxi O 
CC 3 



XII 

inuo 
o in co 
o o o 
o o o 


HO O O 

I CO co O J J 

o - 2 : co cx. cx. 

O CL >4 CO CQ 

«- CO I 3 4 M O 


HI J I - 

z - - o 

Cx] Q Q 4 CO - 


C Cxi J 4 Q I 


I o 
- - - a. 

: j 4 o i i co 


Cxi o Cx] o 
CJ CO CJ O O CO CJ 
4H043ICO 
4 a. o J 


I 3 CO » I 3 


CO CJ o »- 

1 CO U H 

- 4 4 CC Cx. 

I 3 OS O X 


3 3 3 

ooo 

Cxi Cxi Cxi 


3 3 

cr o 

Cxi Cxi 


333333333333 

000000000000 

CiiCiiCiiCxiCxiCxiCxiCiiCxiCxiCiiCxi 


3 3 3 3 

o o o o 

Cxi Cxi Cxi Cxi 


a a j a j j 

J*—>cn>>ai> q>mm>xjhjjjhj 
I X 4 O Z O X 0300030 40>CJ0CJIX4I4X4 

j j q i < i j scosscor q r 14 ran juju ju 


M J J M N 
X 4 4 O. Z 
J O O O -3 


as CQ Cx. 
H CJ 3 
z cx, m 
CxlHQ 


CJCJOCJOCJCJCJOCJCJO 

Cx,Cx.Cl,Cx.Cl.Cx.Cx.Cx,Cl,Cx.Cx.Cx. 

OCJQCx.Cx.Ct.ZCx.QCaSCx.4 

as3cqocjcocoaas32:co 


in cj o 
o in co 
ooo 
ooo 


o o 
o o 
o o 


cm q ti. o i- (\i m? inio 4 
0000 »— 

oooooooooooo 

oooooooooooo 


^ cr, cj o 
O O O CM 

o o o o 
o o o o 


4 in -=r cq m 

ooo o o 

•- t— Cxi -3- m 

Q ctn ao <y> (O' 

*- •— a Cx. CM CM 

m cm cj 4 m co 


o o o o o o o 


o Cx. 03 

O Cx. o 

v£> 4 O \0 

o Cx, co cr 

4 •— O' Q vO Cx, «— Q CO Cx. CJ 4 H 

CM •“ «— f— Cx] *0 «— HCT'vOHCTS'O 


4 in 3 4 -9 in - 3 - 
o o o o o o o 

O O «- CM Cxi «- CM «- Cxi 

O O Q 4 CO Q 4 CQ CO 

CT'CJCxiCiiHCQCM*-040*— Q 
(MvOfOO'OCM(M(MU(MUIMU 


O co vO H CO 4 

ooooooo oooooo ooooooooooooo 


in xt in «- 

ooo o 

cj Cxi »- o »— 

ca co o o -xr 

*- Q Q Cxi CM 

CM O O Cx, O 

«- - 3 - H 4 CJ 


o o o o o 



Number 49 

376 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 25 









05 
05 E- 
O 

f- -J 
U t 
b] X 

to ce 
o 

t- Z 

u u. 


a a. 
< X 
bl 3 


H bu 
2 3 

o m 
u x 


u u 
CO E- 
O M 


3 a. 

o 
w o 

05 J 


x e- 

u o 

H Z 


O w Ou 
I CO X 
U U 3 
b) 05 3 


“op 

:i 

s| 

o § 

a. J 


3 z Q 
U. bu Q 

CO 

=> 3 
O a. 

M H 
> 3 
b] O 
05 

a. a. 


Z O M 
b. “to 

H I [u 


t" CO to CJ CO Ci. CM 
E- HXCOH3- 
bu bu - «* u. m 
S X *- X X Z X X 


QQXU-XbuXZX-CJXXQOaxCMQcOObuZZZ 


O 3 X Id U O 
JOQWNUtOU 
U.QHOHJXtO 
b) J tO Q 


: to CJ E-> O to bu 
-CCCCbubObJm 

: z ce cj 3E z as o 


< u. t mu z h 
HOH m>UZ 


x o q a 

«C X X _] i-H J 

H Z O X X X 

to H X CO J to 


Q ° J J JO 03000 

•J J J C M HJO.J»HQJJXJ-JXJ><MMI-l> 
35 O <<05Na.NX<CXXX«CXXZXXOXOXZXX: 
*JX OCJO3O3Jt_>3O-4Qt0Jt-(t0-JQC0XO3Jj: 


J _J _J Q _J _J 

«*>HX«S<X<X«C 

OXtO-JOOJOJO 


Q a Q o 

JXj>x>xj«s«s 
XOXOZOZXOQCN 
jxjrHiHWjoT 


J J -< 

■t J J M M J J - 


x«j;««a,z«C'<QKNXX><s:<x 

J00030CJ003-J.JXOCJJ 


J J Q 
.....400 
X > <c <£ x 


mom 
o o o 

m o f- 

(\l O (\1 

cm on m cm »— cm 

•- •- b] CVJ <M f\J 

U Q U b. (NI ID 

u u u u o o 

CM CM 

o o o o o o 


ffl in in c\j t\i«?mao 
° o o o oooooo 

t*. m co .=T«-»—<\jw«-buO 
^ r~cvi CMOinoooincMoo 
«<m ooe»<u<'-om«c>- 
Cvjtil UOnUtbUIMOUtM'* 

com u h. cm co i 


m o in in 
o o o o 
« o ms 

1 (\l O' O C7< co s m 


mm m «c «s cm o m 

oo oo o ooo 

bu c~- on m co o 

cm CM CM Q o O lO i'i m ui u o' 

0'fVI<fn(M«<m(\IOin(\Jr->-'OQU(\l*-QQ 

•— fMOMCMCMCMCMCMt^mcJCM*— OC 4 rOm»— OO 

)WOUWm'OCOmU--3l-.<mU--NimoCJ'OQUr-4M3'OU'-3S 
oooo<->-"-'-'-'-(\i(\i(M(\i(\i(\immmmmmmm4 334j4inioin 
(M(M<MCMCMCMCMCMCMCMCMCMCMCM<MCMCMCMCM<MCMCM(MCMCMCM(MCM<MtMCMCMCM 
ooooooooooooooooooooooooooooooooo 


m ^ ^ 7 
o o o o 
r- (\i o u 

CM < «- CO 

«« Q «- Q 

CM O CM O 

< o o m 
in in vo vo 
CM CM CM CM 
O O O O 


vOO'<QUUO>-7t“eO 
vOvOvOvOvOvO C"^ C— C— 0- t— 
tMCMCM<MCMCMCMCMCMCM(M 
OOOOOOOOOOO 


_ - _. -; in m cm m o min m 

ooo oooo ooo ooo 

Q CM o •— OO O' Q 

m in in cm o' «— cm 

- vo o a < 

- O O O CM 


O Ci) «- Q mooou. 
cm co o o r-cnoav w u< u< v 
•-QQM CMQQ«*!t^-<»-«— v 

cm (J o bu ooommor 


mw«-7r voo'Ob.cMmioo'OU’-s 

c— c— CO CO CO CO CO CO O' O' O' O' O' O' < < 
CM CM CM CM CMCMCMCMCMCMCMCMCMCMCMCM 
OOOO oooooooooooo 


O Ou 
X X 
C 3 


J O 
E- HH 05 
Z E- b) 
U 2 N 
X 3 


b] 


Cm3 


05 a. CC 
OOO 
b] O E— 
Q J CO 


b] V) 
CC U 
O 05 


E- Q 
3 Z 
a. ci] 


H U 
Z X 
bu < 


Ci) E- 
> i—c 

<C CC 

V) Z 


a o 

j j 

O bu 

b: m 


bu bu 
3 3 

m m 
o o x 


xomx<xooi 


uu uu 

30. HtbQ.DO.UIUO 
mb.HZHHfflIi.ONJ 
CJ3ZbuZZX3«<t-Hbu 
-mb. - b. bu -ma.com 
CQXOOXI-IOXXCO 


o o 

cn b. b. on bl 
E-« m E-» cn> 
I/IW bu - - -o 
x>-i«s:Xxomx • 


a o n x z x 


w z 

<C bu 
Z t-H 


< X O' 

: X bu H - 
. - bu bu 

C c o x a 


m m m z E-* 
UUUblZ 
■ - «C - «< b. bu b. Q. bu 

<XZXZ<E-*E-*C-*OM 


- > Z E-* CO X CO 


....>X>XCXQ 5 CM«X<»H 0 _J»-H 0 JM 0 JJ<X'< HHHJ<<H<JH 
XXOZOZE— ZC_)ZCCH-XX«CXXXXXXXQCCMXX5»«Ctx:E-*>E-'XX 

'XHZHtl)HQ’]XfflJtQUJIOV)J(OJtl]JO']JJSUXtOXfflJJ 


O -J ooo 
OJHJHJJXCU 

«xx«xx-*xox 

QtOjOjOJX3 


-J > t-H ► 

x o m m : 

J X o 3 3 


-3 O — 

x>cxx<x«*:xhhh««x 

-IXOtOjOjOXCOtOtOOJ 


_] a o O X 
_]JX_J>«CX> 
<CXOXOHZO 
.JXtOHZ 


O' O' t» 
Q < H- CM 
u mm u 


oooo 


o o c 

o in 

co o vi 

*-<-vofnb]rncMfnincMb.cM«-(MQ 

CM*-7(MH-(M'-'-00<'-CMCM0 


<cm7rvommmm<c<m 
OOOOOOOOOOO 
ininiiiomovoiu'-mj 
Q CM •“ O' CM CM O' CM O O O' 


*— m o m 
ooo o 
v- *- O *- oo 
u min cm o' 


m m m a. 

O O O bu 

»■—inmu 

O' O O' CM U 


m o m 7T m «- 
oooooo o 

m o u *- co m in 

CM in oo bu CO CM bu 


J O mm 0 7 lb 7 oo 

3 O OOOOOO OO 

jr- omcomob]*-ci] ooo 

- o in o o cm in to u co in vo 

--vOQCM*-Qv-QbuCMCM 


CM t— bu o m cm-oucmcmUcmu 


6 m c 


o in m m 

ooo o 

o ov m tu 

(— »—CM CM 

CMO<ffl<U(MmQ 

mUCMU(MHr-^ s 



Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

377 













lllllllllllllli 



u 

H 

H 


O 


faJ 

N 


03 

C_> 

u. 

E- 



E-* 

hi 

CO 


o 


fa. 

03 


x 


Qu 

O 


U 

M 

M X 


to - 

III. < J 


03 03 U* 

C_> C_> O 

uu.u,muai 
H H O OO > Q 
fa. - - - O - 

X X Q ID I Q 


C Q 

x td a 
Q to U to U 
HOinHXtO 
u J in [i. - <c 

to U (M £ I 3 


u 

u o o 

N U tO U < J 

H J I w h It 

tO Q - « fa. 03 

x z x z x »-i 


h 

bu 

X o 


u 

to X > 

fa] o 

z < i a q 1 r 


Q J J J X 

XX><NMtHt-HX*-*XXlHt'JtH.J 

oxoa:zxx>'<x«c<a.zx<c 

QCOXO-3XXXOXOCJO-3XO 


Q -J 
J J 
X «< 
X u 


J Q. < 

«s x a 

o -a 


< N O. 
OC Z X 
O ~3 O 


X 

> X < X K N h 
O Z H Z O Z faJ 
X H (O H Q T tt 


t- 

b) 

o 


z 

bu 

O 


X 

u 

O Cl. «- 

X - Z Z X 

- bu bu - 

«C«S - C3XOQ«tQQQX 


Q a 03 o Q c 


(M (> in *- 

z - z z z 

b* • fa. bu bu 

CJ3 - UQQOOU 


z - 
bu - 
U < Q 


>«C HNXft.H<<XK]HH<XINtt.H>< XM M M 4X1 O.K M< 

OZNa.ZZXXKf-ZX>>(-ZOZO>OKtMZXNOuMOuMHZOMXOM>H 

XOIUTH-JJXtOHU.XXWHQ’lO.XZO-HHUTUTU-JtOHQ’lTQTi;!/) 


bu 

E- 

bu 

X 




o 


bu 

O 


fa. 

O 


bu 

a 


m 

C\J 


X oo o x m o in in 

o ooo oooo 

t~- moc\j»-cooroc—Lu 

eg mirunni O'® t-mbu 

c\ioif>(\i«—*-voa*-Qactf 
(Mt-CDUtM'-OU'-UUti. 


1*14)4 
OOO 
bu m u 
f—VOCO 

CM *- Q 
o eg o 


to ^ 45 ^ nj x 
o o o o o o 
OiNinua? 
CM < C- CO X O' 
<C Q •— Q no c 
eg o eg o o en 


«— o 

o O 
«- o 

JT O 
MM 1*1 
X O O 


en 

o 

co 

O' 

u m (M m in t\i O' 
f- eg •— «- o o t_> 


en en x 

o o o 

o Q «— on 

eg «e <m 

t-CO U (M 1*11*1.- 

cn o bu o eg o •- 


X O 
o eg 

ti. (M 1*1 in M3 u w 
«c q o m «— 


no 

o 

CO O' 

X o 

no in eg «— vo 

«- o o a o 


4 - 4 en en 

o ooo 

< 04Ui-<lfc 

«- eg «- esi bu eg a 

lilt--4r*itil<Iil<til<(M 

n-xoegtuotuobuo*- 


4 en on 

o o o 

CJ «“ *< fa. 

*- O td on 

in «*: en in < w eg 

o o o o o on *- 


Maoxt_JQoen\ocoxw*-.=r'oo'CJbueginooxM »— eg in 

ninininin'O'O'O'O'O'on-c— t~- e- e— r— co co co co ao O'O'O' 
■nonmenenenenenmenenenenenonenmenenononen en en en 

OOOOOOOOOOOOOOOOOOOOOO OOO 


co O' «C X O Q o 
O' O' O' O' O' O' «c 
en en no no en no en 

o o o o o o o 


•— egn r izrg30'CQO'-egm-3'vnxo' < cxxbu'— egenvoMO'Ow*— mmn-xo'ObuOenin 
<»(«S<<«S<C<CQXXXXXXXXXXXOOOOOCJtJOC3QQQQQQQWWW 
(*if*ii*i(*i(*i(ni*i(*)f*i(*i(*ii*imi*i(*ii*i(*i(*i(*it*it*im(*i(nf*ii*i(*i(*i(n(nfnm(*i(*i(*imi*imen 
ooooooooooooooooooooooooooooooooooooooo 


in llllllllllllllllll .IHIIIIU iiiJIIIIIIIII illlllllllliu :|lli!llillliu . illilllllliy Illlllllllli ' IIIIIIIIIIH IIIIH 


X 


so 


X o 

4 H bu O to U X 

I Z H to X to H 

- bu - < » < fa. 

QQOI3I3X 


X X vO 

X t_> X O O 

H XXX X*— WHXOMU 

ZX HXH H->ZH«XW 

X - XXX “ -ox - <£ - < 

occxoxxacoxoxzxz 


X Z O' O' «- «- X 

+ + ++++ O X 

XXXX XX XHU XtOUUH 

••oejoxuoxujSKiinHXXHz 


ouooxooxojxinE-: 

XXXXXXXXXX«*inX-«suuuu - - uj - - 

<E-E-'E-*Ht-HE-<t^E-'OXfgXXZXO QXWX X Q X faJ X 


X X 


V) VI X to - 


Q X 
H X 
X X 


X co 


a — ~ 
Qtoooxeg 

E- X CO El O 


O fa. < X X X CO S «C X X 


X bj 

X N 

. __ X M 

— XX- XX 

z x x a a x x 


m a j m j i 
x c x x «s : 
X O CO J O . 


I X X 
: < X 

I U X 


csj 


x o x m x n : 
X X O X CJ X ► 


x Q —1 —J _!_■ >u u U H u U M U W M U M o hU hj nJX Q Q 

iXX»-ixi-tx«c«s«*««-<M«a:«s:'-i««xx*HtMnjxx >x>xxjk>x;>>i;xxxxxx>«* xxxx< mxxxmqxx 
-«XX*<X*CXE-*H t-QZe-QZE-«C«:XZX<XX OZOZOXOOZOZOXXOXXOXNXO<<XMX<XXX<XX 
OXXCJJC_>XXXXX*»:XX<XUOOXXUXXXlHXMXXXXi-HXt-HXXXXXXXOXXXOOOXXCJ>XXXQXX 


U Q Q O Q Q 

— ^-^>^xxxxxxx>«s 

OOZOZOXXOXXOI 


Q O X X 
X X X X «s 


— a 

4 X CU X t 


a q 
Q X X 


d 

c 


4 oo4 in^ cn 

4 o o o o o o 

) QQUr-UO 

4 cgincocuco*- 

- O' CM •— Q «— £3 eo 

- r- eg eg o eg o o 


— N<CQbl'-4S«C 

egegegegegegegeg 

oooooooo 


en en o maio-tinu 

o o o oooooo 

U O til QXcOQQW*-b3 

co bu co inotJ'eginoobuco 


oooo o o 

oooo o o 

ocooinbuin'oc 

inioMOStoot 


o in in en vn -o- en m 
ooo ooooo 
io to in b o n u in a 
sO-4 in bu *— moo o* eg 


ffl 03 

o o 

M O' 

eg eg 


m m 
o o 
a t~- 

eg eg 


en m 
o o 

o bu 

vo eg 


t*i >0 4 enm o 
oooooo 
<c til fa] in bu o 
4 4 CO O' eg CO 


m tn 
o o 
bu C~- 


QO'-(gint'<tafalOeOinO'Oti4(gm'0 0'Utii*-4t'0'Ubu(g4t'<QOe03-iniONCOaiUOtiHt.O'-4MDttlfalbuO(*l'0['<Ofal'-4N<QO'-4 

fflocjoooooooQQQQQfaibifajfaifaJCdbufaubufa.bufa.ooooo'— egegegegegegegeg en en en en en en en 4 4 4 4 4 in in in 

cgcgegegegcgegegcgegegegcgegcgegcgcgegfgcgegegegegcgegenmenenmennnnoenennnenmennnenenennnenennnnnnnenenenenennnenennnenenenenmmen 

ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooc 


Page 28 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 

378 


Number 49 







O to 


UJ X 
H W 
X z 


Du J 
< 
- z 
z t-i 

Dd O 

e- Da 
h a 

M 

as o 
» t— 


U 33 
as o 
S K 


X to 

H < 
in -J 


■ «- + o 


E- O 
M Z 

to Da 


X CQ 

Du u z no «- 

Du Cl- X HE-* 

o x o in z z 

- - OS in Du Du 

ZQtOWUO 


OQoQOQOQ Q 

--Z -Z -z -z - - z 

'a^QZOZOZaaaZC 


U < U J < Q 


to a o qo a - cj *- o - u 

- z z - z - z -< - -o«e 

:zozo«*oz«»:cqz«s:zco<j:- z 


x o co cu 


H H J H N B. 

> x x a. z SE 
I j o im 


> «S _J X CU 

O as N «s z ac 

«E O as o *"3 


XXX -j J J J J 

tOtQtOHH— 3|—|-1>-U-1|— 11 ■—■ I—I 1 n. ft. n, u 
???t^m X<><<><<><><OOOI,J 


< > to :» > cq >■ £ca.a>«tN><NHa.H>Hi 
*oxooaaooz:E<oaszoasz>a:>oa: 
isrcoszaEtorxu-ixaroxaio-aazxJEa:-*:* 


x x x x 
to to to to 

X X X X 
a. cu cu cu 


Q Q 
Q Q 

z z 
* z 


03 in =t =r 

o o o o 

h mm k, < j 

Eu t-co (u in (M 

>fl •- o id (\j ro 

no «- o Du o o 

td o no io oo cq 

t— CO CO CO CO CD 

3 ^ 3 

o o o o o o 


u Du o in 

OO CO O' CT> O' O' 

•a- .s- a- ■=»■ -a- 

o o o o o o 


Q CM <S CM 
O Cu O Du 
Id Q Id ^ 
no o no o 


o o o o 


f^^ma-o-aoao -s 

tMtSoOOOOOO O 

OOCQaOCQ^-CQ^CCQ'-'-m 
O'-Uidu 1 0UOOOOU 
ininin>o^Q r -Q^Q^Q f -^jQ^^ f .(ji 

IdQUO--U^ Ur -(j r - u ^oOUQIdU 

tMm^ins<Qom'CCMJIu(M^NCO(J'< 

<<<<<< <ffl(D[n(ofl J fl ) ouuuoo 


o o o o o o 


ooooooooooooo 


O «*Q < ON 

o a o Da Da cm Du o m lu 

C*JQnOCuCJ<r— «XOC'OC7'0'«-CMCOOfMDUOOvOO''*JrO 
of-0"Ot-0"oaoo»-t^a3ot^cQorouor'-cjtj 

COQDaDuO*-CMrOiOt'-««a30QO*-CMint— <OQtu 
UO'JUQQQQQQQQQQIdldldldldtdldldld 

OOOOOOOOOOOOOOOOOOOOOOO 


cm on a- in 
Du Cu Du Du 
S ^ ^ S 

o o o o 


cu Da 
Du 

X Du 


B. 2 J h 


Id < D K 

OtO-lZ 


a. c 
o Da 
o J 


Z 3E - Z 


SOI - o - O Q Q C 


in Id O CQ t— Du 

Hcua. cu cm o «- + o Du mo o «- x 

2 H D. Du 8— CO O C— m Du X E-CuOtOUH CQ 

^*31 zxzsrtoz oxomzxcoxtoz <o Q 

-turn- Cu CQ Du - ■< Cu Du - K in D. - «C - «t Cu - « 

s H O < < OOOXZO<XQcOCMOXZX zcjro_jxxxxxxoo 


-o - -o 


« a, >_... 

: a: o cu z z x ___ 

<-5a:oxHja:a:ox 


N x M H > < X *-H «-H <CXK CUBS w ... 

OKNZIUNfl.NHZONSUN>(-ZZICIdh[d 
—-OTUOlO» ,/ '““ ~ — — — - - — --— 


! X O. < H U h 
suiMiUN^r-ZZEIdhld 
caTTOTItOHIxetOK 


a a 

t-t j j > «< 
x x x o as t 
Jto JZOC 


J Q J J J 

cxzx-sjEash-x-scuzxcx 

omjUTXidJuo^Juj 


-J o a o j 

J(Ut-H>HHQQQQQ»HaXJXuH>Jl-lh 

<xxo><-<«s<«*:x-<oxo>«<x: 

ox«*a:2:c3QaQQJcjxjx2:oJ3 


j o a 

j i j 
«fi O X 
o x to 


ca c os < o <c 

— CM*- t-~ O •- CM *- v 

Mm[dIdCM(*1*-'OIdt^<mId<Id' 


■OMuUlM' 


-CQOCMtuODuO 


o o 
o m 
*- Du 

cm coin < no in 


«*roi/-i«CDacMromcuO'f-0' 


- o o o o o no 


o «s o m o 


d)N<a3QO'-S'OMDfflU[d'-IOiOMOO'ODuOfnin>ON<ffltJQ 

CdCdDdldldluCuCuCuCuDuCuDuDuOOOOOOOO*— *—*—*—•—*— •— *— •— 
CO IO CO to CO CO (O CO OO COCOIOCOCOSSSSSSSSSSSSSSSSS 

ooooooooooooooooooooooooooooooo 


o o o 
o m in 
O' CM CM 
*- CM < Id n- 
(M CM CM N 

U3 «- a- n- co 
*- CM CM CM CM 

a- a- a a a- 
o o o o o 


on CD -s ms s 
o o o o o o 
■- in uvo id s 

< CM COQCO CM 
CO Q CM CM *- Q CO Du CM 
UOCMQ(MOU<CO 


aocninamainaa c 

ooooooooo c 

DuCOIuti.<S[din IdSCO O C 

f'-f-p-iuint'-coiu co cm o o a 

*“ Q td CM — Q <— Q COH)Ifc>0(MMJ\0'0'' 

^ O Du U CM U CM O O Da \0 CM CM CM CM CM CM r 


m m vo ro X 

o o o o o 

CD U CO CO S CO CD 

CM O O' CO O CO CM 

3<a3'OQr-sOOCQCM 
JCMldOUCMOUIdCM 


0'«CQoromcy>OQonovncofflDa 
(MCMCMCOCOCOCOCOCOSS 
ssssssssss 


C-<UQB.O^CMC03l-COO'UQIi,(MinC'<D 
s s in ininininininiovovovovovoiovovoiomn-t^n-o-n 
a a 


oooooooooooooooooooooooooooooooooooooo 


Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 29 

379 






IIIIIIIIIIHIIIIIIIIIIIIIIH llllllllllil 


xonauunax 


xomooumox 


XQCQOWpaQX 


- X 

xamuuxox 


WWWHHJO.H6.H 

3DDXXOOOU 


XXX J 

DXDXXOOOM 

a.a.a.j£ua.a.Q.B: 


XXX J 

WWMHH JO.O.O.H 
D3DXXOOOU 

a-a.a.jzuik.a.a.(e 


XXX -J 
WWWh 

a.o.p.zUQ.a.a.E 


XXX _] 
viiO(OHja.a.a.H 
3XX><OOOW 
a.a.a.£ua.a.o.c 


xxx j 

MMWHJo.a.a,H 

D3DXOOOW 

a.a.a.sua.a.a,E 


o m in 
in •- o 

inmini-UQ'-'---^ 

UQU'-OUUQUU 

'ONCO»UU'-(\|l»l» 
^^^^a^tnininin 
in in in in in in in in in in 
oooooooooo 


u so in 
in •- o 

inmin>-ujQ'-*-*-oi 
U QU--OUUQUU 

iruONCOfflQO'-tVM 

ininininininioio>oio 

ininininmininininin 

oooooooooo 


=r in«0N<UGuO^ft| 
vOvOvOvOvOvOvOf— 
in in in in in in n in in in 
oooooooooo 


ininmuQ'-'-'-oi 

uoooooouo 

invo ao m o o ci] 
t— e— e— t— r— t— t— t— c— 
inminmininininin 
ooooooooo 


«- o 

mininc«]Q*-»-*-cTv 

UQUOUUQUU 

Ci*0*-<\J-»t'-000'< 

inininmininininin 

ooooooooo 


mininci]Q*-»-«-ov 

waooooawo 

moQworrxrinvo 

CO CO CO CO O' C7v O' O' O' 
inininmininininin 
ooooooooo 


» « H :* 

- *2 M 

uuua.HQX 


XQfflUUfflQl 


XQXQOUXQX 


XQfflQOUXQX 


x q maoumox 


H>Jo.a.o.a.h 

>0«SOOOOCi] 

zzua.a.a.a.c 


S X X J 

(on«Hjfl.a.a.H 

ooo>«sooow 

a.a.a.zua.a.a.c 


XXX _J 

(OcoiOHja.a.a.H 

000>«*OOOCil 

Q.a,a.i;ua,a.a.a: 


XXX -J 

OOOX><OOOCi] 

a.a.a.jxoa.a.a.ce 


xxx j 

wwwHHjtt.eua.h 

OOOX><OOOCi] 

emi jrua.o.a,K 


Xxx J 

Wiowhh ja.o.ii.h 
=*OOX><OOOCi] 
a 'Q-a.J3:oQ.a.a.x 


UJfcuQ*— O' 

omotOQUo 


Page 30 

380 


*- in 
o o 

inininc*3Q*-*-«-o' 

lOQOOOUQUO 

»-Nm5>DO'<tiao 

ooooooooo 

inininmininininin 

ooooooooo 


Q m 
o o 

in ui in u D o< 

ttQOOOOQUO 

Q U It. O IM in>o SCO 
OOO*— 

minininmmmmm 

ooooooooo 


o Ci* in 
moo 

mmm*-MQ»-«— •-o' 
Ci]QO»-OOOQCiao 

oxfflot'-s mios 

•—•—•—•—•— CVJ(\JCVJC\IC\J 

mmmmmmmmmm 

oooooooooo 


a) o>< o u om? in>o 
cm (\i im (\i i\i m m m m m 
mmmmmmmmmm 
oooooooooo 


^mm'-tuQr-'-'-o' 

UQU'-OOUQIilU 

C— CO 0<< Q Cu tv in 

Mmmmmmmmmm 

Oooooooooo 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 





o 

CQCQCQCQmCDCQCQCQCQmCQCQCQ CQ K CO 

QQQQQQQQQQQQQQ Q O Q 


. CO 

>-(\imsif('os®CT><aioo(ii o 

ooooooooooouoo « h 

COCOCOCOCOCOCOCOCOCOCOCOCOCO Cd z 

ZZZZZZZZZZZZZZ N Cb 


x> ir\ -r oo^auiMCJs 

IT» vO C*- X vO V£>C— 

O'omu^o^s-muwu.cMon o 
CMvOvOvOt— Of-vOvOvOvOvOvOv£> O 
svoiniouou.'-irun'-iM'-in o 

in'OvON'OfNl'O'O'Ot-'DC-vO'O O 
Oifimi«,o>QWinmu.UMWrn O 
=2 SC''Ot-(NJ'0'£)t-'0'ON'Ot- O 
QNOQmooNOflinifuno o 


t»N»-U>Of-lM\l001Dlilcnin CO O O 

a\<mtDQii.u.O'-c'jrcisvON co o> a» 

tnirunuurtiru^vOvo<£\otoiO'0 vo vo 

oooooooooooooo o o o 



— o < x z cm cd 

H Cb OlflJli.CMt'OOSO'UUOflXUQN 

2 3 22[i.DHHHhOOOli.U.i-Ul<.QH 

CbCQZCbCbfflCQCbCbCbCbCOCOCOCbOCdKCJZCO 

oacbOOMxxxxxxxxoKcoiozsx 

sO'-Q03'dQ3mmuoiriii.cimcDW<a\ 
(Vl00O<*-O'O'C'(MM(J'O>-SOOSe0Oa(M 
cr ooooa- co cq •— c\j mcniT'vovo o o in in o ao 
ooooooooooooooooooooo 


H -a-CT'W'-'oaatb coco QffluuiOQn 

z ZZZXHHt-HOOOOCbCbOlOOO 

CbcexCbCbCb<CbCbCb(bCOcocoCbU<cc<z[b 

oocdoooxxxxxxxxooetocoszx 

'-OO^'-lilinSO'-BIBO'CMnO'-C'COUN 
o o m fciin<-CMfncnin>oiofflooin3^ co 
ooooooooooooooooooooo 


Cd X O Cd Cd 

u to E moo «£ Cd CM t— UJUUUUQh 

U.Ot-< ZZ hhhf-OUOU.UIi.<UQH 

(b_Jzt->CbCbCbU.(bCbCbCOcococo<ta:a.<czcE: 

OOCdCbOO-JXXXXXXXOKKCOZZZ 

ONlC\0"Otb<OlflQ[bCMlMdin*-3'-Wta^ 

•-mOOtbOOOCbC0r-<Cb-3'C7'O»-QtbOv£) 

oinoomaO'-'-(MroininiciDino<3»in 

ooooooooooooooooooooo 


> z cc z 

■HCCUH 
) K U H O 

l O. H z a. 

J Z l-t 
EHOK 
: o o a. [d 
ItbO. Cb 

t— Cb c 

J Cd H z O CQ C 

INZlbfflUl 
IHIb Cb 

) CO XX 8 

H D K H : 

i cd o a, o o c 

j —j a. x x Ou t 

« M Z O Cd z : 

• Cb t—t O X M ( 


a. m Cd a. Xu 

CbXOt'JfMt'-XOmo'Q»-vOCQ z u u U J u cococococococococococococococo 

OZCbt-HZZZCbXXXOOO Cd CO Cb O O Cb QQQQQQQQOQQQQQQ 

(&CbCbC0CbCbCbCbCbCbCbC0(Ocoa:a.CdzCbCda: 

OOQCbCJOnXXXXXXXZOaccOXZZ 


in<mx»-CbCQvo»-ai«<x*-aJoa'Q<MOcoir> 
CMin*-CMCbacM«-ox.3-CT'Cbm<M«-o*-ino'*- 
m 3 ocommcoo «- <\j micunvo o inino o^ o 
OOOOOOOOOOOOOOOOOOOOO 


x cd cd ••a.cdcda.a.a..o o 

OOMCbCbMMXXlbP3CQCD_J_J 

<<MOOI-tMZZOOCJC_)CbCb 

Ha.COCQCQCOCOCbCbCQCbCbCbCQCQ 

COCOXOCJCbXMOXMOXMO 


cm a. «s id o. x co 

XX r -iflfflU.tMcoQUlf'<NhQUUUQO 
z-JXZzc_)oxxH>oo*Hz««Cb««ZQac 
CbCdZCbCbCbCQCbCbCbOCOCOCOCbCdCbXOZCd 
oacbUoxxxxxxxxxoKcocozxcM 


ir*cj'00»-co»-Cb'-*-ocovoomQco»-»-CM«<oo r-^fnicMCM^o>ajQtb'-(\imsin 
Q m JT ONOCOmCMvOinvOCTNOCMOCMCM*- CfN «S Cd CO 0\C3QQ(M(M('JIMtMIMf0ir\S0'CJv 
<SlAvDf0lflfflffl'-IM('lfniA'0<IBlAO<^»'0 <<<<CDa3fflCDa3CIlIIlDaCQcDCD 
OOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOO 



lllllllllllllll llillllllllll illllllllllllllllH IIIIIIIIM 



Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 31 

381 
















A Cross Reference 
Program 


for Northstar BASIC 


BY LARRY HUDSON 
2232 Alameda Ave. 
Ventura, Calif. 93003 


Here is a combined line number and variable cross referenc¬ 
ing program for Northstar BASIC. Because this is a machine 
language program, it runs much faster than the others I have 
seen which were written in BASIC. This one will do a 500 line 
program in about 30 seconds. 

I have tried to write it to be as general as possible. All I/O 
is through the normal Northstar DOS I/O, and naturally the 
disk routines are through the DOS. All other subroutines are 
within this program. The output routine uses the standard 
Northstar convention of specifying the output device by the 
code in the accumulator. As it is written now, it uses 0 for the 
console device and 1 for a hard-copy device. These numbers 
can easily be changed if needed. 

It reads the program to be cross referenced directly from 
disk. It accepts the standard Northstar convention of follow¬ 
ing the program name with the drive number. It creates the 
cross references for both the line numbers and variables in the 
same pass, and follows this with a second pass to flag any bad 
line number references. After these lists are created, the pro¬ 
gram will ask which list you want printed, and when that is 
done it will ask if you want another one. In the line number 
cross reference list, any reference to a non-existent line is 
flagged with an asterisk. 

When answering the questions in the program, it will only 
accept L or V for lines or variables, or Y or N for yes or no. 
They can be entered in either upper or lower case, and no car¬ 
riage return is required. All other keys except Control-C are 
ignored. The control-C will cause an immediate abort back to 
the DOS. This is not the standard DOS control-C check; it will 
not interrupt the running program; it is effective only when it 
expects a keyboard input. 

When entering the program name, either the underscore or 
delete will backstep to delete characters. Both will echo the 
underscore. This set of backstep characters can also easily be 
changed. The buffer to hold the program name is only 11 
bytes long, but the input routine keeps counters to prevent 
overrunning either end of it. 

This program loads in the area normally occupied by 
BASIC, with the disk buffer located at address 2A00 through 
2AFF. If you reassemble it for a different location, be sure 


this buffer is located at a page boundary or the GETCHR rou¬ 
tine won’t work. There should be no other restrictions on loca¬ 
tions. The cross reference lists are created as linked lists im¬ 
mediately following this program. 

2B00 is the normal entry point of this program. 2B03 is a 
second entry point which jumps directly to the list printing 
routine. Naturally, to be able to use this second entry point, 
the lists must have already been created and must not have 
been changed. However, this does make it possible to go back 
to display or print more copies of the cross references without 
reading the BASIC program again. 

The data in addresses 2B06 and 2B07 are for the page 
lengths of your console display and hard copy device. The 
printing routine will pause after printing the specified number 
of lines and wait for another keyboard input before continu¬ 
ing. This pause can be disabled for either of the output de¬ 
vices by storing a 0 as its page length data. 

Each entry in the two main lists in this program, the VLIST 
and LLIST, consists of three items. First is the link, which is 
the memory address of the next entry. Second is the data, 
either the variable or the line number with its good/bad flag. 
Third is the first entry of another linked list of the line num¬ 
bers that refer to this data. Each entry in this set of lists, the 
RLISTs, consists of two items, the link and the line number. 
The last entry in each of the lists is marked by the link set to 
zero. These relations are diagrammed in Figure 1. The program 
keeps all these lists in order as they are created. 

Finally, a few words about this assembly listing. This assem¬ 
bler allows a few extra non-standard mnemonics. The ones 
used in this listing are: 

CLA clear accumulator, assembles as XRA A. 

SF set flags, assembles as ANA A. 

SKP1 skip one byte, assembles as CPI without a data byte. 

The DC pseudo op is for Define Characters. It assembles a 
quoted string as a string of ASCII characters and it sets bit 7 
of the last character high to serve as an end-of-message mark¬ 
er. The message display routines in this program are written to 
use this format. 


Page 32 

382 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 










Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 33 

383 







































u ■+> u u. 

at <* 

i- 0) V V V 

oc.cc 

C O 3 O 

V> O O O 

h in a u v 


a> 

cum 
rc Qi in 
m c £ ii 
in t t- 
C S- 3 T? 
Oi c ri 

u- jz 


E ttl 


^ m ci 
e -I 

T9 T9 O 


TJ E r-. C 


E E V- E ♦» 
t- O O ai T3 3 

a. *- > a> o 

T? C E E 

-*-> _x c o ^ 

t= |_I * u 3 Ifl 


« <TJ 
1- Xi 
► Ci. 

2 ° 


in 

r u x 


iZX«®X*lU« 


i ac a x X 


•-« =*xae k u. x a: n X 

NO.UOIUNXtUUZZ 


X — 
I«N + X 


UJOZ3 
Cl. in «—« a *r 

3 C ac : 

“ <x c ft; a 

z i « u z 


: o_ CC —i _J 
c Z > « «. w 

' “> •-• c o -> X 


—I —J 

—iy*-«_ia.<r:>>c=>-xxxz>-~» ... „ , 

o*C9ZXXOa_nvjx<C*:xc9a.r^ia.MCL,MX: 


.uoacOOXac«X3ixc*r 

ioxoxxcncno“)-jo~5 


CM 04 ro 04 (M CM 


CM r*i CM CM OI 
CM m - co « o 


«u<M*)Q<C<rn*in(Mi»)»nui 

uxar\f'j®o®ucM«uM®u®' 


iArorM«— ujacm«— a 

l U O N (M M U 


I I I 


-wr. CMun-oronnujuj 
(MUUMWCMinCMMCMNU. 


I I 


I 


I I I 


I 


I 


I 


I 


I 


I 


:*-wMr-UJUJ«liJ«UJ«Mn»UJ'ON»NCMQ(M»-BrO 

)CMUUN\U.O|J.UU.U(MUCMNU.M*J(MNUO(MOO 


I 


I 


I I 


I 


N (N M N (N N N IN 04 


I 


I IN 04 04 04 0-4 IN CN 04 04 04 04 04 04 04 IN CN 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 0-4 04 04 04 04 04 04 04 04 O4 04 04 04 0-4 04 04 04 04 04 04 


-O O QD «>>■ i 


__^!^^ l C'5^: l ? t ^®rr jM, ‘ in ' orvQ:,(> '*'' pjn,rin 'O , \0 D1 >'®'~ r4ro, r in ' orv CDi>-i»-CMroTin-0NCD(^«i-pirovin-or\m 

up up in in -o -o -<3 ~o ~o ~o ~o -o -o -O rv i\ rs r\ IM r\ r\ r\ r\ OP go oo oo go oo OP m eo m ov a- o~- o- Q'i>-(>-f>'t>.f>-^ia !■& ». «. <& m «, _ _ __ ,_ r . . 

*• ^ ^ ® ^ ® ca • • ® Ci ci • Ci m <si ci vi % ci d vi ci >d vi q^ ^ ^ ^ ^ ^ ^ n> qt ci ql ci ^ qpi ^ ^ ^ ^ ^ ^ ^ ^ ^ 

<S»3><S>iS<Sl>S>'S)!a«»tS? , S'SJCS'SJiS«!S»«Sj«S»<a'Sl!aiSl'Si'S>'S»®»cSl«S?<S»'S»«a<S»«S»'S»!SJSJ , S> , Si'S> , S!SlcS»«SJ'S» , S»'S>«SlcSCSl'S»Sl!S>!SJ«Si^'S>S55iSl555 


* •< ITS 


C c ITS ff 
U ITS ri i—« H 
O £=—-.—1 


m in oi u oi i if _ 

Oi <U <*- KT> Z- +> Oi > X 


~ a * 


X l_» e ^ 


c £ h T 3 f - rc ai- 


Oj O CJI 

era — 

r-t Cl. OJ in 

—« TT> « 

t- ra a 

e o a» a. u 

a» <4- r? mo 

a o u *> 


■»? -• 3 in u • 

l Oi Cl Oj 

a» -*-» c ** c a 

0» E r-* 3 n rtJ 


a» v- e e u 

* E V 3 10 10 

fU O 3 O jC Ct. 

c. v- £i u o in 

rtS M 

Cl jtL «J •** 


ai ai qj fu 
in in 


ra a. in 

T9 

Ql K 3 
—• U X 


«*- - CM W T X 

O U. + + + ♦ Z 

inra-^. ZD ac oc oc oc _i 

— ra-m — CM 04 CM — — N CM *4 A ►— *— *— i— SC 

c 3 u u u u « 

aacncnuiuicnuiuicncn o 

QQQQQClCiQQQCi tf» II II II II II II 


A A A 

' —I —I ►—« I 

a: X X X 

i in in j to 


o »-« _l 


U in in _l cn : 

X a ® X Ci x 
—I A A . 

X X <c a. N a. N i 
J JUUIOTI 


e in in 


Z _l X ID 
z. u_ u. _J •— 
-iH33flc« ju. 
_J_JAAZ9Z»*£_J: 
r>a.=»acc_3<iA=>( 


3 uj in 

Oi A A UJ A 
<XOca:i— OZE-I— 
A K U U W u a. 

I U. »U J O J K ® 


.Uin-CMCMCM-r-OJM 

I CM — — — - v v ^ 


> CO <T A l_> (_) 


II II II II II II 


a ro m *n CM 
» <Z U UJ <z 


~o rv co a ao <x c_j uj u. A r-4 

pT| flft /y. /v. fl[| OQ Qc* ^ A CCl OQ 

04 04 04 04 04 04 04 04 04 04 04 


CM CM CM CM m 

A A A A A 

04 04 04 04 04 


m'OO'UL.INTNO'UU. 
rOMMWrOTTTTTT 
AAAAAAAAAAA 
04 04 04 04 04 04 04 04 04 04 04 


- cm po t- m -o n i 




■S‘S5l , SlSliSliSi'Sl«»^«l®l^i , S|iSl'S» l S>cS>'Sl®Sl!S'S> l Sl , S!lS» l S!?Sl®a»iSJ'S>iSl«»<Sl!ScSiiS?' 


P a 9 e 34 Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 Number 49 

384 




























«= o rtJ i_ 


w tU 0) — Cl. 


Ol V o C V 

u e u. Ck. v- 

U r< <0 3 Ol 

z; o > o> oj Xi =3 

u a. t- t_ c 

0 J o o ■** x 

Ql til 0) ♦> 

> > O in «< 


01 o s- 


t- u u u 


H O V. +* 


— CX> -« 


o %- %- a< 


T3 h (5 h 


•*— Oj fTJ 
-*■> T? 

Oi C 

U r-« O 


in a ^ 


— a 


o> c i 
u* .O -< 

a» c ^ a 

•— 3 OJ 

n e -o o u 
tv to <V 
h oi aica. 


u u 

•I V 

* 3 

| ? 


uj ae o. s 

oo<io ac < 

a. at wTi i~ <x 

X _J UJ 

<[ « j m n a. *-•« 

uwuuno-)i;w' 


s > : OC UJ UJ ►— Z» => U 

_ »x >— a o o a. i in co x 

Q t/) : CO Cl I a. Q z 

X X _i X X _J 

x^O.MN«xo«ja)(ojiLa.Ma. 
*>C£lzk*ju «XX>:=><sO<=>x*: 
'Ciu-JuiHuinuLL'iua-a_i —> 


CO X 

*-« ac 

_J —i 

: => ic 


o uj q cocoa a cd oc 

«<c=>«tM_J3:u.usx: 

X3:ox_J*:X3:oX=>K-oae:XXcjX=D3:: 

J0)XJU1J(/)XJCU)£O1JX“)Q.mi 


u_ Cl N a. 

—I »- x *: cj x o 
3- <r x ui a: A X 


S ot > x : 

U N O Z I 

J Cl C M , 


CMCN4CM C*MCM CM CM CM CM 

* ® ® u CO O' in CJ aa rM co (M 

u. uj rM rs CM cm r\, cm rs u. o- <s> u. 

U.CMQUJNCD«UJ(MI*)UI|«)UJ(M(NrtlL(Mairtlftqt-*-^n 
4'-uiL(jiaun<- •— ro □ u. c_j *— «— <c «— c_> u. uj cj uj u_ «— cj 

I I I I • I I I I I I I I I I I I I I I I, I I I I I 

9'««UJ®rO'TN». 40a«CMin<OM9»UOUI'(Mn-0 

inminiO'O-O'O'O-O-O-O-ONNNNNNNNNNODaOOflO 
UUUUUUUOUOUUOUUOUUUUOUUUUO 
CN N N M N (N n M (N CN CN CM CM CM CN CN CN CN CM CN CN CN CN CN CM CN 


I l I I I l l l I I I l l l i I i I l l i I l l l i l l I I l l I 

»uu.»M»N«ouJ--m'«Na)®LJL.(Mrt«rinooO'UQwu.fMncDO'U 
mmcoi)'Cho-o-0'0-0'«i<i«<i<i<r4<l®a®®®aa«i»»®uUuutJ 
uououuuououuuuuuuuuuoouoouuouuuuu 
CN CN CN CN CN CN CN CN CN CN CN CN CN CN CN (M CN (\4 CN CM (N CN CN CN CN CN CN CN CM CN CN CN CN 


C'IMTin<lMBO-®^CMrtTin-OMIICS®-Nn»in-ONOD(M»-CMMVin-OM»l>-®-CMPOVin'OM»0-®-(MrO»lO-Of\COO.®-CMfn 
a)mo)cocDcn(X)Coc>'i>0(>-o-^0'&-0'»-«»i»i®«®»®®®^-^-r----r--^(MC'iMtM(MC'jCM(M(MtMnnMKirowror*iroM»*»» 
— — — CMCMCMCMCMCMCMCMCMCMCMCMCMCMMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMCMC'ICMCMCMCMCMCMCM 

<si's««icsi'sj«s!!s>!sj's)<siisjs»«sj'si's» , s»«i's»isi's>'si!a3j'sia»«s»«s»'s»'s>«acsicsjis»ca<aisjcsj!s>'s>«s><sj«s»'s»«iisi's»<siis»tsiisi«s»'s>«si®«s«csics»<sj's>«si«s>cs> 


»M Oi Oi <0 


Cl (0 UJ 
Oi Oi 'v. 

i= i? i- a 

■X C 

—« CM Oi O 


Cl i 


u $ 


O t0t 

3 O 01 
v C > 


Oi O V > 
c c a c c 
^ O U 


O'—' Hi u 

a c- 

Oi O ' 

a# j- 

> o *n 

tv -►» a» 

m in s- 


o o QJ u. 

v h in 

i Oi 

: r»> u - t~ 

i co e w* o 

—« 3 O Oi 

V- <i- C > in 


a: 
ae 
U. (_> 


a: 

c_) 


3) <_> 


UJ 


c o 


UJ M C a UI U-J_I' —I UJ s trt 

id ac _j uj X O a: ! x = x O : l 

CJXOCU U O 2 '• O 


oc O 


in uj 


UI 


CD x o 4 o <x 
X <x X UJ A 

—I O-J —J to _ _ _ _ 

M J CC -JI>_J3>X_JI-i_J—« 

x«cjrM<to<rooXcJX<ca-rMa_a:<xa-XZ:ii-*«o-XXCi.3:<rca<coX»<lo 

JOO*lUCOCXWXJUUT!JTUUT3'JTaCJ-OUTU£OCil.oa. 


► z ju 

■IJXHJm"‘hnJ»<Nu. h NJ*«iN£Ihi., 

ia.z<la.zj;u.z4a.zccL* 


Ul *— t_J ll. u. 

LD <C X CO X * O 
00 X Z O U. Z 4| 


S D 4 U N X 
s X : 2 


Q O ® Z O Q 
= O = X 


: x <C <r _f >-« hu<Ix<[4Jh >-« cj 
■ * -J •— <£O-u0.X!“*_Ji-<Co-C-»u.X!— : 
iHUWUOTOTlflHUmUUTOTW 


— Ac=i«XAu_ArMAC v 4A — a uj <x uj cm 
CM unuumumujMuj - uu.cju.cj 

i i i i i i l i i 
in ao co cj 


00 ao<»Qa>i«.r\«ouoc^4rsacNuu.«u« cat 

*— OU.OaffiOU.OU.Cf'J’-U.CNOUJIhNU. u. 

4 UJ H Q UJ CN M 


cMoujcMroujcMau.arMmA'— ro-oujcM 
'•'*U.OUU.UUOO*UJOUJO®u.U' 


u_ ro m m in 


ICMMU.MwUJ4UJNNnu.NO 
• — «*-OU.QU.Q»-»-<C»-Oi 


’ 1 1 1 ... ’ ... 1 1 1 * 1 ■ I I • I I I I I i I I I | I 

NM'ON®OOU.N<rNO.UU.-»NO;U|L-»N».OU.®M»inffl^UUJOnin'<)N(DI>sUUJ*-M'OM»».4QU.N4NCD 

uJUJuiuJUujuiuiu.u.u.u.u.ii.««®®oo----^-NNNr')NNNNMMMMMroMnro»»»*»4'»4'*inin!nin 

ajoaaooaJoacioaooAaaaQ&aQooaaQoc_jc-]LJc_JC_jt_jc-jc-jc-it_ic--»t^fjifi<irjf^rir-.r < r yr^ f > r-. ,'. f-.f, r . , 

04 r-4 r-4 r-4 cn cn r-4 r-4 cn cn r-4 cn r-4 r-4 r-4 cn r-4 r-4 cn r-4 cs cm cn tN cn r-4 r-4 cn cn cm cn cn r-4 r4 r-4 cn 04 r-4 c-4 r-4 r-4 r-4 cn 04 r-4 r-4 cm cn cn cn cn cn cn r4 cn cm cm cm cn cn cn 


,^NM»n-OMiio-®-Nn»in'ONa(>.®^cNn»in-ONCDih®».Nrt»in-OMao-®u 
__ _ _ ___ ^ ^ ^ ^ ^ ^_^j^^^^^^^^‘»irt»rtinminminininm'0*o-0'Oo<OMS'0-o-ofMrMrMrMrMrMrMrMrMfv.oocr« 

i’soi®s®!si®!a®®®®®5!S!s®®'si®’s i ssi®<si®5i®is!5i®isi<si5i5si5® , s)®55®5555555555555555555 


Number 49 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 35 


385 












-« UJ c 


_ EES- 3 rl 

—, -< OJ —» O —1 

C -C. * - 

c; x -»eoqj qi 




Cl ♦» 

* IT 

Q l! 


ai oi o in o 


T3 



O 



s 8, 

«- CO 

s* 

* O 

<b 

° 5 

— Li 

° c 

:<§ 


X X X X X 

x z> x > x . 


•x a: 

=< Cl. 
X O CJ 


X <t i: X>cxa.z>—IMXOX 

____ 


'j-X=>XC>r>« K NjLOX=>Xl>_J 
'JCii00ii2DZO*0I 
-miHCntj 


_l •=• LD LO 

_jO_ J i 5 x M i 

<cOr^iXc_>ocjOCJC 
_i u. a: _j x x a x x “s 


u- oc -J tn 

<t — x» i— oc. — 

c=!4cu n a. a u z 

x a cn k cci u: _j 3c —i 

oc x *x _i ac 

a a -j ui a ^ o cl. 

—I -J -J •—' -J _J _j => <t 

Ii<Cuxi<IioceN 

jwoTjinuj c o ~i 


M^^wujWfouirtNt'jujaufo-oCMMnrtujfO-oda'-OJlai'jartmm 
N (N M ") (J N N N U N U. U M \ N <C u. U. UJ in M Irt * U UJ M in f ( m N (J B y ^ UJ f\ M MiJ U 


cm cm cm cm r-i cm cm 


^S^2SS^ii:5lI^?‘ r, ' ,000flC ''- je:auju - <v<r * -,,r,r, ' o rv.Qo&«(_jciLLJU.'*> — V\S)>UQUJL.SII- 

r*! '. 4 C -4 v 4 .4 CM CM CM CN CM CM CM CM c-4 C-4 C-4 C-4 C-4 C-4 C-4 C-4 CM CM CM CM C -4 CM C-4 C-4 C 4 C4 C-4 C-4 C 4 C-4 C-4 C-4 C-4 C-4 C-4 C4 


<TN«D®P0-00-UOUJ 

NN\NOCD(DODOCDOJ 

caca C'Qaaaaaaa 

C-4 C-4 C-4 C-4 C-4 C-4 C-4 C-4 C-4 CM C-4 


-o \ a &■ « 


^■NM»in-Of\COO'itl — Mrovin-Or-xOJO'iSi — (N 
” ’T’" ^ N N r ' c-4 (N n n m M ro m w 

rororororororororomi'omro'ororo-ororopororo 
, SJ35lS&'S’:S>tS»'S!'S!'S»3>!<5»'SJ ! S»S>. ! 5><S* - S< : S>'Si'S>!S> , 5! 


^ v in -o i'. cd 

PO ro "1 ro "l “) 
ro ro r-o ro ri po 

<S> 'Si 3? !S> -Sj -S! 


PO PO M 

® S S 


1 /-J -O X. oo o- <3E» 

«r ■>»■ ^ in 

r-^ -o m p-o p-o m 

PS; Si ® CS- cSi 


-(NM»in-ONCD».®p-CNP*)«r 
ininminininininin-O'O-o-o -o 
ropomroror*ipnpopoporopoporo 
, Si‘S?tSjrsjcSJS?Si3a3J®S!CSi'S?Si 


in -o rv. 03 

-0 -0-0-43 

r+t m m m 
S S S S 


i. 3 >C 


O -o 

o o 

T> O 


tU ^ 

e —» e m 

O Xi PC -O 

v- ft: > 


m « — -l> 


E UJ 
a< 

E Q 

3 O 
U 

QJ 


*= *= =! 1=1 * UJ 

uj i a <[ uj q z 

« a a 

:> x o I> <x _j z a. 

azoXiae'NXcj*: 
C —< C X O ~i '.O X 


=> <b CO 

<t =» UJ ao * 
C I C =1 —I 
co A co z 

x_izz>xz>cn^a. 

CJZt_jOc-»OXiXZ 
X _J X X =< X 'j_l~) 


• n 
«r z 
«« cn => 


I =»■ *x X X : 


x _» a. x x =» x ■ 


I > X > LL <i oc X2>x=>x—IO-—!«r 

'OozoOocjp-Mzcazoxozxca _ . _ _ 


x z> x a. :>-.=> x 
— ox xoocoxr> 
”> x o x -* x ■ 


C-4 CM 
I CM 00 


INNNUI 


LL®i-(Mro<rrs.«t* uJu.(NPO»in-o^. « 


a®-»in-ON«».«i 
UlU.U.U.U.U.U.U.U.U.1 


u.^rn-or\CD>.<r 1 iiQiarn«-incDO'« aouj 


u.-Nroin-ooo(xo 

-(NCNC-JCNNC-JMIM 

— aaaaaMMQ 


C-4 C-4 CM c-4 04 C-4 C-4 C-4 C-4 C-4 C-4 C4 CM CM C-4 C-4 CM C-4 r-4 C-4 C4 CM CM C-4 C-4 CM CM CM CM C-4 CM CM C-4 CM CM C-J CM CM CM CM C J CM 


IT^^:2^!S^:!^ir2T‘!2'2 r i' : 5 c i:' s,,_rvJr, ’'^ ir> ^ >rxaoa ''* , ’“ r ‘ Jf ^' ,rir, ' or M«> l x'»»-o4ro«rvn-or^cDo->»4-cNro^- 

_4 CJ C|J C|4 C-l rg C|J C-J r-4 CM cv* C-4 CM C-J 04 CM CM CN Ol CM r^J C J C^J C-J Cs* OU r-j CvJ C-U CM C-J C^4 CM c-l C'J CU fpj CS| CM CM C-J r-4 CM 04 C-4 C^4 CM Csl fSJ CSJ fSJ 


in-ONCDo-«~NM<-in 

ovo>>o^a.9ii»«c l «,s l 

CJC4CMCMC4POrrjPOp<3ropo 


Page 36 

386 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 





U -Cs 

O «T> ty- 
r-t >. 




z 

u_ 


O (5 C Ci 
V > M 

^ o 
♦> 

E E X* E 



:>_!=>■ 

oe :> ac Cu CL. Cl. u. 

a. Cj <r _J XX 

<=■ CS _J _J __J _J CD 

ij- _j —« => <r ijhjhjji 
CIXOQCNO<XX<IX<I<IU 
"D-J-JXOiXXO-JO-JOCJX 


r> x =» x 

O *; o Z 

X —i C i-i 


<X CJ > • 
i-i <x <X t 

> i- w i 
C J I 


ixox<C3c<r:^«x x z <r i 

-J O _l _J CO 

x=>xZ>xOCM*-«_J:x:_i*-i_iX!i_:>f 

i*Qto*uz»«u«x«ycoi 

MtMrMQiruxujux-ir: 


u. =9 ; 

a O 5 
Q_ 

<r 


i »-i _j 
: r> <T 
I X o 


X _J => x 
2 « o z 
»-« C-> X <-« 


I 3C LU 

co x r> 
D z O 
u. *-< ar 


x 2> t-i _j x 

3E O r> <C O 

h r t u x 


(N W CN W (M CN 


04 04 IN 04 CM CM 04 04 04 04 04 04 04 04 


coo-anuui'-<rincoix4:»uouJu.M«NQo<&iijf(MiO'OGoaiQ«(Min-oa-4;Auciuu.«i'-n'0 
rorororororo«r«r^»»5r<f«r'<r«r<rioininininin-o-o-0'0'0-o-ONr\rvr\r\NNNr\Nrs.cocacxico 
LU LU LU LU LU LU LU LU LU LU LU LU UJ LU LU LU LU LU LU LU LU LU LU LU LU LU LU LU LU LU * ■ 1 I ■ I LU LU LU LU LU LU LU lx! LU LU LU LU LU 

04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 




: <Si ?SJ <5! ® 


*S? *Si :& tSi 1 




i !S» Si 56 «S» ISJ 


: !SJ <S» i 


|!SaiS)(Sl(SlCSi!Sl'SicS('S>CSl!S4iS>!S!tSi<Sl 


o —« o «= E 


01 O O !_I 7D 


tO CJ <-« - - O' \ 

—* -u •» v in •D TJ 

o co in f m in o fc 

ac, —« o —i 3 cn 


E U +-> 


c*. «= t- » 


D Hi j2 U U E O 


O H f4 


— t- 


i- o- 

ai -i m 
3 QJ 
in oi « 

C t_ .Ci 


> h in nj c 

C_ 0! —> rH 

J_ fO E <t- E 


0 0 3 0 


ft; in 

m c 

Qj tO 


in u u cnn 


a» c 


' Oi E 


in in —i f-i 


rt (5 Hi H 


z: ac 

_j >=> 

cc oc 

=1 Cl. 
: CJ CJ 


CCl CVI 

a ac x 


ui*iujioi 

x a _i o K _i 
=>xx>Xu»x=>XCO-J-J _J 

OaCOZCi3COZ3>3:<CrUL_J<X 

r m c m c h r h i j u ~i 1 'j 


O X C O X X _l <1 CJ 'J 

—i 

a. a. —* ci-! a. r> :> r> <x 04 

tcox-x:*Tc=.0<=>0a£X 
~4 u- x o a. c z ar o ~i 


X O 2 
U W h 

3 a: a= x = 

X> O L»- Z> 

X ir> s 


LU 

cs, CO 


cn 


*— CD t— *— CD O LU LU LU cn 

Z> -I OC 3 LC in U C. z 2 LU CC J —• : 

— CD = — ii.Uoa.tz®m&.OH-OMZOiL _J . 

1 — X> x> v _j => => >- o _i + j m o _i X> _J 

a. = <x -► x> «x x <r«^<Eoo«*Ci__i_jx><cjc: < 


—I Wm _J J M M M N J <H H _j •—« 

>OX<t«Z4.Nii.X<ra.aNJ»-a«X«<C^*>HOZOh-HQUNXX 

_ju—iuu«oio“)UL)r"DowcujoutTto)j“ija)wjcnjj 


to 


04 04 CM 04 04 0-4 


<c i 


04 m 04 ro 


p 

O — T4 ro *r ud 

o- »- O'¬ 
'S .=. CS, 1=1 =. El 

Qj 04 04 04 04 04 

.C 

& 

C o- «• •— 04 ro 

O 43 M\ N N 

f j i-o m ro ro ro 

S? Oft IS ’SJ IS? 


•0\CD0‘<iQ®rO'O0-. UMU.rgin'Or. o3&i« 

CD CD CD CD CD CD CD CD Cl CD CD CD CD CD C 3 CD CD Ci ■—■ ■—• 

04 04 04 0-4 04 04 04 04 04 04 04 04 0-4 0 4 0 4 0 4 0 4 04 0 4 04 


ai»r-4rr\«uiU'-ro-oO'*Ciisi<-<f-oi>-uu.N<rNO'ULLNincci*uju.Nio 

SCJCJUUUUUOai-iMCiCilUliJlUlULJLJUJlLU.LLlLL.L.®®®®®®'-'- 

oaaaQaQaDwMaciOQMaoaaaOQQOQQiuLuwwuJlijLuiu 

04 04 04 04 0-4 04 04 04 0-4 04 04 04 0-4 04 04 04 04 04 0-4 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 


csiro^rm'orv.ooo-isa- 


«rin-or\cot>-isi — tNrt^inorxCDO'is*— ojr-3'ri/-i-o \ aoo^ i 
NNNr\Nr\03Q30omcDCDa3aicoco&'0'»-».0'0-o> >> o- > 

rommmmrommrornmrorommmmromromrorommm^r^r<<r«-*»-«»-«f-«-^-«r<w-- 
<S» ! SJtSi®'Si’SS , SiSfiSJ'S!5Sl’S!'S!'S!^iS5S'S!S!S'Sl'S>«l5» , Si!S!'&iS8!SliSi<S'S!CS l S!S>lSt'Si | 


! IS! is? !S; !S» IS! I 


I'S’SfiS-iSJtSi'S-iSilS!! 


Page 38 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

387 












ending 


OJ ChQjh(HOT?CT? o 

c —i 30 Q.aiu-*-ia»u 

•— d c c*. -o <k t~ > t_ 

>—«£*■- tt» ♦» •«■* >-t O Cl O 

0£C-fJ(liC>Xi O 0l 

l- V- 3 C > ^h >-. ut 

aid! o o rc j- o oi o aim 

•y* N u u in a. c i_ t- 


-*-> x m — 

m n jc c i c_ 

c - JZ a< 


CD £ a i m c a 

C -i in > r-. 

*■» —• 3 rt> —< O 


T3 C C_ 
ai ai u 
C .c « 

v* •*» u a 


3 <=» « o : 

n *: : 

+* —i —i 


Sizocui iT x 5 

cukcuz u x: 


*—' —I <3C 

^«mu.muj:3x<I<i3<iciq i -u 

cujwocQ-jiLJUuruiJcna: 


a. o uj cn w UJ =x 

X O X. CD X CD <X CD <n CD 

O <E —■ UJ =i i. < 

*= 3= •=• —I XX I __J 

'J)m JM j* cn _J r> _J Z> Cl ■ 

Xl=Xx<tcjh-i=»<c^i-*OCi: 
X 3-IJOQOiUtLiCil 


CM ro (N M CM CM CM 


CM CM CM CM CM CM 


CM CM CM CM CM CM 


I I I I I I i I l I I I l 
U.<-»NCD>«aUJ*-»N».i 


CM CM CM CM CM CM CM CM CM CM CM CM CM OJ OJ OJ OJ 


* J CM OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ 


'ONOO'®*-NM^ir>-OMnO' «-NM»in'«\(DO-«i-NrO«rr>'OMD».«-NM»in<MDlSi 
iou->u-)ir>'0-0'0-o-o-o-o-o~o-or\r\rxrvr>.rv.r>xrMrv.r^a3CDcocxjcoaocx3Coaocxio-0'0-(>-c>~o-0'0'i>-i>'i 

<Sl l ^!S>iS>®<Si<S>«Si«JiS»<SitSl<SiiSlcSl«l!5i:Si®JtSi<5»iS«!S><SJ!Si<S»<S*«liS»iSliS><S>cSi!3J®iaa®i!SliS><S>'S>cSi«S!®Ji 


iNooo'»-Nm»in'OKco 


—« D C .—« 

—i O 3 

O 3 O CD 


Oi Qi Oi Hi V 


OJ _j -* <r x 
I Z <r =» *- o 
OUtWi 


:> <r 'M <x ■— 

O CC T .=4 X ‘ 

C O —i _j o : 


X‘-I<r'-INX'NXX<I"-<CLNI"I x k O n ac I- CJ 

'-'•xoa-ztl^'XxrO-aEsraeoiA.xixiO-cu. ZXuju.nh 

T H(K CO QC W 


l l l i I I I l 


OJ OJ OJ OJ OJ N CM 04 OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ 


OJ OJ OJ OJ OJ OJ OJ OJ OJ 04 OJ OJ OJ OJ OJ 04 OJ OJ OJ OJ OJ OJ OJ OJ OJ OJ 


♦ in'ONCBj'®-WM»in'ONflaO-®»-NMVin'OM»(>-®^Nmvin-ON»C>-®-(Nm*rin'ONffl(Mln-(MM»in'OMDO>. 

— - '-'------M('jN(N(Nf‘JC'ic v i(M(N«M'n'omropn f O , nr>i*r<rv»v»*'»»» 

v,r * ,r, 'XSlCli?^l2«lf?^«£!lI?!f?!i?li?l2 ininin ' n ' nin,niriinin ‘ nin,ninin| n |rtin “' 1 'n^‘n!niriinin 1 niniftinininininin 

S^iS) l S»«aSi : Si , Sl t Si^ t S®'S! : SS!^Sl : Si^S:'S:cS!iS! , S , S 1 SiS? , S>iS^icSl®5J-S- , S? , SS!S?^S!^S?!S;c5>'S^>'^i(S>fSJcSi , SlCSiiS'tSiiSi ; Si^Sj'S;!Si®j 


® - N m » in 
in in m m in in 
in in n in in in 
IS CSJ <SJ <S> -Si «S» 


Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 39 












in 

cr> 

IT. 


O V £1 n 

U M 4-> C l_ <0 J- 

H H O U 

t> co ar rc 


O O Oj a (O 

•*■» U T? U 5- 

s= o ro re 


J- CuOl J. 

m ■«-> o « -Ci 

-C 3 ■- jT fu 

U O IT! U fj 


=» A — *2: 33u_ID 

_ - — cn OCi «X ►— 3 3 1/10 TV 3 1—30 CC 3 (/) O -J 3 O r— w-»wr— r— 

3 t. h n rt u.<*,u_^cj = a.ac.u_ « a. A <r <t a .a. <_i lOUuiMio'/la.u to O u a !A u u i_j , 

O — t- jz r\ li o o rv. x, *x •— ZC o A a. u«UU i -‘-4.U'JZil « a. k u Cl *— «x rv. i— ac, , 

*' _ U l Z 3C Z Z X ^3 3C —J i _j 

to C*- C -« D3*Oacri3z 3-J=o--2:=fO=>C3=>4xx:=>2:02:*— c=.Ca_*3=a<C>o<r_i — CO«C=i*Z^^;! 

I'D O if> — 

i- m qi w 

A tO T3 > ~. ^ 

jCO’OAt-H-fr— *— ai Z: 

O <=. a to o => 3 *- Z3 <r ct Q 

O O 33 o r— {_J a 


UJ •— 

2: 33 

C 3 . 3 * CD ►— 




(M CM N CM c-i 


io id -o r\ « « in in -o 'vu.intnujc'jcii.-o^ inQuu-u-CMN- i 
u.ouj^r*)uu.uuj <xu_^u.'_Jr^>«-ts»u_u_ua&'*n<r^-c_i‘nLi.: 


I I i i i i i i l 
uj-cMinmo'ffiuiu.i 


cn cn cn cn rj cn cn cn r-4 


r-4 cn cn r-4 r-4 cn r-4 r- 4 r-4 r-4 cn r-4 cn cn r4 r-4 r-4 r-4 cn r4 r-4 cn cn cn r-4 cn *n r-4 cn cn r-4 r-4 r-4 r-4 r-4 r-4 r-4 r-4 r-4 cn 


(Mm<rin-ONO>« — c-4r)»io-or\aa»-isi-(N 
ajcocxjcococt) an 030-0--0- o-cx ooo-o- o- -v ^ n 
- 0-0 O-O-O-O-O-O-O-O-O-O-O-O-O-O'O-ONr’, K 
»Si®iS>«««J5Sl'S»'S»cSl«i«!S|-SJ , SjcSJ-S!CSi<S>«J^S> 


'Owin-ONCD(>.®-f-(ri<rin'0\(D(>'®»-CM»*)»in-o\ooa-®-!MPOVin-o\®0'®^(Mi 

r '~- rv - rv - r '' r - f^* f'- r>^ r». rv. r-- rv. rv. rv. r-^ rv. r 

SS-'Si , SSCSi l S>SlSi®<Si'S»!S? , S!SiSlcS«iSJ^ , ^>tSJ^.<Si^! , Si5}!Sj5J5JS!CSJ'Sl , S!'S?!Si'Si3S!tSl'Sl , S! , S!' 


cn ai lu ai v in 

Ql L N d l/l J 

a a c m 


ts Cl ® 'i » a. ® '1 

u3t-co i 

®» | _ I _ I _ | _ , 

x c. * a a Ci Ci_i< 

A Cl Q A Ci <r 


u in in J ! 

* =i = <r u : 


•— r> x . 
a. uj O ac - 
nocCHi 


i •—« <r uj<x m o Ci € o a 
a 

> 3>*x3>r><xX>XAX><rr> 

:cjo*oo*:02:«0fis:o 

ntuctutHOtoi 


(M in in Q « -• r- * CM — *— O' 

QmUUwUCiU/INOUJU 


I I I I I I I I I I I I 


I - IM in -O N 


U.U.U.U.U.U.U-U.U.U.U.U. 

r-4 r-4 r-4 r-4 r-4 r-4 r-4 cn r-4 r-4 r-4 r-4 


r-4 r-4 r-4 r-4 r-4 r-4 cn r-4 r-4 r-4 r-4 r-4 


r-4 cn r-4 r-4 r-4 r-4 cn r-4 r-4 r-4 r-4 cn r-4 cn r-4 r-4 r-4 r-4 r-4 r-4 cn r-4 r-4 r-4 r-4 r-4 r-4 r-4 r-4 r-4 cn r-4 


0'Ui-iMM«riD-or\coc>-. ® 
«— C-ICMfMlMCMlMN(MlM(MrOl 
'O-O-O-O-O-O'O'O-O-O'O'O 
5&!S»'5j®|!S!®!3l<S»CSJ<Sj!Sl®l< 


cMro»m-o\a)(>'«-iMw*in-oM»».®*-(Nf*)«-in-ONooO'«t-(Mro»in-ONaD»'®^Nm<rin<iNmi>>®r- 

iroror»>rornpOforo^r^r<r^r^-^-«r^-^-^-iou3u3i/3mir>ioir>irJu3'0'0-o-0'0'0'0'0'0'Ors.rs.rNrvrNrs.r^rs.rvrs.oocD 

5^55i^^^^'°'°‘ 0 ' 0 ' 0 ' 0 ' 6 ‘ 0 ' 0 ' <, ' 0 ' 0 ' 0 ' 0 ' 0 ' 0 ' 0 " 0 ' 0 ' 0-0 ' <, - 0 ' 0 ' 0 ' 0 ' 0 - < >- 0 ' 0 -0'«-0-0'0-0-0-0'0-0-0 

?a5i3i®l®l<SisS>iS!:S»CSJ<Sl'S!S»iS|!Sl<S»Sl*»:S>5& : S>'S!:Sl3»<Sa«»:SJ!SJ'SJ®»!S>3>'SJ!SJ<S*<S!SJiSf®!®» l S!!S? , S3l3*JtSi;S>?S?iS?3l 


Page 40 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 

















m N n n O' w o (s ui«iujin<SiU.mu«' «ruj*«>suiuiui 

N-orst\-oNinr\C'J -orv-orv<r' 0 ' 0 ' 0 r^ \ -o -o ^ n <i <i ^ 

»-»-inu.uinaou.u®*-®a'U.u.ui©nrn5i o--®o~u.u.c>'. mul 

•0-0-0'0«r-0^0<r<r-0rNO-0M-0-0(Nr\<i •o^nn-O'OO-O* 

♦Ni>-u.KCDisi9«in»r , i«rinuJ 
in«O-OCV4(N'0MN(Nr»imNNr. NfrsN-O'0»« , (NrV'ON'ONN(N 

• I I I I I I I I I I I I I I I I I I I I I I I I I I I I I 

*TN«Cj®r v i-oo-Uu.'-*N<iCi®rO'0»'UuJu.C'jincoajijj'-<N 

»«r«’^inintnioinin-o-o-o-o-o\Nr\NNr\NcoaooocDoo(»>(>'» 


u. - u m ®»cj « in u. T-4 ujujcn Cl c-4 M m in n w o ^ 

-o-o-oo T -4 -o tv. >0-0 rv -o-o-o rv, -o rv -o r\ O -O <x 

a(NCM«a<Siii.i>Ci»-SiCMCi^(M a-®Ci.'i---inrOKi r'j in uj ® OJ 

Cr*vN(N-o« •o-oaDNNNaoNN -o cvi -o u_ -c-ouj-orsrv-o-oC'jN 

<Siisirsa'-u.uJ'4m«'ino4(Ninu.Ciuininin'CO'U | »u. '»-oioinu_ 
C v 4ir>'0'0'0m^-'0-oi0'0r'^rs,<r-oao«r'0\'0uo-0'0fsi-orj'0-o-o-o 

i • i l i i i i i i i i i l i i i i i i i i i i i i i i i i 

0'*ui»-*N9'Ou.»-t-N«iJu.»-('jincB«Q®r«)inoci»uj'- , rN 

»-0'0'«<i<i<x<r<c<axiiXiixi>xiauuuuuuaaQi=iQaujuJuj 


oorooooooo'oooooorooorooooooorooooooo'oro'oo'o'o'oro'ooo'o'o'oopo'oo'otofororofo'oro'oro 




U- f» u. U- <S)Li-(S> 

~J ro ro Cl cm ro cm cm 

— u- o- cm uj cm "5 a ro uaoao 

u. in in ro ♦ cm <r <s> <r as cm 

Q-oujauJNNCiuqO' - o ro 

uuju.uu.u<rurouu cm c_> c_j 

i i i i i i i l i i i ill 

m io <► u uj •- n in i\ <t au>- 

M M M M M M ro r<) ro ro ro ro ro » 


,< 1 K ) r ‘5' < )' , 2r<)r')'*)rO! , 5'') 


ro ro ro 


p- in-oNGoow-nro 
i ♦'r«-«rvinininm 

fT r>sNKrsNNrsNrs 

O rsrrsj-sj-sirsrrsisrrsirs 


■<ri/ - >-orv_aocr-!S».— cm 
ininmininin-o-o-o 
rv.rvrvrv.rv.rv.rvrv.rv 
rS^S^rSi^. -SrSJSl'Si 


'O*rin-orvaoc»'-<x» — cm 

O-O-O-O-O-O-OPvNN 

rsNNr\.NNi\r\rsfs 

^CSl l 3lcS!rS»cSi®i , Si«S<S> 


to«rm-ONfflo-®^r-io 

NNNr\NNr>sCOfflCOQO 

r\.NNNNNNNr\NN 

’SJ'SiSliSiCJ'Si'Sr'Si'Sira® 


♦ in-or'sCDO'® - cm ro 

rvrvrvtvrvrvrvrvrvrv 

SrS>3l‘S!Si®'Si!SS'Sl'Sl 


u"j -o i~s co cr- ® -— cm ro v 
s>- o O- >i>o® ® ^ ® ® 

rv rv rv rv rv rv cocoaoaocx) 
54iSl«i'Si , S:‘S?'Si'SiS('Sl-Sl 


Page 42 

390 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 














******** LISTS start 


VLIST BS 2 ;pointer to 1 
LUST OS 2 Jpointer to I 
LIST OS I ;lists start 


= 3 
= 7 
= 9 
•= BAH 
= 0DH 
= 5FH 
= 7FH 
= 143 
= H4 
= 224 
'■= 154 
= 2O0BH 
= 2(10H 
- 2(1CH 


; Equates 


30EA - 
i(EC - 
3(EE - 


= (0(3 
= (0(7 
= 00(9 
= 00(A 
■ 00(0 
= (05F 
= (07F 
» 008F 
= (090 
» 00E0 
■- 009A 
* 20(0 
= 2010 


DOS 
READ 
PC ODE 
WIDTH 


= 2028H 

* 1 {read cormand for BCOM 
- 1 Jprinter output code 

= 7 ;tt entries per line 


the end 












Solution oS Three First Order 
Differential Equations with 
an SR-52 Programmable Calculator 


BY S. ANDREW YAKUSH PH.D. 

Department of Biomathematics 
School of Medicine 
Loma Linda University 
Loma Linda, CA 93250 

Abstract 


This paper presents a program 
written for the Texas Instruments 
SR-52 programmable calculator to 
solve three first order ordinary 
differential equations using a 4th 
order Runga-Kutta method. Gener¬ 
al instructions for use of the pro¬ 
gram and a program listing are 
given and a typical sample pro¬ 
blem done. 


Introduction 

In mathematical modeling and espe 
cially the area of biological modeling, 
effective models have been developed 
using three first order ordinary dif¬ 
ferential equations of the form: 

x' = f(t, x, y, z) x(t Q ) = x 0 
y, = g(t,x, y, z) y(t 0 ) = y 0 
z =h(t, x, y,z) z(t 0 ) = z 0 

It is often helpful to be able to do some 
preliminary examination of the model 
before employing a computer to do the 
major simulation. This paper presents a 
program written for the Texas Instru¬ 
ments SR-52 programmable calculator to 
solve this set of equations using a 4th 
order Runga-Kutta method (7). 

Program Description 

The user is required to define the three 
functions f, g and h using the labels 
C, D and E. There are 61 program steps 
(162-223) and 9 data registers (11- 
19) available for user in defining the func¬ 
tions. For use in the functions f, g and 
h the current values of x, y and z are 
found in the registers R 02 , R03 and R o 4 • 
The initial time t 0 is stored in register 
Ro, and the initial states x 0 , y 0 and z 0 
are stored in registers R 0 s,R06 an d R07 
respectively. One half the integration 
step size H/2 is stored in register R 9g 


and the number of integration steps 
is stored in register R 0 o • 

The program is designed to use a PC 
100 printer to print the values tj, x (tj), 

y (tj) and z (tj) for i = 1.N where 

tj = iH. If a printer is not available, pro¬ 
gram steps 147, 151, 155 and 159 can be 
changed from PNT to HLT (see Table 2). 
This will cause the program to halt 
after each integration step and display the 
appropriate values, then continue when 
RUN is pressed. Each integration step 
requires about 18 seconds in addition to 
the time required to execute each of the 
functions four times. 

Table 1 contains the general instruc¬ 
tions for use of the program. Table 2 is 
a listing of the general program. 

Typical Sample Run 

A model for the spread of an epidemic 
and its control is described by the follow¬ 
ing equations(2): 

S/= -cSI-v(t) S(0) = S G 
I = cSI — rl 1(0) = I„ 

R' = rl R(0) = § 

V ' - v(t) V(0) = 0 

where S is the proportion of susceptibles 
in the population, I is the proportion of 
infectives, R is the proportion of recov¬ 
ered, V is the proportion who have been 
vaccinated, c is the contact rate, r the 
recovery rate and v(t) the vaccination 
rate and S 0 + I 0 = 1. Since S +1 + R + V = 
1, we need solve only the first three 
equations, hence this program is ap¬ 
plicable. For the sake of simplicity we 
will assume that v(t) is a constant. 

Forty nine program steps were re¬ 
quired to define the three functions (see 
Table 3). Table 4 shows excerpts of the 
sample run which required a total of 
about 6 minutes for execution which is 
about 20 seconds per step. The para¬ 
meters chosen for this example are those 
of the 6th case in Table 1 of (2). 

Comments 

The execution time for this program 
is quite long even when compared to 


a minicomputer. However, the conve¬ 
nience can often outweigh the slowness, 
or make it possible to solve a problem 
even when a computer is not available. 
Another advantage is that the 12 digit 
accuracy of the SR-52 is equivalent 
to double precision on a 16 bit mini¬ 
computer. Since there are only 63 pro¬ 
gram steps available and 9 of these 
are used for label definition and returns, 
only relatively simple models can be 
simulated. But as the sample shows, 
there are meaningful models which fit 
this criterion. 

Programs to solve two first order equa¬ 
tions, a second order equation, or a third 
order equation using the 4th order 
Runge-Kutta method are available from 
the author. 

References 

1. Bekey, G. A., and Karplus, W. J., 
“Hybrid Computation.” John Wiley 
and Sons, New York, 1968. 

2. Hethcote, H.W., and Waltman, P. 
“Optimal Vaccination Schedules in a 
Deterministic Epidemic Model,” Math. 
Bios. 18, 365 (1973) 


S. Andrew Yakush received the 
A.B. degree from Andrews Uni¬ 
versity in 1966, the A.M. degree 
from the University of Southern 
California in 1972 and the Ph.D. 
degree from the same institution in 
1976. 

Dr. Yakush joined the faculty 
of the Biomathematics Department 
in the School of Medicine of Loma 
Linda University in 1972 where he 
is an Assistant Professor and has 
taught graduate courses in Bio¬ 
logical Control Systems and Bio¬ 
logical Modeling. He has also partic¬ 
ipated in several research projects 
pertaining to the applications of 
computers and mathematics to the 
medical and biologcal world, and is 
now project manager of the Image 
Processing and Pattern Recognition 
facility. 


Page 44 

392 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 







Table 1. 

General Instructions, 


Table 3. 
Sample Program 


Step 

Procedure 


Enter Press Display 

LOC 

rn 

KEY 

LOC 

Cl) 

KF.Y 

LOC 

cn 

KEY 

LOC 

CD 

KEY 







163 

46 

LBL 

176 

85 

+ 

189 

01 

1 

202 

15 

F 

11 c 


x’ - f(t,x,y,z) 




164 

13 

C 

177 

42 

STO 

190 

04 

4 

203 

43 

RCL 

12 r 


y’ = g(t,x,y,z) 




165 

43 

RCL 

178 

01 

1 

191 

75 

- 

204 

01 

1 

13 v 


z' * h(t,x,y,z) 




166 

01 

1 

179 

04 

4 

192 

43 

RCL 

205 

02 

2 

14 cSI 






167 

01 

1 

180 

43 

RCL 

193 

01 

1 

206 

65 

X 


l 

Enter program CA t» B) 




168 

65 

X 

181 

01 

1 

194 

02 

2 

207 

43 

RCL 







169 

43 

RCL 

182 

03 

3 

195 

65 

X 

208 

00 

0 


2 

Enter f(Roi■ R 02> R 03' R 04) 

into 

C 

CTO 163 

170 

00 

0 

183 

95 

. 

196 

43 

RCL 

209 

03 

3 



R< r 01> r 02' r 03' r oD 

Into 

D 

LRN 

171 

02 

2 

184 

94 

+/- 

197 

00 

0 

210 

95 




and h(Rgi,R o2> R 03' R 04) 

into 

E 

. 

172 

65 

X 

185 

56 

RTN 

198 

03 

3 

211 

56 

RTN 






. 

173 

43 

RCL 

186 

46 

LRL 

199 

95 

- 









. 

174 

00 

0 

187 

14 

n 

200 

56 

RTN 









LRN 

175 

03 

3 

188 

43 

RCL 

201 

46 

LRL 






3 

Enter half integration step 

H/2 

STO 98 

H/2 

4 

Enter number of steps 

N 

STO 00 

N 

5 

Enter initial conditions 

^o 

STO 01 

^o 



x o 

STO 05 

x o 



y 0 

STO 06 

Yo 



z o 

STO 07 

z o 





Printed 

6 

Start program 


A 

ti 





X 1 





Yi 





z i 


Available: 



etc. 


61 program steps (163-223) 
9 data registers (11-19) 



Table 2. 

Program Listing. 


LOC 

CD 

KEY 

LOC 

CD 

KEY 

LOC 

CD 

KEY 

LOC 

CD 

KEY 

LABELS 

000 

46 

LRL 

041 

43 

RCL 

082 

19 

D' 

123 

09 

9 

A 

Start 

001 

19 

D' 

042 

00 

0 

083 

44 

SUM 

124 

17 

B' 

B 


002 

55 

* 

043 

06 

6 

084 

06 

6 

125 

43 

RCL 

C 

f(t ,x,y,z) 

003 

43 

RCL 

044 

95 

- 

085 

09 

9 

126 

06 

6 

D 

g(t ,x,y,z) 

004 

09 

9 

045 

42 

STO 

086 

56 

RTN 

127 

0 7 

7 

E 

h(t ,x,y,z) 

005 

09 

9 

046 

00 

0 

087 

46 

LBL 

128 

44 

SUM 

A' 

used 

006 

95 

- 

047 

03 

3 

088 

1 1 

A 

129 

00 

0 

B' 

used 

007 

55 

RTN 

048 

43 

RCL 

089 

25 

CLR 

130 

05 

5 

C' 

used 

008 

46 

LBL 

049 

01 

1 

090 

42 

STO 

131 

4 3 

RCL 

D' 

used 

009 

18 

C' 

050 

00 

0 

091 

00 

0 

132 

06 

6 

E' 


010 

65 

X 

051 

85 

+ 

092 

08 

8 

133 

08 

8 



Oil 

43 

RCL 

052 

43 

RCL 

093 

42 

STO 

134 

44 

SUM 



012 

09 

9 

053 

00 

0 

094 

00 

0 

135 

00 

0 

REGISTERS 

013 

08 

8 

054 

07 

7 

095 

09 

9 

136 

Oh 

6 

00 

N 

014 

95 

- 

055 

95 

- 

096 

42 

STO 

137 

43 

RCL 

01 

ti 

015 

56 

RTN 

056 

42 

STO 

097 

01 

1 

138 

06 

6 

02 

xj+K/2 

016 

46 

LBL 

057 

00 

0 

098 

no 

0 

139 

09 

9 

03 

Yi+L/2 

017 

17 

B' 

058 

04 

4 

099 

03 

3 

140 

44 

SUM 

04 

zj+M/2 

018 

43 

RCL 

059 

13 

C 

100 

42 

STO 

141 

00 

0 

05 

x i 

019 

09 

9 

060 

18 

C' 

101 

09 

9 

142 

07 

7 

06 

Yi 

020 

08 

8 

061 

4 2 

STO 

102 

09 

9 

143 

99 

PAP 

07 

z i 

021 

44 

SUM 

062 

00 

0 

103 

16 

A' 

144 

43 

RCL 

08 

K/2 

022 

00 

0 

063 

08 

8 

104 

02 

2 

145 

00 

0 

09 

L/2 

023 

01 

1 

064 

19 

D' 

105 

22 

INV 

146 

01 

1 

10 

M/2 

024 

45 

LBL 

065 

44 

SUM 

106 

49 

PRD 

147 

98 

PNT(HLT) 



025 

16 

A' 

066 

06 

6 

107 

09 

9 

148 

43 

RCL 

67 

sum K/2 

026 

43 

RCL 

067 

07 

7 

108 

09 

9 

149 

00 

0 

68 

sum L/2 

027 

00 

0 

068 

14 

D 

109 

17 

B' 

150 

05 

5 

69 

sum M/2 

028 

08 

8 

069 

18 

C' 

110 

16 

A' 

151 

98 

PNT(HLT) 



029 

85 

+ 

070 

42 

STO 

111 

02 

2 

152 

43 

RCL 

98 

H/2 

030 

43 

RCL 

071 

00 

0 

112 

49 

PRD 

153 

no 

0 

99 

3 or 1.5 

031 

00 

0 

072 

09 

9 

113 

00 

0 

154 

06 

6 



032 

05 

5 

073 

19 

D’ 

114 

08 

8 

155 

98 

PNT(HLT) 



033 

95 

- 

074 

44 

SUM 

115 

49 

PRD 

156 

43 

RCL 



034 

42 

STO 

075 

06 

6 

116 

00 

0 

157 

00 

0 



035 

00 

0 

076 

08 

8 

117 

09 

9 

158 

07 

7 



036 

02 

2 

077 

15 

F. 

118 

49 

PRD 

159 

98 

PNT(HLT) 



037 

43 

RCL 

078 

18 

C' 

119 

01 

1 

160 

58 

DSZ 



038 

00 

0 

079 

42 

STO 

120 

00 

0 

161 

11 

A 



039 

09 

9 

080 

01 

1 

121 

49 

PRD 

162 

81 

HLT 



040 

85 

+ 

081 

00 

0 

122 

09 

9 








Table 4. 

Typical Sample Run. 


Step 

Procedure 

Enter 

Press 


1 

Enter program (A & B) 





2 

Enter definitions of f, g and h 


CTO 

163 



(see Table 3.) 


LRN 





LRN 


3 

Enter model parameters 






Contact rate c 

10 

STO 

11 

10. 


Recovery rate r 

6 

STO 

12 

6. 


Vaccination rate v 

.4 

STO 

13 

0.4 

4 

Enter initial conditions 







0 

STO 

01 

0 . 


So 

.99 

STO 

05 

.99 



.01 

STO 

06 

.01 


»o 

0 

STO 

07 

0 . 

5 

Enter integration paramaters 






H/2 

.05 

STO 

98 

.05 


N 

10 

STO 

00 

10. 






Printed 

6 

Begin integration 


A 


0.1 


S(.l) 



. 

9383331529 


I <. 1) 



. 

0143969329 


R(.l) 



• 

0072699143 


t 




0.5 


SC.5) 




6974981485 


I(.5) 



0 

.034952619 


R(.5) 



• 

0675492326 


t 

SO.) 



0 

1. 

.402482465 


id.) 



. 

0263862156 


R<1.) 



. 

1711313194 

7 

Change vaccination rate 

0 

STO 

13 

0. 

8 

Enter additional steps 

5 

STO 

00 

5. 

9 

Resume integration 


A 


1.1 


sd.n 



. 

3929749397 


id.i) 



. 

0215503779 


Rd.i) 




1854746824 


t 




1.5 


S(1.5) 




3709168282 


Id.5) 




0089478071 


Rd.5) 



. 

2201353647 


Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 45 






IMPROVEMENTS ON CP/M AND CDOS 


Dear Suzanne, 

Thank you for the great, all CP/M issue of DDJ #41. 
I have a few comments to say regarding Jim Warner’s article 
“CP/M and CDOS Program Compatibility.” There are two 
small bugs involved with this program. 

The first problem is that the function call 134 (FORMAT 
STRING TO FILE CONTROL BLOCK) builds the FCB 
correctly, but does not set the Next Record field to zero. 
This means that when the file is read in, CP/M will begin read¬ 
ing at the Record Number of the last record read of the pre¬ 
vious file. This is normally only noticed under DEBUG when 
reading in multiple files. The fix for this is simple, and only 
adds 7 extra bytes: 


NAM2: 

CALL 

DUMMY 

;THIS IS PART OF OLD CODE 


X0R 

A 



LD 

(DE),A 

;ZER0 FILE EXTENT 

> 

; THIS 

IS THE 

ADDED CODE 



PUSH 

HL 

;SAVE HL REG PAIR 


LD 

HL, 20 

;0FFSET FROM EXTENT TO NEXT REC. 


ADD 

HL, DE 

;HL POINTS TO NEXT RECORD FIELD 


LD 

(HL) , A 

;ZER0 NEXT RECORD 


POP 

HL 

;RESTORE HL 

; BACK 

TO ORIGINAL CODE 



POP 

DE 



RET 




The second, very small, problem concerns another function 
call. My version of EDIT (V00.10) does, as its first function 
call a GET VERSION AND RELEASE NUMBERS (8DH). 
As far as I can tell, EDIT does not care what values come back 
as the version and release numbers. There are two possible 
solutions to this. 

1. Patch EDIT to eliminate the call. 

The offending code (for EDIT V00. 10) is at location 
021CH. The original code is 

021C LD C.8DH 

021E JP 5 

If location 021CH is changed to a ‘RET’ instruction (C9) 
this eliminates the function call, and EDIT appears to operate 
correctly. 

2. Change FILTER to ignore any undecoded function calls. 
This may seem to be drastic, but I can report no problems 

with it in my experience. Change the instruction in FILTER 


Apart from these two small problems, I found Mr. Warren’s 
article both enjoyable and very useful, and so I thank both 
him and you for it. Keep up the good work. 

Sincerely, 25 Buena Vista Drive. 

Leigh F. Fiddes Montmorency. 3094. 

AUSTRALIA. 

MORE ON INDIRECT ADDRESSING 
FOR 8080/Z80 

Dear DDJ : 

With reference to “Indirect addressing for the 8080 and 
Z80” (DDJ #47), an alternative way to implement LHLI is 


; LHLI performs HL:=(HL) 
LHLI: PUSH PSW 
MOV A,M 
I NX H 
MOV H,M 
MOV L,A 
POP PSW 
RET 


This is more efficient than the “miniprogram” technique 
described and avoids the gaucherie of self-modifying code. 

Similarly, 


; IXMOV performs A:=(A+X) 
IXM 0 V: PUSH 0 
PUSH H 
PUSH X 
POP H 
MVI 0,0 
MOV E,A 
DAD D 
MOV A,M 
POP H 
POP D 
RET 


Obviously, macro versions of this could be written to 
handle indexed moves to other registers. Also, the PUSH- 
POP pairs may be omitted when the application does not need 
the corresponding registers saved. 



JP NZ.IGOR ;NOT DECODED, ** ERROR ** Sincerely, 

to David Ecklein 

RET NZ ;NOT DECODED, IGNORE AND RETURN 


Tesseract Associates 
Stinson Lake Road 
Rumney, New Hampshire 03266 


Page 46 

394 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 









INTERFACING H -14 TO HORIZON 


ADDENDUM TO “ZX65” 


Dear Editor: 

May I make the following suggestion in response to John 
R. Dye, {DDJ #47), regarding interfacing a Heathkit printer 
H- 14 to a North Star Horizon. 

Instead of trading away a very nice printer, why not make 
it run full speed? The North Star Horizon ports are extremely 
flexible and can interface to almost anything. You may wish 
to publish the following 3-wire configuration setup to assist 
others who wish to wed these two devices. 

On the Motherboard header at location 4D, solder a wire 
from pin 7 to pin 8 and also a wire from pin 9 to pin 10. 
Then solder a wire from pin 12 of header 4D over to pin 
12 of the header at location 2C. These 3 connections should 
be the only ones on these headers. 

This allows the printer to run at full speed by having the 
printer’s buffer full signal (interface pin 15) drop Clear to 
Send to the second serial port USART. No software changes 
are necessary. 

Sincerely, 3417 Hickory Hills Drive 

Warren B. Saunders Oakton, Virginia 22124 


Dear Editor: 

I am writing in reference to J. R. Dye’s letter in DDJ 
#47. I agree with him that you should be aware of the com¬ 
plexity of integrating different manufacturers’ hardware. 
Mainframe manufacturers’ suggested configurations in many 
cases do not represent the best alternative to a user’s needs. 

There is no substitute for knowledge of your hardware’s 
capabilities. The North Star Horizon has the needed hardware 
and software to perform the simple handshaking the H14 
printer requires. I’ve successfully interfaced a Texas Instru¬ 
ment’s 810 printer to the Horizon’s serial ports. 

This printer buffers incoming data until whole lines have 
been received. The printer then prints the buffer while holding 
pin 20 of the EIA interface low (DNB option in the 810 
printer must be selected). The serial output routine must be 
able to detect this low signal and hold further output as the 
printer logic is BUSY printing the buffer. 

The STANDARD serial output routine in the NORTH 
STAR DOS tests the least significant bit (TxRdy) of the serial 
port status byte. This bit is ON if the serial port is ready to 
receive a character from the CPU for output processing. This 
bit is affected by the CTS (clear to send) input to the 8251 
USARTs that control the serial ports. The CTS input is termi¬ 
nated at pin 12 of the serial port config header. 

In my application it was a simple matter to rewire the 
serial config header to jump (EIA pin 20/header pin 1) to 
(header pin 12/8251 input CTS). This turns OFF TxRdy bit 
in the serial port status byte when the busy printer is holding 
EIA pin 20 low. Note that a low on header pin 12 results in 
a high at the 8251 due to inverting EIA receiver. 

Be aware that more is involved than just the above details 
in making the interface work. You must carefully scrutinize 
hardware documents in building the config. header and I/O 
cable. Your objective should be to get a low signal to pin 12 
of the serial config. header signifying the printer is busy. 

Pitfalls such as inverting EIA receivers/drivers, strapable 
hardware options and special I/O cables can make a maze 
out of the best documentation. I have personally experienced 
the excellence of North Star’s hardware manual as well as the 
T.I. 810’s. I would suggest you find a more knowledgable 
Horizon dealer, friendly or not. 

Sincerely, 2021 N. 22nd Street 

John T. McCarron Phoenix, Arizona 85006 


Dear Editor: 

A potentially serious error in “ZX65: Simulating a Micro” 
(DDJ #47) has been pointed out to me by a user. It is sys¬ 
tem dependent and, fortunately, fairly rare. In those cases 
where the problem exists, however, ZX65 simply won’t accept 
input from the console keyboard, and thus will not respond to 
commands once loaded. 

The problem is that ZX65 expects the user’s console print 
routine CONOUT to return with the character just printed 
still in the accumulator. In those few instances where this 
doesn’t happen, the following patch will solve the problem: 


ADDRESS 

OBJ CODE 

INSTRUCTION 

7A28 

C3 80 7D 

JP 7D80 


7D80 

F5 

PUSH AF 

7D81 

CD 0C 7E 

CALL CONOUT 

7D84 

FI 

POP AF 

7D85 

C9 

RET 


This patch can be inserted by loading ZX65.COM under DDT, 
making the changes using the “S” function, and storing the 
modified code back to disk, following warm start, by typing 
“SAVE 15 ZX65.COM” 

Respectfully, 6221 Woodlow 

Richard M. Kruse Wichita, KS 67220 


WHEN MINIMUM VALUE EQUALS MAXIMUM 
COST 

DDJ: 

Most readers probably feel, as I do, that the goal of all 
human enterprise is to provide maximum value and service 
at minimum cost. This minimum can never be zero, since 
someone must pay the piper. I was therefore interested to 
learn that someone at Prentice-Hall did not agree that the 
numerical value of price is always positive. They sent me, 
earlier this year, no less than two announcements of a new 
book, Microcomputer Interfacing, by Bruce Artwick. Each had 
a postcard saying: “Yes, please send me a FREE 15-day exam¬ 
ination copy. After I’ve seen (it) . . .I’ll send you my check for 
$18.95 plus postage and handling. Otherwise, I’ll return the 
book during the 15-day trial period and owe nothing.” My 
normal tactic for new books is to wait until they show up in a 
bookstore, and to look them over very carefully before arri¬ 
ving at a decision (usually negative, since truly fine books are 
rare). So I ignored the first P-H message, but when the book 
failed to appear I sent in the second postcard. So that my tiny 
circle of admirers will not feel that I have lapsed into senility, 
let me add how I interpreted the word FREE as used by P-H. 
Since the retail markup of a book is 40-50%, I assumed that 
P-H was not really expecting to reap this for itself, but wished 
to provide extraordinarily early availability—a special serv¬ 
ice-while absorbing the extra costs (trivial handling charge, 
etc.). 

The P-H interpretation of the word FREE is significantly 
different. I had sent the card in May. Nothing happened. 
In late June, the book appeared in a local bookstore. A very 
small book, technically OK, not worth the price ($20.18, 
including sales tax.) My examination of it was really FREE 
for me, though of course the principle that nothing is free 


Number 49 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Page 47 

395 




was not violated —the overhead costs to the store are ulti¬ 
mately paid, by me and others, as part of the price of the 
books we buy. That’s fairness. 

Yesterday, the P-H computer acknowledged my card of 
last May by sending me a bill for $23.09, itemizing the base 
price plus $2.73 postage and handling, plus $1.41 sales tax. 
This tax is 18 cents higher than the local tax, since the com¬ 
puter is programmed to tax the postage-and-handling too. 
The computer also knows that the Berkeley tax is 6.5%, 
not 6% as in most of the state. It doesn’t know that the card 
it was answering forgot to mention a tax, or that there is as 
yet no book. It is probably now counting down from 15 days, 
when it will emit a second bill. As to the book itself, the mills 
of the gods (notoriously slow) may even now be grinding away 
at this trivial problem. For the scam to be truly perfect, it 
ought to appear on day — 1 of the countdown! The FREE 
offer would then become an unconditional sale, delivered 
4+ weeks later than I could have got it in Berkeley and at a 
price $2.91 higher. This idiotic rigmarole perhaps makes 
sense for a potential buyer in the middle of the Sahara desert. 
The P-H computer, so deeply versed in the minutiae of taxa¬ 
tion, is unaware that Berkeley is awash with books. 

Fairness compels me to acknowledge that the P-H organiza¬ 
tion is not made up 100% of nitwits (except perhaps at its 
selling end). Last May I had a phone call from the Bay Area 
P-H representative, Howard Welt, an intelligent and courteous 
man. He had seen my articles on Instruction Sets in Kilobaud 
Microcomputing , and wondered whether I had enough 
material for a book. I said no, explained why not, and sug¬ 
gested names of people who might be interested. Later, I wrote 
him a letter with supplementary information. No “handling 
charge” (P-H) since I’m a true believer in the dissemination of 
information at minimum cost. That’s the major role of a 
university. I don’t expect book publishers to operate at a loss. 
Still, they also are disseminators of information. I do expect a 
high level of integrity and efficiency. The cost of the Artwick 
book could have been reduced by using paperback instead of 
hardcover. Since such books begin to obsolesce before the ink 
is dry, softcover makes better sense. 

Sincerely, College of Natural Resources 

Hal Gordon University of California 

Berkeley, CA 94720 

TOO MUCH Z80, 8080 AND CP/M 

Dear Dr. Dobb’s: 

Thank you for the issue on the Language C (DDJ #45). It 
is nice to see some recognition for alternatives to PASCAL. 

Tim Pugh’s article in DDJ #46 on MCALL-C, while inter¬ 
esting, contains an instance of the much-too-prevalent atti¬ 
tude that everybody who has a disk system is using it with a 
Z-80 or 8080 and is running CP/M. For a column and a half, 
the article, which is about a communications protocol for 
sending files from one personal computer to another, could 
apply to any computer with a modem and a disk. Then he 
answers the question of why it takes an indeterminate amount 
of time to open a file by saying that it’s because of the wide 
variety of disks and controllers that can be used with CP/M! 
I was expecting something more like: it’s because of the wide 
variety of disks, controllers, operating systems, and processors 
that are in use. Instead, we are apparently intended to assume 
that the only disk operating system (DOS) that exists is CP/M 
(and by implication, that the only microprocessors that exist 
are the 8080 and Z-80). To be fair to Mr. Pugh, he has deve¬ 
loped the protocol on a CP/M system and is apparently selling 
this CP/M implementation of it. However, there is nothing 
about the protocol that requires CP/M. It could be imple¬ 
mented for any DOS on any processor. 


I would like to clarify the remarks I made in my letter that 
appeared in DDJ #46 (page 55). My statement that CP/M 
will not be “universal” until there are versions of it for many 
other processors (6800, 6502, etc.) was not intended to imply 
that I advocate such implementations. CP/M has a number of 
limitations and shortcomings that should not be perpetuated 
in other operating systems. The biggest such problem is 
probably the lack of device-independent I/O, as well as the 
fixed and rather limited number of devices supported. CP/M 
keeps track of the size of disk files in sectors rather than in 
bytes. Thus, a special data character (control-Z) is required to 
mark the end of a text file, and files containing “binary” in¬ 
formation must be a multiple of 128 bytes in length. These 
features, resulting to some degree in two file types or formats, 
are at best unattractive. The orientation toward disks with 
128-byte sectors, toward terminals with upper case only, 
its encouragement of assembly language for almost all pro¬ 
gramming; the restriction, removed in the latest release, to 
disks of 256K bytes or less; the rather clumsy method of 
random access to disk files, improved in the latest release; 
and the fact that processing and I/O cannot be overlapped are 
also problem areas. Perhaps it is because of some of CP/M’s 
limitations that it can run on as many different systems as 
it does. 


Sincerely, 5472 Playa Del Rey 

Jim Howell San Jose, CA 95123 



Page 48 

396 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Box E, Menlo Park, CA 94025 


Number 49 




© David Dameron 1979 


397 






































































































































































































































































































































































































































































































































































































































































































































































































































































Dr. DoBB'S JoURNALof 

COMPUTER 

(Calisthenics ^Orthodontia 

Running Light Without Overbyte 

Number 50 November/December 1980 Volume 5, Issue 10 

A REFERENCE JOURNAL FOR USERS OF HOME COMPUTERS 


N-Logs: A New Number Language for Scientific Computers 4 

Keneth A. Simons 

Las Vegas Super Slot: A CP/M Game Machine Program Using Flashwriter I Graphics 10 

David W. Freidman 

Quick-Key: A North Star BASIC Statement Generator 23 

Leonard E. Garcia 

TUTOR: A Foreign Language Vocabulary TVainer 29 

Gary D. Gaugler 


Interfacing the WH14 Printer to Your Microcomputer’s Serial Port Is Simpler Than You Think 30 

Lachman Sippy 

and more ... 


399 



\IO(.S 



ANEW 

NUMBER LANGUAGE 
FOR 

SCIENTIFIC COMPUTERS 

by Keneth A. Simons 


SUMMARY: The N-log is so defined that it is a simple 
positive integer used to represent any number, with any re¬ 
quired precision. No suffixes, prefixes, exponents or decimal 
points are needed to allow symbolizing the entire range of 
numbers encountered in scientific computations. N-logs 
are particularly useful with digital computers, eliminating 
the need for floating point routines and exponential notation. 
A procedure is described that allows finding the N-log of 
the sum or difference of two numbers, when the N-log of 
each is known, without converting from N-logs to numbers or 
vice-versa. 

INTRODUCTION: Since men first started numbering and 
measuring, the results have been written symbolically. There 
is, for example, not the remotest relationship beween the 
symbol ‘2’, or the word ‘two’, and a pair of things as they exist 
in nature. We have all become accustomed to the fact that one 
represents the other, but the whole idea is strictly man¬ 
made. Since this is true, it is perfectly allowable to look for 
other, and possibly more convenient, ways of representing 
numbers. A good example is found in the hexadecimal system 
where, because it is convenient in the computer context, we 
use, for example, the symbol A to represent the number that 
has been symbolized by 10 for at least a thousand years! 
This paper describes a new way of representing numbers which 
is based on simple fundamental principles and has many 
advantages over conventional methods. 

THE DEVELOPMENT OF SYMBOLS FOR NUMBERS: 

When a prehistoric farmer asked his slave how many hogs were 

Keneth A. Simons —2035 Willowbrook Drive, Huntingdon 
Valley, PA 19006 


in a field, the man might have held up nine fingers, or made 
nine scratches in the dirt, like this: 


This system was direct, but became cumbersome for the 
wealthy with lots of pigs! So a better system evolved wherein 
one counted four pigs, then scratched diagonally across to 
show the fifth. With these symbols twenty-four pigs would 
appear as: 

One simply counted up how many fives there were, added 
the odd ones and arrived at the number. 

ROMAN NUMERALS: As history progressed it became 
necessary to deal with larger numbers, and a simpler system 
was needed. The Romans came up with a scheme where letter 
symbols were used for numbers. Thus I represented one, V 
was used for five, X for ten, L for fifty, C for a hundred, and 
so on. Any number could be portrayed by writing the appro¬ 
priate symbols in a row, with the smaller ones on the right. 
The number represented was understood to be the sum of 
the numbers indicated by the symbols. Thus CCLXI meant 
two hundreds (CC) plus a fifty (L) plus a ten (X) plus one (I), 
or two hundred and sixty-one. Unfortunately, at about this 
time, mankind became interested in calculation. With the rise 
of commerce and the early beginnings of the sciences it be¬ 
came necessary not only to be able to write numbers but also 
to use them in calculations. The processes of multiplication, 



Page 4 

400 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 







division and the expression of fractions were extremely clumsy 
using the Roman system. As Dr. Jacob Shekel once said, 
referring to the failure of the Romans to recognize the use¬ 
fulness of a symbol for zero, “Their trouble with numbers 
was that they didn’t know nothing.” 

ARABIC NUMERALS: Fortunately a system had been in 
use in the Arabian countries for centuries based on three 
revolutionary and incredibly useful concepts. This system was 
to be adopted by the Western world, and it played an import¬ 
ant part in making possible the rapid development of the 
physical sciences during and after the Renaissance. These 
concepts were: 

1. Nothing was given a name (zero) and a symbol (0). 

2. The next nine numbers were given both names and symbols 

with the English names: one (1), two (2), three (3), four 

(4), five (5), six (6), seven (7), eight (8), and nine (9). 

3. The weight of a given digit was indicated by its position. 

Thus the right-most digit was assumed to be multiplied by 

1, the next digit to the left by 10, the next by 100, and so 

on. 

Using the Arabian system the symbol 9870 would be inter¬ 
preted as (9 X 1000) + (8 X 100) + (7 X 10) + (0 X 1). This 
way of symbolizing numbers greatly simplified the algorithms 
for the needed mathematical calculations so that, compared 
with earlier systems, these calculations were accomplished 
much more rapidly. 

FRACTIONS: With the acceptance of Arabic numerals, an 
additional need developed —the need to represent numbers less 
than one. Unfortunately a solution arose which originated 
centuries of confusion from which we still suffer: the fraction 
was introduced! Numbers less than one were represented as 
the quotient of one integer divided by another. These symbols 
were clumsy to write, and, as any grade school graduate 
knows, calculations involving them were complex and cumber¬ 
some. To make matters worse the British embraced the idea 
and saddled us with a system of measurement that is incredi¬ 
bly inefficient. They did, in retrospect, the strangest things, 
avoiding the number 10, the base of their number system, as if 
it were a plague! A mile was divided by 1760 (where did that 
come from?) to get the yard. The yard was divided by 3 to get 
the foot (why 3 rather than 5 or 10?) The foot was split into 
12 parts (they couldn’t use 10, it might simplify things) to 
get the inch. Then they ran out of names, so smaller sizes were 
expressed as fractional parts of an inch, right on down to 
l/64s. The whole mess has become part of our culture, and 
probably has wasted more man-hours of intellectual effort 
than all of the World Wars combined! 

DECIMAL FRACTIONS: A much simpler way of represen¬ 
ting numbers less than one followed the invention of the 
decimal point, and the discovery that a self-consistent system 
resulted when the first digit to the right of that point was 
assumed to be divided by 10, the second by 100, the third by 
1000, and so on. With this approach the symbol .235 represen¬ 
ted the sum of 2/10 + 3/100 + 5/1000. The great advantage 
of presenting numbers this way lay in the fact that all of the 
calculating algorithms that worked with integers were equally 
useful with numbers containing decimal fractions, as long as 
care was used to place the decimal point in the right position 
in the result. They had the further advantage that they were 
easier to write since there were no numbers above or below the 
line. Decimal fractions are almost universally used in today’s 
pocket calculators, which generally don’t display ordinary 
fractions It seems possible that, between these calculators and 
the almost world-wide adoption of the metric system, the 
world may (except for some back-water areas like our own 


country!) at long last get rid of the English system and the 
ordinary fraction. 

EXPONENTS AND EXPONENTIAL NUMBERS: With 
the rapid development of astronomy, physics and the other 
natural sciences in the 16th and 17th centuries, came the need 
for improved ways of handling very large and very small 
numbers. Astronomical measurements showed, for example, 
that the distances to even the nearer stars were so great that 
they could conveniently be expressed by using a ‘light year,’ 
the distance travelled by light in one year. One light year is 
about 6000000000000 miles. In physics it was found that the 
rest mass of an electron is something like 0.000000000000000 
0000000000000001 kilograms. It was obvious that it was 
impractical to express numbers like this with ordinary 
numerical notation. A more compact and convenient numeri- 
ca language was needed. 

It had been customary for some time to express the number 
of times a number is multiplied by itself by the use of an 
‘exponent,’ a tittle numeral written above and to the right. 
Thus 2 times itself, called “two squared,” was written 2 2 . 
2X2X2, called 2 cubed, was written 2 3 , and so on. The 
use of the number 10 with various exponents turned out to be 
a very effective answer to the problem stated above. Since 
10 12 = 1 followed by 12 zeroes, an awkward numeral like 
6000000000000 could be broken up into the product of 6 
by 1000000000000, written simply as 6 X 10 12 . This tech¬ 
nique provided a much simpler and more satisfactory way 
of dealing with very large numbers. To deal with small num¬ 
bers the fact was used that a number with a negative ex¬ 
ponent is equal to the inverse of the same number with the 
same exponent having a positive sign. Thus 10 -4 = 1/10 4 
= 0.0001. The rest mass of the electron, written above with 
30 zeroes followed by a 1, could be expressed much more 
compactly as 1 X 10' 31 kilograms. Numbers expressed in this 
way, i.e., using an exponent, are called “exponential numbers” 
and this technique for handling very large or very small num¬ 
bers is called “scientific notation.” It is used almost universally 
in scientific work where large or small numbers are involved, 
and is available in most calculators and computer languages 
intended for use by those concerned with scientific calcula¬ 
tions. 

LOGARITHMS: Another important numerical language 
that is closely related to the exponent is the logarithm. The 
basis for logarithms is the fact that any number can be raised 
not only to a power which is an integer (e.g. 8 6 =262144 or 
3 4 =81). but also to a power that includes a decimal fraction 
(e.g. 2*' 89 = approximately 3.706, 10 1-1 = approximately 
12.59). The logarithm of any number is simply the power to 
which some other number (called the “base”) must be raised 
to equal it. Thus, referring to the examples above, the loga¬ 
rithm of 262144 to the base 8 is seen to be 6 (since this is the 
power to which 8 must be raised to equal 262144); and the 
logarithm of 12.59 to the base 10 must equal 1.1 for the same 
reason. 

Logarithms were originally discovered by Napier, who used 
the number “e” (=2.71828. . .) as his base. His reason for this 
choice was that the logarithm of a number to this base (called 
its “natural” logarithm) is relatively easy to compute. This is 
also the reason why many computer languages give the natural 
logarithm. Briggs later discovered that, since our numerical lan¬ 
guage, the decimal system, is based on the number 10, 10 also 
makes a very convenient base for logarithms. He, and others 
who followed him, compiled tables of these logarithms which 
formed, for almost 250 years, the basis for almost all accurate 
computations in the sciences and in surveying. 

The advent of the electronic computer in the middle of the 
20th century changed all that. Its speed and facility are so 
much superior to that achieved with logarithms that the use of 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 5 

401 



the latter for computation has practically crushed. In the 
1961 edition of the Encyclopedia Brittamca VKet. 1) h.. VJ. 
May states that . . logarithms (are) virtually obsolete for 
large-scale computation, though they are used in the 1960’s 
for a few special purposes and indirectly as the basis of the 
slide rule.” (In 1980 even this use has disappeared, although 
the logarithm still remains as the basis for the decibel, widely 
used in communications and acoustics.) 

It is a strange quirk of history that today, when the compu¬ 
tation of a logarithm requires only the operation of an inex¬ 
pensive pocket calculator, the need for them has almost com¬ 
pletely disappeared! Almost all the computations that former¬ 
ly required logarithms are now done by these same calculators, 
or their big brothers, the electronic computers. The object of 
this paper is to propose a new idea, inspired by the almost uni¬ 
versal acceptance of the decibel. What is proposed is the use of 
the logarithm as the basis for a new numerical language, called 
“N-logs” which, being integers, are more convenient for 
people to handle, and especially suited for use as input and 
output numbers for computers. 

PRECISION AND ACCURACY: Since one of the major 
advantages of N-logs has to do with their precision, it is im¬ 
portant to establish clearly what that word means. The Inter¬ 
national Dictionary of Applied Mathematics (Ref. 2) defines 
“accuracy”: 


Accuracy: The degree of exactness actually possessed by an 
approximation, measurement, etc. It may be contrasted with 
precision which is the degree of exactness with which a quanti¬ 
ty is expressed. For example, as a value for Tt the number 
3.1428 is more precise than accurate. 


This is, of course, because that number is in error by about 
.04% (as compared with the correct value, 3.1416), whereas it 
is stated with a precision of plus or minus 0.0016% (the 
maximum range of numbers implied by the digits 3.1428). As 
another example, suppose that a digital voltmeter reads 
8.19271 when measuring a certain voltage, but it had been cal¬ 
ibrated against a voltage standard which had an error of 0.1%. 
The accuracy of this measurement, limited by the standard, 
would be only 0.1%, while the precision of the reading would 
be about 1 part per million, 1000 times better. 

THE PRECISION OF RATIONAL NUMBERS: All of the 

numbers that report the results of measurement in engineer¬ 
ing and the sciences are “rational numbers” since they must be 
written with a limited number of digits, and, for the same 
reason almost all of them represent approximations (the single 
exception being integers that result from counting a few 
items, which are the only numbers we deal with that can be 
exact). Because of this it is important to ask what factors af¬ 
fect the precision of numbers as they are usually written. It is 
common to speak of “three figure accuracy,” implying that 
the precision is affected only by the number of digits. Unfor¬ 
tunately this is not true. The precision with which a number is 
written depends not only on the number of digits that are 
used, but on what those digits are. As an example the number 
9821, as an approximation, represents the result of rounding 
any number between the limits 9820.5 and 9821.5. With four 
significant figures, the number has a precision of 51 PPM (the 
error of 9821.5 compared with 9821). The number 1032, on 
the other hand, with the same number of digits, is written with 
a precision of only 484 PPM (the error of 1032.5 compared 
with 1032), almost 10 times poorer than 9821! This problem 
of variable precision is inherent in our number system, and is 
a result of the fact that it was developed for counting, rather 
than for measuring ratios, so that each successive number in a 
series, as we write it, is arrived at by adding a fixed small num¬ 
ber to the previous one. 

Page 6 

402 


THE PRECISION OP LOGARITHMS: By contrast consist 
the LOGs (see -NOTE, p. 36) ot the two numbers written above. 
The LOG of 9821, written with three digits to the right of the 
decimal point, is 3.992. Since this number approximates all 
LOGs between 3.9915 and 3.9925, it represents all numbers 
between 9806 (EXP 3.9915) and 9829 (EXP 3.9925) and it 
represents these numbers with a precision of about 0.12%. 
Compare this with the LOG of 1032, which is 3.014. This re¬ 
presents the spread of numbers between about 1032 (EXP 
3.0135) and 1034 (EXP 3.0145), also showing a precision of 
about 0.12%. This illustrates a fact that is basic to this pre¬ 
sentation: the precision with which a LOG represents a num¬ 
ber is determined only by the number of digits in the LOG to 
the right of the decimal point, and is not affected by what 
those digits are. It is for this reason that logs are called “the 
language of ratios,” and make an excellent numerical language 
for reporting ratio measurements. 

PEOPLE PREFER INTEGERS: Most people dislike frac¬ 
tions (including the decimal kind) and avoid using them when¬ 
ever possible. A person who goes into a lumber yard asks for a 
“2 by 4,” although the actual dimensions of the board he 
wants are close to 1-3/4 by 3-3/4 inches. He asks for “Num¬ 
ber 22” wire at the radio store, when the actual diameter of 
the wire he wants is around 0.025 inches. Although he actually 
pays 0.17 times the principle on his mortgage, he calls this 
“17%.” The whole complicated series of prefixes for metric 
measurements is chiefly aimed at keeping the numbers used as 
close to integers as possible. We’d much rather say 83 milli¬ 
meters than “0.083 meters;” 102 microhenries is less of a 
mouthful than 0.000102 henries. One rather silly place where 
this breaks down is in the measurement of capacitors. Through 
long-standing custom we almost always say “.005 micro¬ 
farads” rather than “5 nanofarads,” which is just as correct 
and much easier to state. 

THE DECIBEL: One of the cleverest dodges for turning 
complicated numbers into integers was invented at Bell Labor¬ 
atories in 1924. They multiplied the LOG of any power ratio 
by 10 and obtained a beautifully simple series of integers to 
describe the quantities which most concerned them: gain, loss 
and power levels in telephone systems. Unfortunately they 
made two mistakes that severely limited the spread of their 
idea. In the first place they insisted that the process could only 
be used with power and power ratios (which limitation has no 
basis in fact since, obviously, the LOG of any number can be 
taken, and the result multiplied by 10, whether the number re¬ 
presents power, resistance, length or the population of Malay¬ 
sia!) (see Ref. 3) The only sensible question is “Does this pro¬ 
cess yield a convenient result?” If it does, it should be used. 
The other mistake the Bell people made was to adopt a very 
confusing terminology. They said, for example, that the atten¬ 
uation of a section of telephone line was measured and ex¬ 
pressed in terms of a unit, the decibel. They considered atten¬ 
uation as a measurable Physical Quantity (which it is, being a 
measurable property of a Physical System), but they also con¬ 
sidered the dB as the Physical Unit in terms of which this 
quantity was measured. One dB is no more a Physical Unit 
than the number 3! The statement “The ratio is one decibel” 
means nothing more nor less than “10 times the LOG of the 
ratio = 1,” i.e., the LOG of the ratio is 0.1 and, since EXP 0.1 
- 1.259, the ratio is approximately 1.259. The number 1.259 
can, by no stretch of the imagination, be called a unit of any¬ 
thing! 

N-LOGS-EXPRESSING ANY NUMBER AS AN INTE¬ 
GER: Since it is clear that people prefer integers, it makes 
good sense to look for a number language that allows expres¬ 
sion of any number in that form. The decibel approach points 
the way, 10 times the LOG of any number can be rounded to 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 




form an integer but when this is done the precision of the 
expression is restricted. This can be seen if we consider the 
range of numbers represented by, for example, 3 decibels. The 
corresponding nominal ratio is found from 10 X LOG X = 3, 
LOG X = .3 and X = EXP .3, i.e., X = 1.995. At the upper lim¬ 
it 10 X LOG Y = 3.5, and Y = EXP .35 = 2.239. Since 2.239 is 
12% higher than 1.995, and LOGs with the same number of 
significant figures to the right of the decimal point represent 
the corresponding number with the same precision, it follows 
that dBs, rounded to integers, have a basic precision of plus or 
minus 12%. Since this precision is inadequate for many appli¬ 
cations, the next question is “How can the precision be im¬ 
proved without losing the important advantage of the integer 
presentation?” The answer is very simple. As with any other 
decimal number, multiplying a LOG by 10 has the effect of 
moving the decimal point one place to the right. Thus 3 dB 
is simply the LOG .3, with the decimal point shifted. To move 
that point two places would require multiplication by 100, 
three places would require 1000, and in general, to move the 
decimal point in a LOG “N” places requires multiplying the 
LOG by EXP N, where N is 1, 2, 3, 4, 5, 6 and so on, as 
required. From this follows the definition of N-logs: 


The N-log of a number is that integer most closely ap¬ 
proximating the product of EXP N and the LOG of the 
number. 


It should be noted that N is not necessarily an integer. In fact 
the multiplier, defined above as 10 N , can be any number. The 
implications of this fact are very broad, showing that one has a 
wide choice of multipliers so that the use of the N-log con¬ 
cept is not restricted to the decimal system, but can be used 
with any number language. However our calculators and our 
brains are both more at home with the 10-based system, so 
the general case will not be explored further in this paper. 

Since N-logs as defined above, where N is a small integer, 
are easily found with a pocket calculator, it makes sense to use 
them. An understanding of the characteristics of each “fami¬ 
ly” (i.e., the N-logs resulting from each choice of N)is essen¬ 
tial if the idea is to be applied to practical situations. Table I 
shows how the choice of N determines the number of digits in 
the N-log, and the precision with which it can express a 
number. It can be seen that these families provide a very wide 
range of capabilities. 


TABLE I 

The Properties of the First Seven Families of N-logs 


Faitily 

N 

Multiplier 

It of Digits* 

Precision 

1-Logs 

t 

10 

3 

♦ 

12 

z 

2-Logs 

2 

100 

4 

♦ 

1.2 

z 

3-Logs 

3 

1,000 

5 

+ 

0.11 

z 

4-Logs 

4 

10,000 

6 

♦ 

0.011 

z 

5-Logs 

3 

100,000 

7 

+ 

11 

PPM 

6-Logs 

6 

1,000,000 

8 

+ 

1.1 

PPM 

7-Logs 

7 

10,000,000 

9 

♦ 

0.11 

PPM 


* The number of digits is that required to represent numbers 
between 10”" and 10 + ". 


N-LOGS SIMPLIFY EXPRESSIONS: The simplicity 
achieved by the use of N-logs can best be illustrated by a few 
examples: The mean distance from earth to the sun is 
9.3 X 10 7 miles. The Two-log of this distance in miles is 797, 
expressed with a precision of ± 1.2%. Instead of reporting the 
result of measuring a certain capacitor as “986 picofarads” it 
could be expressed by stating the Three-log of the capacitance 
in farads, which is -9006, with a precision of ±0.11%. One 
light year, stated as the Six-log of the number of miles, is 
12768973, expressed with a precision of about 1 PPM. The 
rest mass of the electron, in kilograms, is expressed, including 
the accuracy with which it is known, by the Six-log -30040- 
502±6. Since a change of 1 in the right-hand digit of a Six-log 
corresponds to about 1PPM (regardless of what the digits are) 
this states, without the use of any additional symbolism (like 
PPM or %), that this quantity is known with an accuracy corre¬ 
sponding to ±6 PPM. This simplicity in the statement of toler¬ 
ance is one of the several advantages of N-logs. 

AN N-LOG IS SIMPLY A LOGARITHM TO A DIFFER¬ 
ENT BASE : The bases that have been used for systems of loga¬ 
rithms in the past have been a small group. They include 
10 as the base for Common Logarithms; the number “e” 
(2.71828 .. .) as the base for Natural Logarithms; and more re¬ 
cently 2 as the base for logarithms relating to computer opera¬ 
tion. This paper is an attempt to show that many other bases 
are not only possible, but sometimes very convenient. To show 
that an N-log, as defined above, is simply a logarithm to a 
base which is different from 10, e or 2, some new terms are 
needed. In what follows the word “log” will be used to mean 
a logarithm in general, i.e., one taken to any base. With a sub¬ 
script (“log x ”) it will indicate a logarithm to the base indi¬ 
cated by the subscript, e.g., log 2 will mean the logarithm to 
the base 2. 

The formula for changing the base of a logarithm can be 
found in any elementary Algebra text. One way to state it is: 

log x a = logy a / logy x 

In this equation x and y are constants (the two bases) and a is 
a variable, thus dividing log y a by log y x is the same as multi¬ 
plying it by the constant 1 / log y x. So every N-log, which is 
found by multiplying the log 10 of a number by a constant, is 
simply a log, and all the rules that apply to logs apply equally 
to N-logs, including the four basic rules: 


log(XY) = log(X) + log(Y) 
log(X/Y) = log(X) - log(Y) 
log(X v ) = YX log(X) 
log( Vx) = log(X) / Y 

FINDING LOG(X+Y) WHEN LOG(X) AND LOG(Y) ARE 
KNOWN: To allow all the numbers in a computer program to 
be represented by N-logs, and to avoid the need for changing 
N-logs to ordinary numbers, or the converse, a procedure is 
needed that allows finding the N-log of the sum or differ¬ 
ence of two numbers directly when the N-log of each one is 
known. Although it is not found in many modern textbooks, 
such a procedure exists. It was invented in 1803 by an Italian 
physicist named Leonelli, but was popularized by Gauss, and 
called “Gaussian Logarithms” (see Ref. 1). Actually the logic 
involved is quite simple, and the computer operations that are 
required are reasonably fast and easy to implement. The 
mathematical development of the formulas for accomplishing 
this is shown in Appendix I, and the results for one family, 
the Two-logs, are shown in Tables II, III and IV. Similar tables 
for Three-logs would contain 300 lines each, 3000 for Four- 
logs and so on. 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 7 

403 




TABLE II 

Sum Factor for Two-logs 

When A-B is 

TABLE III 

Difference Factor 
for Two-logs. A-B < 30 

Uhen A-B D 

TABLE IV 

Difference Factor 
for Two-logs. A-B > 30 

Uhen A-B is D 

between: 

S equals: 

equals: 

equals: 

between: 

equals 

0 

- 

1 

30 

0 

infinity 

30 

- 

30 

30 

2 

- 

3 

29 

1 

164 

31 

- 

31 

29 

4 

- 

5 

28 

2 

135 

32 

- 

32 

28 

6 

- 

7 

27 

3 

118 

33 

- 

34 

27 

8 

- 

9 

26 

4 

106 

35 

- 

35 

26 

10 

- 

12 

25 

5 

96 

36 

- 

36 

25 

13 

- 

14 

24 

6 

89 

37 

- 

37 

24 

15 

- 

16 

23 

7 

83 

38 

- 

39 

23 

17 

- 

19 

22 

8 

77 

40 

- 

40 

22 

20 

- 

21 

21 

9 

73 

41 

- 

42 

21 

22 

- 

24 

20 

10 

69 

43 

- 

44 

20 

25 

- 

27 

19 

11 

65 

45 

- 

45 

19 

28 

- 

30 

18 

12 

62 

46 

- 

47 

18 

31 

- 

33 

17 

13 

59 

48 

- 

50 

17 

34 

- 

36 

16 

H 

56 

51 

- 

52 

16 

37 

- 

40 

15 

15 

53 

53 

- 

54 

15 

41 

- 

43 

14 

16 

51 

55 

- 

57 

14 

44 

- 

47 

13 

17 

49 

58 

- 

60 

13 

48 

- 

51 

12 

18 

47 

61 

- 

63 

12 

52 

- 

56 

11 

19 

45 

64 

- 

66 

11 

57 

- 

61 

10 

20 

43 

67 

- 

70 

10 

62 

- 

66 

9 

21 

42 

71 

- 

75 

9 

67 

- 

72 

8 

22 

40 

76 

- 

79 

8 

73 

- 

79 

7 

23 

39 

80 

- 

85 

7 

80 

- 

86 

6 

24 

37 

86 

- 

92 

6 

87 

- 

96 

5 

25 

36 

93 

- 

100 

5 

97 

- 

107 

4 

26 

35 

101 

- 

111 

4 

108 

- 

122 

3 

27 

33 

112 

- 

125 

3 

123 

- 

145 

2 

28 

32 

126 

- 

146 

2 

146 

- 

193 

1 

29 

31 

147 

- 

194 

1 

Above 

194 

0 

30 

30 

Above 

194 

0 


USING THESE TABLES: A “Sum Factor,” “S” and a 
“Difference Factor,” “D” are defined by the equations: 

A = Two-log(X) 

B = Two-log(Y) where A > B. 

S = Two-log(X+Y) - A 
D = A - Two-log(X-Y) 

With these definitions the Two-log of X+Y = A+S and the 
Two-log of X-Y = A-S. To find the Two-log of X+Y, subtract 
B from A, find the value of S in Table II which corresponds to 
this difference, and add it to A. Similarly, to find the Two-log 
of X-Y, subtract B from A, find the corresponding value of D 
in Table III (if A-B < 30) or Table IV (if A- B > 30), and sub¬ 
tract D from A. 

Examples: Some examples will show how this works out. 
Suppose X = 1.479 X 10 12 and Y = 0.602 X 10 12 then 
A = 1217, B = 1178, and A-B = 39. Since 39 is between 37 


and 40, Table II shows that, in this case, S = 15, so Two- 
log(X+Y) = A+S = 1217 + 15 = 1232. Since A-B > 30, D is 
found in Table IV, and equals 23. Thus Two-log(X-Y) = A-D 
= 1217 - 23 = 1194. As a check add X and Y: 1.479 X 10 12 + 
0.602 X 10 12 = 2.081 X 10 12 , which has the log 12.32 and 
the Two-log 1232. Similarly X-Y = 0.877 X 10 12 with the log 
11.94, and the Two-log 1194, which results agree with those 
obtained using the tables. 

As a second example let A = -328 and B = -354 (-328 > 
-354), A-B = 26. From Table II: D = 19, so Two-log(X+Y) = 
-328 + 19 = -309. From Table III: D = 35, so Two-log(X-Y) 
= -363. Checking this: X= 0.0005248, Y = 0.0002884, X+Y = 
0.0008132 with the Two-log -309, and X-Y = 0.0002364 
with the Two-log -363. 

These examples clearly show the disadvantage of N-logs, 
i.e., that addition and subtraction are more difficult when 
using them, so that they would not be useful in contexts, as 
in accounting, where these operations predominate. However, 


Page 8 

404 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 




in most scientific calculations their advantages outweigh this 
disadvantage. 1217 is easier to write and to pronounce than is 
1.479 X 10 12 . To find the Two-log corresponding to 1.279 X 
10 12 X 0.602 X 10 12 , 1217 is added to 1178, giving 2395. 
The Two-log of 0.0008132 8 is 8 X -309 = -2472 and so on. 

CAN LOGARITHMS BE USED TO REPRESENT NEGA¬ 
TIVE NUMBERS?: When it is proposed that N-logs be used 
to represent all of the numbers in a series of calculations, an 
objection that will immediately be raised by anyone familiar 
with logarithms is the fact that, since there is no power to 
which a base can be raised that gives a negative result, it is im¬ 
possible to take the logarithm of a negative number. While this 
is certainly true it does not interfere with the use of logarithms 
to represent negative numbers. Consider several comparable 
situations. The simplest relates to the fact that decimal digits 
alone cannot represent a negative number. Any group of sym¬ 
bols including only 012345678 and 9 will be interpreted as 
a positive integer! Mathematical tradition, to get around this, 
provides for the representation of negative numbers by the use 
of an eleventh symbol, the minus sign. What’s sauce for the 
goose is sauce for the gander! If extra symbols are allowed, 
they can be used with logarithms just as well as with ordinary 
numbers. Since the minus sign is already used to show whether 
the logarithm is positive or negative, some other symbol, for 
example the letter N, must be chosen to indicate that the 
number represented by the logarithm is negative. Thus, since 
the Three-log of 5678 is written 3754, the symbol for the 
Three-log of-5678 could be written 3754N. The Three-log of 
-0.3492 could be written -2457N, and so on. Of course the N 
would have to be taken into account when using the S or D 
routines described in the preceding section. 

Another situation, very familiar to computer experts, 
relates to the fact that any combination of the binary digits 
0 and 1, taken as written, must be interpreted as a positive 
integer. To get around this it is common practice in designing 
and programming binary computers to represent a negative 
number as the two’s complement of the corresponding positive 
number. Thus the decimal number +55 would be represented 
in binary by the symbol 110111, while -55 would be 001001. 
This way of symbolizing negative numbers has two advantages. 
Not only does it change them into a form the computer can 
handle, it provides the added advantage that, within the com¬ 
puter, the addition of the binary number representing a posi¬ 
tive quantity to that representing a negative one will give a re¬ 
sult which is the difference of the two quantities (if the over¬ 
flow is neglected). This basic idea can be applied to N-logs, 
as will be demonstrated in the next section. 

N-LOGS FOR COMPUTERS: While there are many possi¬ 
ble ways in which a number language for computers could be 
built around the N-log concept, one particular way of doing 
this seems like a good one. It begins by assuming a 16-bit bi¬ 
nary word. This means that the largest number that can be re¬ 
presented is FFFF (Hex). Thus, including 0 there are 10000 
(Hex), or 65536 (Decimal) possible numbers. There are four 
possible kinds of N-logs to be represented; i.e., the + N-log 
(i.e., positive N-log) of a + number; the - N-log (i.e., negative 
N-log) of a + number; the + N-log of a - number; and the 
- N-log of a - number. This means that the total number of 
symbols allowable must be divided by four to find the largest 
N-log that can be represented. 65536 divided by 4 is 16384 
(Dec.) (= 4000 Hex)). If Three-logs were used this means that 
the range of numbers that could be handled would be the ones 
whose Three-logs extended from -16384 to +16384, i.e., the 
numbers between 4.130 X 10~ 17 and 2.4210 X 10~ 16 . The 
precision of all numbers would be that characteristic of Three- 
logs, i.e., plus or minus 0.115%. This range of numbers and 
this degree of precision is adequate for most scientific calcula¬ 
tions, so this approach seems to have practical appeal. 


A SPECIFIC PROPOSAL: One way to implement this idea 
would be to select the lowest group available in a 16-bit word 
(i.e., the numbers from 0000 to 3FFF (Hex)) to represent the 
positive Three-logs of positive numbers. The two’s comple¬ 
ments of these (i.e., the numbers from FFFF down to C001 
(Hex)) would then logically represent negative Three-logs 
of positive numbers. Adding 4000 (Hex) to the lowest group 
would set aside the numbers between 4000 and 7FFF (Hex) 
to represent positive Three-logs of negative numbers, and their 
two’s complements, the numbers from C000 down to 8001 
(Hex), to represent the negative Three-logs of negative num¬ 
bers. Such an approach would provide a simple way of arriving 
at the initial Three-log, by the use of a scientific calculator, 
simple algorithms within the computer for converting these 
input numbers to the corresponding binary numbers, and ex¬ 
treme simplification of the operations of multiplying, dividing, 
powers and roots by the computer. Operations corresponding 
to the addition or subtraction of the original numbers, or the 
intermediate results, would be a little more complicated, re¬ 
quiring look-up tables for S and D, but would be perfectly 
feasible and quite fast. 

CONCLUSION — A PERSONAL NOTE: It must be obvious 
to anyone who reads through this paper that the missing step 
is the creation of a program, which must be in machine lan¬ 
guage to be effective, demonstrating how well these ideas 
work. I have not attempted this for a very good reason. I have 
been trying for somewhat more than ten years to get across 
the (to me) obvious advantages of a wider use of logarithms, 
and am fully conversant with the mathematical side of the 
story. My acquaintance with computers, on the other hand, is 
limited to building my Digital Group unit, using it extensively 
for computing, preparation of text (including the manuscript 
for this paper) and plotting. All of this has been programmed 
in Basic. Up to now I have not found the time to get into ma¬ 
chine language programming. In short, if the subject matter of 
this paper is to be proved properly, I need help. If any reader 
with the appropriate skill finds the subject appealing, I would 
be most anxious to work jointly on proving these ideas. The 
fundamental concept of N-logs is sound, and there is no 
doubt in my mind that they will make a valuable addition to 
computer techniques, but this needs to be proved. □ 


APPENDIX I 

The Mathematical Basis for the Sum and Difference Factors 

Note: In what follows it is assumed that X>Y. Antilog(a) is 
used to mean the result of raising the logarithmic base to the 
power “a”, i.e., the inverse operation to log(a). 

Let: A=log(X) B=log(Y) and C=A-B 

Then: antilog(C)=X/Y 

Let: H=Y/X=antilog(B-A)=antilog(-C) 

The Development of the Sum Factor "S": 

log(X-Y)=log[X(l-Y/X)]=log(X)+log(l-Y/X) 
Let: S=log(l+Y/X)=log(l+H) 

Then: log(X+Y)=A+S 

The Development of the Difference Factor "D": 

log(X+Y)=log[X(l+Y/X)]=log(X)+log(l+Y/X) 
Let: D=-log(l-Y/X)=-log(l-H) 

Then: log(X-Y)=A-D 

(continued on page 36) 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 9 

405 



$$$$$$$$$$ 


MS UEEHS 

SraSLBT 



asp/m 

gama masltiis pgiam 

using 

Flaaftiurifar I graphics 


Page 10 

406 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 


iiiiiimiiminmiiM (iimiiiiiiim' 















© by David W. Friedman 

Eiko and I were spending the year-end holidays quietly 
at home with my word-processing-oriented North Star 
patiently waiting for the next major copywriting assignment 
which is how I earn our keep. We had been recounting the fun 
of playing the slot machines in Macau and the Philippines 
when she challenged me to put the game up on the computer. 
I agreed on the condition that she help with the graphics and 
off we went. 


VIDEO BIT DIAGRAM 

fiIIS;yiD+4ppH yiD 

76543210 76543210 

1111 xxxx xxxxxxxx 

• • • !_pix»ls on/off ! S S__graphics pixel bits 

• _horizontal I I_non-graphic bit <40H 

!thin lines I_reverse video bit 

8 !_vertical 

!_half-intensity shading 


THE HARDWARE 


A North Star Horizon II double-density system with 56K 
of RAM, a Vector Graphics Flashwriter I video board at EOOO, 
a 12V TV converted to a monitor and an 80-column friction- 
feed Teletype 43. Other video boards may have the same or 
similar graphics provisions but I know of at least two which 
don’t, so you’ll have to check carefully or else rewrite the 
graphics routines to match what you have. 

THE SOFTWARE 


The designation of each bit is shown. Note that bit 6 
(40H) of the video byte is undefined in the graphics mode; 
this bit has two graphics coding uses in the VEGAS program. 
The attribute bytes are actually equipped with RAM only 
for the lower nibble such that, for normal alphanumeric 
character usages, reading this memory will give an FO hex 
byte. This is slightly inefficient usage of address space but, for 
an 8-bit microprocessor, yields efficient access to the remain¬ 
ing four attribute bits. 


Las Vegas Super-Slot is programmed as a standard CP/M 
transient at 1OOH and requires CP/M both for loading and for 
internal file manipulations as well as input/output standardiza¬ 
tion. I have been running VEGAS.COM using a modified 
version of the MENU.COM program by James Frantz which 
appeared in Creative Computing’s December 1979 issue. 
On both cold and warm starts, MENU is invoked so the user 
need only type a 2-digit number to access VEGAS. 

THE GRAPHICS 

Flashwriter I is an excellent video board for alphanumerics 
with limited graphic capabilities. Characters can be displayed 
as 16 lines of 64 characters per line. The graphics capability 
can be invoked randomly for any desired character positions 
which further subdivides each character location into a 3 
high by 2 wide pixel (picture element) array. This yields an 
overall resolution of 128 pixels horizontally by 48 pixels 
vertically. 

There are also four other graphics features each controlled 
by an isolated bit: reverse video, low intensity video, horizon¬ 
tal thin lines and vertical thin lines. Access to the twelve video 
bits for each character position is segregated into two memory 
areas which can be called video and attributes (VID and 
ATTB) such that each character-position’s attributes are 
always exactly four RAM pages above the corresponding video 
byte. For example, if the board is located at EOOOH, the first 
character position’s video byte will be at EOOOH while the 
four excess attribute bits will be located in the byte at E400H. 

David W. Friedman -2 -8-24 Okubo, Shinjuku-Ku, Tokyo, 
Japan 160 


USING THE GRAPHICS 

VEGAS begins by setting its own stack pointer, thus 
discarding the entry stack pointer, and calling the routine 
INITIZ which handles all necessary initialization, including 
graphics. VEGAS provides the user with a 3-reel/3-position 
down-rotating-reel presentation of a slot-machine plus a 
moving crank arm at the right and various status displays 
including winning combinations, current credits, current 
winning amount, current jackpot amount, ready indicator 
and others depending upon the current operating mode: 
TEST, PLAY, ZERO or READY. The initialization of the 
graphics functions is in the following order: 

+ ERASE the screen to all spaces, 20H 
+ apply the PAY OFF strings at top and bottom 
+ apply left WIN and right CREDIT boxes 
+ apply shading to top and bottom reel positions 
+ apply graphics bits and REEL boxes at three positions 
+ apply TICKS at centers of boxes 
+ apply initial reel patterns using SPIN subroutine 
+ apply operating arm using CRANK subroutine 
+ show JACKPOT amount retrieved from separate file 
or create file and load it with 100 credits 

There are several very generalized routines used to accom¬ 
plish the above and usage of these is described here: 

+ at entry, the B/C register must contain: either BLKOFF 
=0 or BLKON=8080H plus 100H times the vertical 
height (to B) plus the horizontal width (to C) defining 
an area. 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 11 


407 


Number 50 






























+ at entry, the H/L register must contain: the beginning 
character position byte which is: either VID or ATTB 
plus the vertical line (0 to 15) times the linelength 
(LNLGTH=64) plus the horizontal character position 
(0 to 63). 

+ BOXY requires at ATTB address in H/L to apply or 
remove a rectangular box dimensioned by B/C. Exceed¬ 
ing right or bottom limits does not wrap around nor 
write into non-graphic RAM addresses. BOXY uses 
the GRAPH and GPHRHZ routines and may be used 
for zero width or height boxes (lines only) although 
VEGAS does not contain such usages. 

+ GRAPH requires an ATTB address in H/L and the bit 
of interest in the A register to apply or remove that bit 
from the rectangular area defined by B/C. GRAPH 
uses the GRAPHER routine. 

+ GRAPHON is the same as GRAPH with A being set by 
the routine to the graphics bit, 0001B. 

+ GRAPHER applies bits to one horizontal line at a time 

+ GPHRHZ is the same as GRAPHER with A being set 
by the routine to the horizontal line bit, 0010B. 

In addition to these generalized routines, two specialized 
routines are used: 

+ CRANK which calls HANDON and HANDOF both of 
which call the generalized BOXY routines. 

+ MVPTN2 which requires the area to be specified in 
B/C and the upper-left byte to be specified in H/L. 
MVPTN is set for areas 10 characters wide by 12 high 
and thus moves 120 bytes to the block of video memory 
specified. 

These routines provide access to every graphics capability 
of the Flashwriter I video board and are readily applicable 
to use within other, unrelated programs. 

FORMING THE GRAPHIC PATTERNS 


REEL GRAPHICS PATTERN CREATION FORM 



L-I-i_I_J._l_l_I_.i-i 

i i i i i i : i i i 
j._I_i_I_i_l_i_l_l_i 

L_I_i_I_i_I_i_I_i_I 
iiiiiiiiiiii 
-i_I-i-I_i_I_i_i_i_I_i_I 
11111111:1:1 
_i_I_i_l_i_I_i_I_i_I_i_l 


o\o\22 jjw \o\o[ 
.2 \ 3 t\ 20 \ o\o\0\ 




O 1 0 1 0 1 


20 


i 

« I 
1 


10 

! 

» 

I 

2 I 


A- 

_i 

8 

l 

! 

I 

1 I 

____ 

.!_ 

_i 


Having settled upon the graphic presentation desired, it is 
only necessary to code the individual bytes by referring to 
the form’s coding diagram wherein each pixel’s bit value is 
given in hexadecimal; adding gives the byte value. VEGAS 
uses 3FH for all white pixels within a character position 
rather than the optional reverse video function 8 OH. Bit 6 
which has value 40H is reserved for identification coding of 
the patterns and is added to the first four bytes of the pattern 
for this purpose. In this way, the final pattern’s code can be 
read out of the video memory after the reels have stopped. 


As an aid to rapid creation of the reel-graphics, the form 
shown was very efficient. It incorporates a pixel aspect ratio 
of 1.7:1 compared with about 2:1 actually obtained (depend¬ 
ing upon monitor adjustment) such that penciling-in the de¬ 
sired blocks yields a very slightly squat but proportional black 
on white representation of what the final pixel pattern will 
look like when shown on the video screen. However, it was 
found that short video display routine to test the final ap¬ 
pearance was essential to finalize the individual patterns. 



THE MAIN PROGRAM 

After “READY” is shown, the KEYTEST routine looks for 
any keypress while incrementing the B/C register. When a 
keypress is obtained, C is saved as a RANDOM number before 
returning. The key is read to register A and tested against 
‘$’ (credit entry) and the first letter of the four keywords 
EXIT, TEST, ZERO and PLAY before testing for a CR. Any 
of these routines, if called, will return with a CR in A if the 
call was inappropriate, thus executing an ACCEPT/OPERATE 
cycle. Keywords are control key oriented by ANDing each 
reference string letter with CTRL=1FH and represent pass¬ 
words to be known only to the user and not to the players. 

+ ‘S’ issues credits only if no credits remain. If credit is 
issued, the jackpot is increased by about 15% of the 
credited amount up to a maximum of 15 jackpot credits 
while receipts are increased by the full credited amount. 

+ EXIT erases the entire video memory and saves the 
jackpot and receipts before branching to a CP/M warm 
start. 

+ TEST applies 100 credits and automatically runs the 
game until credits reach 0 or until the CR key is pressed. 
Jackpots are not paid in TEST and it returns with 
credits set to 0 in either case and can be used to cancel 
a winning player’s credits. 

+ ZERO sets receipts accumulated from ‘S’ collections 
to 0, shows 0 receipts, saves the jackpot and receipts 
and, upon pressing the CR key, restores the READY 
condition. This feature allows the user to leave a player 
in charge with means to check the receipts when he 
later returns. (continued on page 14) 


Page 12 

408 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 




















+ PLAY shows current receipts from "$’ collections, 
saves the receipts and jackpot and, upon pressing the 
CR key, restores a READY condition without having 
affected the current credits. 

ACCEPT checks to make sure credits are available before 
permitting OPERATE to be called. If credit is available, the 
READY sign is removed and OPERATE is called. If OPER¬ 
ATE returns with the carry set, the jackpot is paid out and a 
zeroed jackpot is saved to disk. All internal branches are back 
to MAIN which restores the READY mode. 

THE OPERATE ROUTINE 

One credit is CHARGEd for each play, the winning value 
is zeroed, the arm is CRANKed with sound effects, SPEED 
sets maximum reel running times based on the RANDOM 
number generated during KEYTEST, the reels are spun with 
stopping sound effects and options for individual reel—stop¬ 
ping control using keys ‘1’, ‘2’ and ‘3’, a WINCHeck is per¬ 
formed which increases the jackpot for certain high payoff 
combinations, the winning amount is shown and, if not zero, is 
CREDitedOUT through one-by-one adding to the credits 
with sound effects. CREDOUT returns with the carry set if the 
win was three bars in order to pay out the jackpot. 



THE SPIN ROUTINE 


Here, speed of ‘rotation’ is very important. The use of a 
fast pattern stuffing routine and video pattern internal indenti- 
fication coding were necessary to obtain sufficient speed 
even with the North Star’s 4MHz Z-80, although no attempt 
was made to use any of the special Z-80 move instructions 
since these are not compatible with CP/M’s assembler. If run¬ 
ning on a 2 MHz 8080A, this routine’s code can be expanded 
to eliminate internal subroutine calls which will help some¬ 
what. 

Initial entry is at SPIN 1 with 12 in the A register to insure 
the movement of at least 3 patterns before STOP-KEY check¬ 
ing. SPINCouNT and each of the REELnS global variables 
must be maintained at multiples of 4 to keep the patterns 
centered on the TICKS at the middle position of each reel. 
SPEED presets the globals prior to SPIN entry and multiples 
of 4 pattern movements insure synchronization. 

If any reel is stopped while others continue to spin, the 
extra time must be taken up to avoid speed increases of the 
remaining spinning reels and this is the function of the calls 
to TIMER 1 in the SPINER routine. The last 16 counts of the 
REELnS globals are sub-divided into four sets of which three 
invoke TIMER 1 to fill time and one outputs a space to the 
printer for sound effects in addition to advancing the pattern 
by 1/4 which gives the slowing-stop with sound effects. The 
pattern for the CHERRY has non-graphic 40H start byte and 
signals the RESETP section of SPINER’s code to reset the 
pattern to CHERRYY in order to close the pattern loop 
similarly to what would exist on an actual slot machine reel. 

STOPCMP checks the REELnS globals for the required all¬ 
zero stopped return condition. STOPKEY checks for a key- 

Page 14 


press of ‘1’, ‘2’ or ‘3’ and adjusts the respective REELnS 
global variable to bring about a stop with slowing and with 
‘slip’ determined both by the reel number and the RANDOM 
number generated at the start of each cycle by MAIN’s 
KEYTEST. Multiples of 4 must be maintained and register 
A is set to 8 to introduce a minimum time interval between 
acceptance of STOPKEY presses prior to jumping back to 
SPIN 1. 

THE WINCHECK ROUTINE 

WINCHK ‘reaches’ into the video memory and extracts 
the 2nd through the 4th byte’s 40H bit identification codes 
with BYTINA. The 3 reel’s bytes are stored in E, D and A 
respectively. Comparisons and BAR substitutions are used 
to determine winning combinations with winning values 
taken from the PAYTaBLe. The winning amount is saved as 
the VALUE global and, depending upon the amount, an ad¬ 
dition is made to the jackpot. 

BIOS AND BDOS CALLS 

All BIOS console calls and printer calls are made directly 
to the BIOS branching table whose high byte is obtained 
from the warm start address stored in the jump at OH. Disk 
operations to create and manipulate the incidental jackpots.lot 
file, use the normal BDOS calling convehtions except, upon 
return from every BDOS call, a dental jackpots.lot file, use the 
normal BDOS calling conventions except, upon return from 
every BDOS call, a check is made to see if an error occurred. 
In case of a BDOS error, the graphics initialization is destroyed 
so an error message is shown indicating return to CP/M via a 
warm start. 

SHOWING STRINGS, NUMBERS AND MATCHING 
KEYWORDS 

All strings are terminated with nulls. The SHOSIG routines 
detects the null for return after advancing the D/E string 
pointer so that a subsequent call can be made to show another 
string following the null without resetting the pointer. Reverse 
video is built-into the strings for READY and JACKPOT. 

All changing numbers are shown as 5-digit integers using 
SH05DIG which can suppress leading zeros if entered with 
b = 0. Leading zeros are suppressed for WINS but are retained 
for all other changing numbers. 

All MATCH strings are ANDed with CTRL=1FH to 
invoke the need of pressing the CTRL key with all of the key¬ 
word letters and, each string is terminated with a null. The 
MATCH routine returns with the zero flag set if successful 
or not set if there was no MATCH. 

LISTING AND AVAILABILITY OF DISKS 

The complete CP/M assembly listing follows except for the 
data bytes representing the reel patterns which are printed as 
a memory dump using CP/M’s DDT in order to save printing 
space. If you’d like to save yourself the typing time and associ¬ 
ated errors, I can make the VEGAS.ASM and VEGAS.COM 
files available but only on North Star 10-hard-sectored 
disks for $50 and, I’ll assemble VEGAS.COM to your selected 
video location of the Flashwriter I board if you mention it. 

CONCERNING WINNING STATISTICS 

If one discounts the effect of using the three number keys 
(1,2 and 3) to control the stopping of the reels, the ‘payback’ 
expectations are as summarized here. However, it is possible 
to ‘help’ things along by using these 3 keys. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

409 




EXPECTATION TABLE 


ITEM 

1 

COMB. 

PAY 

EXP. 

JBONUS 

JKPOT 

BARS 

2 

8 

250+J 

2000 

0 

0 

MELONS 

2 

24 

100 

2400 

13 

312 

DOLLARS 

2 

2-4 

50 

1200 

7 

148 

BELLS 

A 

112 

20 

2240 

3 

334 

PLUMS 

4 

1 1 2 

14 

1548 

2 

224 

ORANGES 

5 

1 85 

10 

1850 

0 

0 

CHERRIES 

3 

57 

10 

570 

0 

0 

first 2 


207 

5 

1 035 

0 

0 

first 1 


1 380 

2 

2740 

0 

0 

LEMONS 

5 

1 85 

0 

0 

1 

1 85 

CHARGES 

0 

< 1 46) 

0 

0 

3 438 

STOTAL 

27 

2294 

- - 

1 5423 

— 

1443 

NO UINS 

— 

17389 

0 

0 


1 

• 

JACKPOTS 


< 8) 

208 

1444 


1 

_1 

TOTALS 

27 

1 9683 

— 

17287 




1 7287 





PAY BACK= 



87.8 

percent 




19483 

(skill not 

c onsidered> 


While our experience has shown that practice time tends to 
yield a higher percentage of bigger wins, at the same time the 
number of credits required to obtain these wins increases! This 
is caused by the player trying to lineup the reels, as they fly 
by, using readily recognizable patterns such as bars and dollar 
signs but, because of the reel ‘slip’ factor introduced by 
STOPKEY as a function of the RANDOM number, he is 
generally one pattern away from success. Not wanting to dis¬ 
turb his progress in hand, the player keeps trying to adjust 
for the single offset of the patterns and is thus, barring good 
luck, more often than not defeated. It would be blatantly 
untruthful to claim that this was not a planned perversity of 
the VEGAS game machine. 

In view of the above, it can be said that there is the pos¬ 
sibility of skillful manipulation of the game but, just as in 
real life, the most skillful approach may not yield the most 
profitable result. Eiko and I do hope you will enjoy playing 
the LAS VEGAS SUPER-SLOT game machine as much as we 
do. □ 


REEL GRAPHICS PATTERN CREATION FORM 



_ 

{ 0 * l*A-? l-° i ] 20 1 4 I 


2 a I o j / I I 

3 / I 0 I j, 1 
* 0 1 V 1 ?2 l 


'?A±l*l?A*fAPlf 5 1 io ! 2 1 
£AlA?sAi??A^AiiiAL 0 A i—i —\ 

/? *36 1 3V 1 2 J S 1 20 1 0 1 0 1 1 8 ! 11 

i_i_i 


REEL GRAPHICS PATTERN CREATION FORM 


i i i i i : i i : i i 

t I 1 1 ! I ! I I 


I I I I 1 I I I I 




4IIIIIIIIIIIXIIIXIIII 
4Sl!i:llIIIIIII!l!I!I 

lA ’i 1 1 ? ]F] 

\7 \ 2 \ n \it \i s \is \3 8\l2 j ? \3g[ 

3 7 \ l \30 \38\IB 1 />" [38 ]33 \2f { 

i^Ai^Ai^Ai 2 yl 2 fi 2 ^l 2 A 2 ^Ai z ^A 2 °i I 8 ! ' I 


REEL GRAPHICS PATTERN CREATION FORM 

i_I_l_I_i_I_i_I_i_I_i_I_i_I_i_I_i_l_i_I 
tltllllllltXIIlItltl 
i-I_i_I_i_I_i_l-i_l_J._I_i_I_i_I_i_I_i_l 
i i : i : i i i : i ; i : i ! i : i : i 
i_J_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_l_i_i 
\~i ~: 'ri 'Tr'ri'rrrrri 
i_2_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I 
: i : i : i ; i : i : i : i : i : i : i 
i_I_i_I_i_I_i_I_l_I_i._I_i_I_i_I_i_I_i_I 
: i : i : I t i : i : i : i ; i : i : i 
i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I 
I ~i~ i~i~i i-i-ir'l 

i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I 
: i : i : i : i : i : i : i : i : i : i 

i_I_i_I_i_2_i_I_i_I_i_I_i_I_i_l_i_I_i_i 

siiiii!i!i:iii:x:i:i 

i_I_i-I_i_I_i_I_i_l_i_I_i_I_i_I_i_I_i_I 

i"i":-I•'i •'i*' i~i~i "i"! 

i_I_i_I_i_I_i_I_i_i_i_I_i_I_i_I_i_I_i_I 

si:iix!i!i:x:i:xtx:i 

i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I_i_I 

i i : i : I : i : i : i : i : i : i : i 

i-I_i.I_i_I_i_I_i_I_i_I_i_I_J._i_i_I.i_i _ 


1 

i 

I 

I__ 

I 

I 

I 

I 

-I 

I 

I__ 

M M 

I 

I 

I 

-I- 

i 

I 

i 

I_ 

20 : 

i 

4 I 

__ I 

2 

I 

I 

I 

I 

I 

I 

i 

I 

I 

i 

i 

t 

I 

2 

i 

i 

I 

I 

I 

I 

i 

I 

I 

i 

i 

i o : 

2 I 

3 

I 

I 

I 

I 

I 

I 

I 

I 

I 

i 

j. 

i 

i 

i . 

1 

i 

I 

I 

I 

I 

i 


1 

I 

i 

j 

I 

4 

I 

I 

I 

I 

I 

I 

i 

I 

I 

i 

i 

8 ! 

1 I 

4_. 










—i 

j. 

_i_ 

_i 


•>s* 


listing. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

410 


Page 15 





























































Q tN -O CN *C CM *- »- *— «— *- IV CM -O-OO IO Q 

O O © © © © © © © © OOOOOOOOO O o o o o o © 

rv cn rx-00''*-nir>in'*-<x<i«OQQ'0«'0 — N'OO'O o o o q >000 o* — 

m cm mujNNu.o^*->r.Q^iiioo»oinino-o o o .- © o © o n >0 

— Q QQQUIUUUIllUUUUUUNQ«OQNQQn — Q U O Q Q n Qu.CN 

HltHUliniHU U D M II N II H II H II N H H H H WO UUUU.UU.UU.UU.UU.UU.UUUUUQUU O CN (J M (J U U U U « « 

© ooo'fffloooo omuoou.orotin'o u. q o n on •o(MJU.«-f'Oi>'»ujoioina)«Qon' 09 -uu. cn 10 to a a uj - t k <x a 

o ou ouuit'-00 ©omoDoo — — *-000 00 o©©©*-«-«-»- — *-CNCNCNCNCNCNnnnnnn «r n- 11 T t in n in in in 

*- OOOOOOOOO ooooooooooo 0000 *- — ^ ^ ^ r- «- «- »- 

O UiOUiOOOOOOO OOOOOOOOOOO OOOO OO OOOOOOOOOOOOOOOOOOOOOOO OOOOOOO 000 


Page 16 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

411 











QQaminnMoci •€ <r n o -o - q ui -o cn 

OOOOOOOOO OOOUJOUJO o o o 

-r)0'«ro>u^K u.innoai*)N^ifi n >o 

>0'0'0r\'0QU'0'0 rvca*-omo>oocD rx ui 


NNNQQQN^N QQ-r-Q^t^n Q Pv PO <X O' 

CNCNCNCJCJOU.CNCN gU*-NU-(MOU U « O U N 

>-TN<IQOr)'00 ULLtNinCDOiUJ-M -O O' <r A UJ 

05000505050000 OOQaQQflUlU UJ UJ Ui UJ llJ 

CNCNCNCNCNCNCNCNCN (NN(M(NNNfM(NN CN CM CN CN CN 

OOOOOOOOO OOOOOOOOO ooooo 


i=j po o C 5 a q If) m o u. roooo 

O O O O OO O o ou. oooo 

in a a *r o- o n m q m ix >o rx r-v ro <x 

O O »- -0 ■O'OOin PO <0 b. ^'O'OO 

CN O' QUJO — <XO'CN<tO'W — ArO « — O CN CN <X — 

PO U OMOt-N»-(MtM«-(JQNO CN •— >- Q CN CN »- 

U. CN PO'OOOO-UU.OrO'OCBAOA O M O N 4 o o 

UJ U. U.U.U.U.U.U.OOOOOOO CN 

CN CN NCNNC'JNCNMMrtMwnn M M M rt M M M 

OO OOOOOOOOOQOOO ooooooo 


in cn rx CM >© -o >o >o n- •o to o CM a *r po 

O O O UJ OOOOO OOOO O UJ o 

ooroO o f iMMn oooo- w rx u. 

in o - O in co co cd q m *- o cj >o a cn 

CKDQr--mQQQDa^an^M <x c_» m o- —mo 

-UU-riUlUUUUUUJUUINU M MB U CN UI o 

n»N<IQO*-^N«QOr-^N« OOr-CN W >0 Ps 

NCMNNNP)MP)PmM»^Vf^ in in m in m m 
nnwnMMMpnroionwMMnrt ro ro ro ro ro ro ro 

oooooooooooooooo oooo ooo 



-o-o cn in >© cn •ooN'OP)'D«rinpDin 

OO OO o O OUJOOUJOCOLlIOUJ 

> 00-000 O' -O > 00^-0000000 

onoo-o r\ — -oocoincoinajaDco® 

Q Q UJ (N ro Qujpoolumcno- a~-*-o*-a*-*-a*- 

OOU.OO CJACNOP-AUU ucn*-cjcncjocnucn 

go o uj o ro -CD-CfflUQUJr- rjinco«ui-<rr, 4a 

OOO.-*- CN CNCNCNCNCNPOrOPOPOPO 

CN CN (N CN (N CM CN CN CN CN CN CN CN CNCNCNCNCNCNfNCNCNCN 

OOOOO QOOOOOOO oooooooooo 


po*r>o ro *r po o po poo ro po po po >o po 

O CD UJ O UJ O GOO OO O O O O UJ O 

u <r u co in o m in <x ro o o in ro o in po o u cn 

CO <r CD O 05 03 05 UJ GO 05 GO O UJ A GO UJ A CO O O 

Q--UJQ-mQ--r-ar-Q^ 9 .Qr-Qa.Q^a-- 
CJOCMP'JCJCNUJCJUJOCJUJU — *-UUJC_J*-C_)UJOCNO 

OPD-OCPAUJ^ninP-CQUJ-'r'DO-iIQU.CNPMIO 

«pT>fvfTininininininin' 0 - 0 'fl> 0 ' 0 -o>oNN\N 

CNCNCNfNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCNCN 

oooooooooooooooooooooooo 


CNCDQAQCOOAA^-pOO 
0000000^00000 
0> O' UU.U.NQltlSOOO'MOO 

o *- rxoinom«in.-mm.-uoo 

m O' -o P P-OU.O''ON^IOCNr-CN»-(N*-tN*-CJC'IQQ*- 
UJ f-\ A P- MJ>CN»NUJOUNCNCN(NlNNCNNCNUU(N 

UQUJU o*-n»in>OM>‘<iooi*)' 00 'Uu.cNincoisiij 
Ps rx rx p- oocDaocooDcocooocoaoO'0'0-o-0'C>'<x:<r<x<x<r 

CN CN CN P. (NCNCNCNCNC-JCNCNCNCNCNCNCNCNCNCNCNCNCNCNCN 
ooooooooooooooooooooooooo 


Number 50 

412 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia 


Page 17 





P 

J 


o 

I 

a. a 
P - 


2 


O CD 

4 


o 

m 

o x: 

CJ 



a 


A 

+ 


A 

P 

4" O 

X 

4 




C UJ 

4 


Ik 


P 


4 Z 


z 


X. 

4 


o 

O 

X z 

GO 

4- A 


UJ 


x >— 

4 


«* 

A 

CD <t 

X 

4 X 


X 

•— 

N X 

4 




Z oc 


h- 


H 


1 G 

4 


o 

0D 

<E v 


4 4- 



O 

z 



CL 

CJ 

P 

X 

4 <t 



H UJ 

O l£ 

4 






♦ p 


X 

►— 

Z 

♦ 


o 

O 

T- 

o 

4 \ 

CN 

C3 

r- > 


4 



CJ 

+ z 

X 

4 cn 

y— 


HI CO 

• CD 

4 


CD 

(D 

z «-« 


* X 

4 

-J 

CO 

CD <r 

+ 


UJ CN 

UJ ro 

o 

X 

4 Z 

X 

P 

H 

x x 



C3 _J 

C9 _J 

P u 

o 

4 HH 

K 


H x 

£C 

4 


Z UJ 

Z UJ 

z X 

z 

4 _J 

O 

u. 

UJ UJ 

X 

4 

Z P 

<t x CO 

^ uj a 

<Z Cl 

« 

+ 

X 

IH 

tn Z 

<r — 

♦ 

M O 

a: £C O 

oc P O 

P CD 

p 

4- O' 

Z 

• » 



4 

■-O 

■» •» o 

Ik >lO 



4 ■» 

X 




♦ 

cn o 

O 




4 

CD * 


IS 

J 


<1 

Z r : 


ui a o 

■ oc Z O 

-<r - 

' a a < . 


o I <1 

- O - 

» a <r _i -- z 


O 

p z 

* o 
<t u. 
p o a 


4 o- * 
4 * < 

■*■ <r « 


I :> 44 
I - a. 
: Q cn 


CM 

a. _! 0 . 
— uj CM 
X X -J 
uj p UJ 
Ui - UJ 
P P oc 


oc u_ 
X CM 

Z _i 


cn * 

PO rsi 

_i a. + 

uj m P 

Lli _i •— 

oc uj z> 

I k. jjJ » 

: P P a 


P P Z UW« 

ill ro CJ - Mi- 

z X z ZZ P X -J Z 

H UJ H O UJ UJ ►-* 

a. x Q_ o. cj h uj 'll u. 

cnpcn<Ecnp«cnpoei-i:n 


cm 

\ 

x 


P Z oc O 0 
cj <X - — - ►— 

a. oc a \ i!ii. 


>• 

X 

ft- z 

■ o - 

* H Cl 

: ui <X ui 


■ <x Z> 
i oc O 
: o * 


X ^ 5 OC Cl. 

Z O * o M CJ Z 

H t <1 £ m Q T 


Q >< >< QX+ A_JpA_JAA_Jp X A _J Q 

xZAZpr-ZAzPHZAZPOxacr- x 4 :> r-xxx^xxxX^xxxxsXXACJzCpzAXxPzuj^xx: 
jJX<t°tow:c<rQc/j„:*:<iCDxinQui p 4 z o)jjjuu)jjjuo)jjjui/)joiuo1jjoo")ii:ojj( 


. OC rN 
• N (J Z 
: a “) 


■oo>«auakiJO>-(Nn 

UUJUJUJUJUJLJU.U.U.U. 

MMMWMMMrOMnn 

ooooooooooo 


a Q a 

o o o 

co if) o o cd o cj o in o 

in "C r*) od — u o «- -o u. 

-«ujin'«(NMujif)-o(Nnujin-or\(N'Ort 
-(Nrocu.r-^nciL-^ncu.'OtNU.- 

•o > u uj u. - CNroin'OrnO'-acjAxorom 
U-XXXXOOOOOOOOOOO — «-«- 

ooooooooooooooooooo 


QQQO«faQQO'rQQQO<rQP to t q u 

OOOUIOOOOUJOOOOUJOOO oo ooo 

'TNQBffluii.a&'ao-u.acu.'Ou.u.N o- ro ro <x co 

o*nininaoooininmocominin<xcoinin «- rv -o in m — rv >o in ro o co ooo «- 

UJN*-«f-Q(\|^4^a(N'-<I^Q(N«a(MaNN««»inNO-Q4^'0-0«ar)'04QM 
MMON^UINON^UNOtN-UNMMUUaunPJiSftOUUN^OtNUM-tNOnU 


o a a t 

ooo o 

O-'OCD^O- 

n -o io n o co 


’ O O O O O ■ 


» o o o o < 


o o o o < 


> O O O O < 


♦ 

♦ X 

♦ o 


+ CD 
♦ 

♦ X 


« Z x X X 
H o ahocC 

H P UI =9 UJ O 

« z * o z z 

- « r-« p « <£ 

XXIXHOHXX 


♦ X -J X 

4 _l >- * _J 

+ at x cn at : 

♦ - O » - i 

4 a a a a a i 


4 o 

♦ o 
4 — 

♦ 4 
4 u. 
+ Ll 
4- O 

♦ X 



44 


X 


4 



4 


4 





♦ 


4 


CD 

CD 


p 


z 


4 

\ z 


4 


4 





4 - 


4 - 


<t 





44 

A 

+ 

z 



H 

4 - 





4 


4 


n 


z 

r— 


X 

X 


a x 

CD 

4 


4 



z 


4 - 

X 

4 



Z 


CD 



z 

4 

X P 


4 

P 

4 - 



H 


4 - 


4 - 


X 

X 


<r 


H 


4 

X 44 


4 


4 


P 

P 


4 

CD 

4 

oc. 


P 


X 


P 

X 

4 - 


z 

4 

cn 

+ 





4 - 


4 

O 

P 

oc 

X 



X 


4 


1-4 


o 



z 



+ 

X 

4 - 

z 


D 

— Z 

►— 



IN 

+ 

P - 

X 

♦ 

k-4 

4 



CD 


4 

z 

4 


X 

CJ 

X 44 

O 

P 


z 

4 - 

A 


4 

X 

4 

<X 

O 

<x 


4 - 


4 

o 

l— 



z 


r- 

p 

4 




X 

4 - 


z 

P 


4 

X 

4- 

z 

<x 

O 

X 


I X 

r 

4 

U X 

p 

4 

<r 

4 

X 




4 


4 


X 

P 


X 

cn 

X 




X 

4 

X 

4 

CD 


X 

P 

4- 

M 

4 


P 

X 

=t X 

ri D X 

« o 

4 



4- 

o 

4- 

A 

«—1 

l-H 

O 

4 

X 



CJ 

N 

a. 


X 


•-p 

4 



4 


4 

X 

• k 

■ k 

P 

4 


4 

■ k. 

• k. 







4 



4 


4 

z 

— 



4- 


4 

1- 




X -J _J _» _J _l 
’-'(rtja.jjjja. 
X3<To<r«<£<ro 
JiucL'Juuua. 


P 

4- J J- * _] 

: 4- a x cm P 

I ♦ *o * 

I 4 A A A P P 


—J *“• A *-! 

: + x <c X <r x 
+ j u j a J 


O 4 X M A 


4- X X X 
4 cn x cn 

4 A ft- 3 _ 

4 -ft.aa.^Aa.na.oa. 


co <r o < 

<r cj — u <x i 


o 4 — + P G h UJ Cl UJ x UJ -- 

0X4-04- -j xi Xiii ax z a 

- 0 . 4 O 4 -IZ Za-ZXii- *lL ll 

4 - MJfildinincIx X P « <1 u. 

- + o - -u a: 3 D oc G m p oc Q 

♦ iQ€!n(Da.£LCI4.Q«9 3aCa. 


4 <X 4 A <Z - 


<r o 
: r <t - 


4 - cn _i a. <1 a. ji JO.H- • 
4 - 3 «aa:No <io<:ouj ■ 
4-a.cja.ooa.cjCLCja.QC- 


A Z OC O O : 
r « o I t 


X X -I 4- 

cn >-< o i-t a,wJa.PSHufle(Lit-4H- 
AXOZMOA<XO<l 0 PZCJXOX 4 :> 
a.jr<xnu.a.ucLQ*;uTPiiii4-r 


j j >h r> « <£ o o <r 
OOXMOZXOOP 
xx<rocxua:zxa 


4 A 
4 - Z 
4 - <r 


♦ Ll. 
4 O 
4 A 


4 X 4 CL. 


4 4 CC-- 

4 N 4 UJ X 

4 X 4 X X 

4 X 4 X X 

4 X 4 <1 <X 

4 X 4 X X 

■- CD — CO CD 


o ro t o t m 

UJ o o o o o 

in x in uj in x 

IN «0 w CD A N 

— mAk-AAAA — 
CNUIULdUUCJCJUJ 

<TAX.-CNinC 0 AX 

inmuT'O'O-O'O'O'O 

MMMMMMMnM 

ooooooooo 


cn ro o x n 
moo mo 
m u o cn u 

CD GO CD GO CO 
— A — O* — ro 
OCJ-f ou 

x cn ft m th u 

•O N N N N N 

n w n mm n 


CN M O X 

OOO O 
03 CJ -O CN 

o m m o 

*- a «- O' — 

o u — »- o 

x cn in m o- 

in ao oo m CD 

M M W M M 


in r*j 
x o 
in o in 
x A CJ 


ro in ro ro »- 
o cj o o A 
m^mmo'- 

<£ X <Z CJ A X 


UOmD'OO'UX-fN 

cDO' 00 ' 0 ' 0 ' 0 ' 0 <i<r<r 

nnnnwnnnnnn 

ooooooooooo 


m o o a 

x «- >o X x ro 

ro <t x <r m cj 

m « a p x o 

« <L <X <X « A 

ro ro ro ro ro ro 

o o o o o o 


in o ro ro ro ro «- 

x o o o o o A 

m o L- in ui m a — min a — - 

Cj T OAXXACJ XA AO 

ft*-tD-o<x^nA-0'Uxmnro>-0' 
A — INXOXOOX»-NXAOCJXCJ 

inooAcjx — rouTco<iAcJX^CNinm 
AAAAAOOOOOOOOAAAA 
rororororororororororororororororo 
ooooooooooooooooo 


ACJQXO--CNrOTin 

AAAAXXXXXX 

rorororororororororo 

oooooooooo 


Page 18 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

413 







3 

•S 

C 

© 


rn 








“5 

+ 

o 


j 

+ 

N 


UJ 


>- 





+ 

(J 

cn 

+ 

♦ 

T— 


D 


(Z 




z 

♦ 



+ 




-J 


OC 

cn 



□ 

+ 

X 

M 


+ 



<r 


UJ 

UI 




♦ 

<1 

A 

♦ 

+ 

111 


3 


X 

X 



ro 

+ 

—J 


+ 

♦ 

X UJ 




CJ 

V 




+ 

L 

H 

♦ 


a cc 


z 



>- 




♦ 

0) 

cn 

♦ 

♦ 

ii 


M 


H 

iZ 



o 

♦ 


UJ 


♦ 

C/1 UJ 


3 

UJ 

CJl 

S 




+ 

a 

3 

+ 

♦ 

w UI 



a 

CL 

UJ 

z 



♦ 

i 

o 

+ 

♦ 

O 


II 

Q 


X 

o 



♦ 

X 

-J 

♦ 

+ 

© cj 


Ui 

CJ 


o 

3 



+ 

O 


t 


|Z T- 

CM 



CM 




£ 


Z 

o 

♦ 

♦ 

<1 in a 

<z 

Q 

c n 

© H 

X 

z 


O 

+ 


H 

♦ 




CJ 


co 

p 

o 


at 

♦ 



♦ 

+ 

ro • 


* 

> 

• 2 

a 

£ 


U. 

♦ 


>— 

♦ 

♦ 

C-4 © 

cn 

Ui 

OC 

© j 

A 

UJ 



♦ 


cn 


♦ 

♦ J 3 

© 

_l 

QC 

3 


—j 


cn 

+ 


D 

♦ 

♦ 

>- Hi 


A 

UJ 

X 

OC 



a 



—> 

♦ 

♦ 

Z UJ M 

w 

<r 

X 

— © 

O 

u. 

u 

a 

♦ 

A 

a 


+ 

<r iZ DC 

OC 

(— 

u 

iZ u. 

U. 

►H 

K 

« 

+ 

© 


♦ 

+ 




■ » 

t» Ik 


(» 

ae 

■k 

♦ 

O 


•f 

♦ 


Z UJ 
i 3 <X i 


x i >- <r 

U CJ « 3 

3 3 0 0. £ © UJ 

o o » * * 

jQjaia«(n<I' 


> D 

n oc in j o 
*►- * «in 
Q « tn « 3 <m 


$ 

Q 
a < 
« C • 


S£ 

oe O 


♦ © 

+ © 

♦ O 
CM 4 O 
k- 4 — 

« ♦ © « 
X 4 * * 

I H ♦ < U 1 


<t U 

*«ir® 


<z u 

® « x r 


u 

_j 

A © 


CM O 
•c* X 

is 
»- 

o -J 

44 

*'* 

+ w f\ ® CD 
• ♦ Q + G 3 + - 

' + LU a H K ® © 

i + a: m tn Q m m 
l + JCDOU^f-O 
: ♦ * -X X * -x 
i i QZioUaato 


CN CN 

♦ + 

I I 

I— ►— 

O O 


+ -J -J 

4- © * * 

+ ►- IV CO 

+ CO + 0 + 

4 Z Q Q U 

+ hhc n d 

+ 3 3 O 3 -J o 
♦ - - X * 

4 © X tn a 3 A 


a. 3©rN©fNii-i>-ia3©3h-»M©iHMk-« ^ w q u h 

xNoxzxz3X«Qxo©xx3*3i-xn®N©uXx'ni 

UTruTUTCJQt-ilUfl£untuiuzO-)ucca:«i: 


Q 

■ x _l a © ■ 
I 3 Z x « X 
IlHjan 


►h 3 « U 
3 O Z _J 

x r « oc c t 


5?X««UO>x<^uh 
PQZ? 


a + -i a 

<J + hmJJMmq. • 

__- _JX4XX«XX3Z- 

H«oiroc + jain + jjujjtn' 


4 CD 
+ © 
4 <x 


+ © 
+ u 
+ O 


4 CD 
4 »-i 
4 Q 


in 


in 


m 


in 


in 


CM 


o © © . 

cm cj u o u co — cm CD m »- <r © uj u. u. © cm o 

— »- — © rv. CM © O CM O O U. MO © o © -o u 

<I*IiB»(N<ICN'0-0‘UJM«UJO«IUJtMUJnuaiN<ruJa3U.-0CCU.'0n«0-r^ 

nuNauau>-CM<-NUMLua'OunN)iLuauiLQOUJOin'--N>-u 

in-oo-^auiu.N^MDo-uQu.o^n-ocoaaujiLfMfwmcauuju.cMM 
©©©©© 0 ©*-«- — ’-*- — — — CMCMCMCMCMCMCMCMCMMrOMr)MMrOMrO^'«- 

inininininininwinininininintniiiininininintninininininininmininininin 

ooooooooooooooooooooooooooooooooooo 


© a n«—>oocm in 

O © © UJ O O UJ © 

ro ro D'-an<r-in 

•c -o <r u in -o ro o cr 

« * cm — a <x *— >o m 

CM CM CN •— CM CJ CM »- O CJ 


■ocoocciiiuQiu^o-CMn^in-cco 

4-T44<r<r44«r^minininininin 

inmininininininininininininintnin 

ooooooooooooooooo 


O' u © 
in in in 
in m in 
© © © 


OM'OO'UU.- 
-O -O M3 -O O >0 CM 

in in in in in in in 

© © © © © © © 


n - -o cm a 

© UJ © UJ © 

Lt CM © CM «— © 

in cj in © -o © 

«- — © — <x -o 

- CM U *- CM O 

*r in. « © © po 

IN fS CM PM CO CO 

in in in in in in 

© © © © © © 






♦ 









© 

* 







4. 



4 


4 



+ 









+ 









3 

* 







+ 



4 


4 



4 









+ 









<1 

* 







4 



4 

H 

4 



+ 







cn 


♦ 









Ui 

+ 







+ 



4 

CJ 




4 







>- 


+ 











X 






4 



♦ 

<1 

+ 



4 







UJ 


+ 









X 


G 






* 



4 

X 

+ 



+ 







X 


♦ 









o 

♦ 

!-! 






+ 



+ 

UJ 




+ 






X 



+ 









X 

+ 

X 




G 


4 



+ 


+ 



4 






CJ 

Cl 


♦ 










T 

r-j 




o 


* 



4 

G 

+ 



4 







Q 


+ 

»— 








Ui 

4- 




X 


+ 



+ 


4 



■f 









+ 

Z 


UJ 






O 

f 

— 






4 



+ 


4 









o 

cn 


♦ 

<1 


£ 






X 

♦ 





N 


+ 

© 


4 

O 

+ 



+ 









♦ 










+ 

X 




I 


4 

r 


+ 












z 


+ 

cn 


»— 






z 

+ 







4 



+ 

CL 

+ 



+ 





a 

X 

UI 


♦ 

z 








1— 

+ 

© 




© 


* 

X 


4 

© 

+ 



4 





X 

o 

UJ 


+ 

o 

CD 

© 






<x 

♦ 

© 




£ 


4 

G 


+ 


4 



4 





M 

— 

3 


+ 

U 

z 

O © 

X 


© 



X 

■f 

►H 




<r 


+ 




G 

+ 



+ 





CL 


1- 


♦ 


M 

j— 

© 


z 




♦ 

3 




ut 


■f 



+ 

<X 

4 



4 





a. 

X 

u> 


+ 

w 

3 

Ui CJ 

X 


M 



3 

+ 








© 


+ 

u. 

+ 



4 





O 

o 

A 


♦ 

a 

o 

X UJ 

X 


_l 



tn 

■f 

O 




k. 


+ 

X 


4 


+ 



* 





w- 

a: 




UJ 

_l 

y~ u. 

<x 





z 

■4 

T- 




© 


+ 

G 


♦ 


4 



4 





cn 

u. 

UJ 


+ 

UJ 

Ui 

© 

£ 


cn 



UJ 

+ 

•* 




z 


4 



+ 


+ 



4 


m 'O 


O' © 


cn 

£ 


+ 

0. 


\ UJ 



© 



+ 





M 


+ 

© 



© 

4 



4 


•- CM 


m © 

3 



♦ 

cn 

H 

n 

>- 


H 



© 

♦ 





-1 


•f 



+ 


4 



+ 


+ + 


* o 

o 

Ui 

►— 


+ 


o 


X 


> 



o 

+ 




a 




i— 


+ 

H 

4 





I x 


x CJ 

Z 

CD 



+ 

iZ 

Z 

_J z 

OC 


A 



H- 

♦ 





*— 


+ 

a 


♦ 


♦ 



♦ 


t— ►— 


H 


z 

z 


♦ 

UJ 


-J D 

UJ 



G 


© 

♦ 




X 

X 


4 

o 


♦ 

z 

4 



♦ 


G G 


G X 

u. 

<r 



+ 

UJ 

u. 

M O 

X 


o 

X 


© 

+ 




cn 

UJ 


4- 

A 


♦ 

a 

4 



4 


© _J 


_i <x 

i—i 

© 

z 


♦ 

X 

>-i 

u. cn 

o 


* — 

U 


X 

4- 




3 

z 


+ 

<r 



© 

4 



+ 


z z 


z « 

•k 




♦ 



•» ■» 

«» 

>- 

• ‘ 

X 



■+ 

o 



X 

ik 


4 

• a. 


+ 


4 



* 


© _l 


_J 





+ 










4- 





X 


+ 



+ 


4- 



4 


* * 


# 





1 




r- 

X 





4- 

* 






♦ 



4 


4 



4 


"O M3 


M) 





♦ 

•- 

© 

— H- 

© 

X 


X 



4- 

I 

X 


•— — 

G 

CN 

♦ 



♦ 


4 



4 


+• <t 4 

<r 

+ « 





+ 

X 

H 

x a 

h- 

© 

o 


z 


4- 

© 



a z a 

_j a 

z 

♦ 

© 

© 

+ 


4 




© 

a z © 

z 

© Z 

z 



z 

■¥ 

UJ 

UJ 

UJ o 

© 

X 


X *- 


4- 

© 

X 



z 

h- 

+ 

© 

© 

♦ 


4 


© © 

+ 

a 

►H M M 


M W 

X fH X 


© 

►H 

+ 

z 

X Ui 

z u z 

X © 

CJ 

1 

tn x 


4- 

*- 

© 

<x 

X © X 

© X 

© 

4 

«- 

Z 

+ 

© 

4 

<r 

£ £ 

4 

.j 

3 h- <r 3 i- ■<£ 

O H- 

— © » 

_J © 


© 



*- UJ 

M © - 

o © 



= 3 


* 

a. 

a 


Z 3 0 

o 

3 

+ 

a. 


+ 


4 


W M 

4 

<x 

► >- a. a. 

>- a. 

» >- 

»- cn <r 

<1 

© 

+ © 

<r I- <x A 

-r- Z ro 

— H © <1 

«r © 

x a 

© © 

X 

x x 

4- 

A 

© 

© £ 

M A X © 

©XU 

Z 

+ 

«I 

1- 

♦ 

<£ 

4 X 

X 

A 

T 

H 

T 

H 

4 

« 3 

X A © X 

a a 

x * rx 





+ 










4- 







4 



♦ 


4 


4 



z jQa-uo 

m r —i u -) x 


«« Hi • 

oc h d r 
o in n 


<r <x 
a a: n 
_i o “J 


x _j x _j 

hh'JmmUjjh h ui •- a i j i 

UHlZZltCOlU x a X <t O <X ! 
©cflUlculutui _i © Jaiui 


XX 4 4 4 1 4 _J 

^cn«>xo:Na.HQoeNh + Mi + M4cn5itNQ:N£Ll- + «<XMj^ 
Caa©Z0Z0X«CJZ©4^X434a0UZ0Z0©4©k-X<£0 
jutHQ-iijaaii + r -> + z + a. taToio.* 4 xia jut 


oc cc 

+ UJ UJ 
4 Z Z 


M —I 3 M -J W INI 
X « o X « flL Z 

Jut JUun 


+ x 

♦ X 

♦ CJ 


co i- rv oo ck 

© — — © «- 

m'0<lLLl«xcjincMujro 
T-cM-iLaNffl-nu 

UJU.i-ri4TMCDO««U 

nt.cdcococococdcocd 

-r-r<r'r<r4<r<r<r-T 

oooooooooo 


© o 

. -- <r -r 

» — <1 O O Q CD 'r <1 « U. UJ« ©UI — U U ▼ Q A A A 

<TN«acMiiJCM-oujcMOuiuj« r-in-o>«-ar-o> *-in«MiincM^»-o>ocMO' uj ro 

oiaunoitQuiiQUMtQria^-ouujcj ou-mmouuj^*-ouu nu 

u.o-tn-ooDaou.Nin'Oco iuju.rin-oo<i ®u©'-cm<tiitcd®ujo — ^ in cm 

co0'0'0'0'0'0'0'0'0'<c<x<r<i <x<r<roQA®»® «cquuuouuuuq©q © © 

♦ ar «r 

OOOOOOOOO©©©©© OOOOOOOO OOOOOOOOOO©©© o o 


UJ © 

m © 

UJ © 


<r 

© 

cj in 


in © 

© © © 
©*-©*- 
— u u ♦ o 


inrvQCNincN'-O' 

ui'OrocJCMCJuicj 

UOUJU.CMrO'OfM 

©OQOUIUIUJUi 

OOOOOOOO 


© — in 
© uj © 
»- © -o 
'O ® «r 
u. cm 


— in »- in in 

uj © uj © © 

<r sj cm ~o rs. <r 

o* <t * © © 

Qu. — arv-auicN 


MCMUinCMUinCMUltU 

CDO'UU.CMn-OO'dQOCM 

U1UIUJUJU.U.U.U.U.U.OO 

oooooooooo ot-. 


Number 50 

414 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia 


Page 19 




ta 

4 CM I 
+ - 
♦ A ; 


CM 4 
+ 4 

Z + 
►- 4 

o * 

-J + 


4 a x to 

♦ cj u h- 

4 u. <x to 

+ M “) C 


A — 4 >- 4 4 

■ w>- ♦ aa ♦ 

1 aj q + uj h + 
Z « 4 OC :> 4 


« O 

* z ■ 
rzm 


0) 


« x r i z uj 


o 

_i 


X oc 
-O Ui 
O _j 

- <x 

I A CJ 


o 

Ui 

K 

>- 

A 

ac 

a 


X X 
O UI 
O _J 
■>« 
I A CJ 


A CJ 
-X 
<t ft. 


4 X 4 

4 * 4 

+ 0. 4 X 

n it ♦ ui a: ♦ t 

x 4 x x 4 at 

N U + # U + U 
-oc ■*• -oc 4 » 

<r a. 4 « ft. 4 « 


o 

-I 


_j m 

<r o 

» X 

X 

*- !! 
U *- 
Ui o 
A o 
X A 
Ui 3 


O X 
Ct X 


U. X r- H- 
o ui <r cn a in 
-3 -X * * 

» A a. U 3 -I A Q 


A 

Ui 

QC 0. 
uj O 
X ft. 

t*i 


U ft- 

ui a 

X £L 


<1 X N , 

Q u I u + x 

JQTIt + J 


3XaeNft.H 
O Z (J * C3 UJ 
r m q i q. ot 


_i i-i X a. 
<x X x X 
CJ -J w -» 


3X0. 
: M o * r 

iittm 


3 X 3 Z X 


X £L N ► 

z x 2 i 
hU->£ 


a •-« a. 

3 3 X 

a. z -> ■ 


i 4 - U)m[/)>J^wU)Z> 
4 3330 XOX 3 <-»I 
+ a.xo.r_iX_Jft.Q.C 


4 A 
♦ CJ 
4 u. 


4 3 4 3 

4 0 4 0 

4 0 4 0) 

4 ft. 4 X 

'-in • - A 


A X 

o « 

*H A 
A Z 


o ro <r rN 
nnnn 
•o -o -o -o 
o o o o 


UJ li. © — CM li") 'O 

n fo «r ▼ t <r 4 

-o -o ■« -o -o -o -o 
o o o o o o o 


■o in -o 

o o o 

CO If) A 

MIO If) 

a — ro ro 

U-(MU 

r\ « a uj 


rN -o 

o o 

in <r 

CM If) 


in in 
>o mj 
o o 


rs cm 
o uj 
A CM 
CM O 


If) If) 
M3 M) 
o o 


A UJ U. O — CM ro 

in If) If) 'O >o -O M) 

-o o -o o -o m3 o 

o o o o o o o 


03 O O A 

UJ O CM -O 

ui -- -o ro u cm o> 

rO CM r) CM A o o 

-O CO A A UI U. CM 

-O -O O -O -O -O K 

-o -o o o -o -o o 

o o o o o o o 


o ro 
O O' 

m -o ro 

CJ o u 


N N N 
•o -o -o 
o o o 


O' ro 
o o> 
in M3 ro 
CJ O CJ 

O' <1 CJ 
N N N 
•o -o -o 
o o o 


IN. CD 
-O M3 
o o 


o o 

CM O' 

UI to 
ro o 

<r -o 
00 00 
M3 -O 


00 o 

O O' 

ui ro 
ro cj 

O' A 
00 CD 

•o -o 
o o 


u. in — u. — 

O UJ O O' A 

u')'OinLL<rco*-inO' — 

UOQ4CM-0-QUJ UI 

o — roifiM)0'<lAUJ u. 

O'O'O'O'O'O'O'O'O' O' 

'O'O'O'O'O'O'O'O'O -o 

oooOooooo o 


z 

o 


z 

tn 

D 

a. 


;^-XX — XX — XXr- X 

t i 3 ^ i 3 C l ^ « i 3 

■ *rH >— - —• t- - m (— » i-4 

ioQ(JiAu'jiQpwa a a ' 


- <r <i 

x r x 

3 O -J 


in ; 


: a 


+ cj cj a a 


+ _j cn cj 

4 « A U. X 

+ in m h H UJ 

4 » iX Ltl UJ ft. 

4 <11-11)0)0 


* o r-j h- 

O Cl 4 i. 

i ^ a v q h 

: »■ <L o <E CJ 

I iX x <z x LiJ 

: i- a i o a 


uj _j s: 

cn <i <z 

o — -} 

-i a: a 

lj )- <r -i <x 


cn x a uj uj 

-icnu*-?- 

<1 O !i UJ « 

! M H *- _i U 
. oc Ll! UJ uj :V in 

> « !T. 3 u in 


• *- CN 

Cl + UJ >- uj 

: a m « *- o: cn 

I4U^ HhO 
: r u x x uj _i 

i a a: a x oc u 


i _j a. w j cl h Nh<h 4 i 


3^XA3«^-.M* 


! rM _J _i _j t 


H Jft.M JlM Jl»._ -... - _ _____ ___ 

x«ox«Ox«ox«Qx<toil.*3r-uj43Z<xCJoC2x<iO!ZoQ.z:>ouj + :>r-C<x<tx<*zxxxxxacjZoLLJ + =»*-<r«x<i«a.ZZxZx«z<x£L 

juo.jua.jua.juo.juo .0 ")xwoc 4 x»-«A“)xxH4AxaZo3xxoc 4 rt/iuuuLCUnjcfljuiTjAlQQc 4 I'Xuuuuuacjc/iji/iuiuit 


4 3 3 
•-A A 


4 X — 
4 CJ X 
4 <r <x 
* —> —> 
4 A A 


* X x 

4 CJ CJ 
+ <i <r 


m m *) JH 

A A a a 

cDu)rocjiniou.inrou.inmu.ui in 

QO — U.O — U-O — U.O — U.O O 

OUJCIAUJCMUUJCM'OUJfMU.UJ O CJ 
U-A — — A — O'A — UA — U.A IMA 

— A — — A — — A — — A — — 3 — UJ CM 


— CJQ — UA — UA — UA— UAU. U 


O 

ro 

UJ 

ro 


cm o- 

— CJ 


in u. 
o in 
u. o u. 

CM CJ CM 

ui CJ O' <Z A 

O O — A IN 


in 

u. 

CN 

<X ro o- O' o in 

IN ^ — IN. AM- 


m 

o 

O IN O 

ro a cm 

UI CM UJ O' O' 
U. CJ O N CJ 


A 'C -o -O 
O O o o 
in in m in u 
o in <t m- a 

UJ CM A A A m 

ro ro cj u cj u. 


-o in o a o A 

o o o o o © 

— A © rs IN O' 
CJ U. CD -O 00 M) 

a cm <r rj <t cm 
U (J CM CM CM CN 


•O A UI 

o o o 

IN IN A 

a in a 

ro C A CM A O' 

cj ro ro cj ro u 


A -O -O 

o o o 
un rs ro IN 
o u") <r m- 

UJ CM A A 

m ro cj cj 


O O A 

o o o 

A A IN IN 

<r «r io -o 

A A Ui O OT 

U CJ U. A CM 


O A © N) -O 
O O O O O 
O O' IN CM O 
® -O A A ro 
CM C CM A (M 
CM CM CM CJ U 


M3 

O 

IN 

A 

A O 
CJ U. 


M30'UoroM3<xQO<rN<xuj — o-in \«ua 

C0AA0'O'O'0'0'<t<r«4X<XAAA A A A A 

mmmm^ininhTinwTinininininin m w in in 

OOOOOOOOOOOOO o o o o o 


UJ O — CM 
A CJ CJ CJ 

in in in in 


in 

CJ 

in 


CD a u a ui u. 
CJ CJ (J CJ CJ CJ 

in m m m in m 

o o o o o o 


rN a 

A A 

in in 

o o 


O' A UJ — M- IN 
A A A UJ UJ UI 

in m in v) in in 
o o o o o o 


® A UI — M- IN 
UJ UJ UJ U. U. U. 

in in m in m in 

o o o o o o 


<1 A o — M- m 
u. u. o o o o 
in in o m) M) M) 
o o o o o o 


-OAAUJ — «TINO'<XAOrOM30' 
OOOO — — — — — — CMCMCJ CM 
•CM3'0'OM)M3M3M3M)M)M)M)OM) 
oooooooooooooo 


CJ li. 
CM CM 
M 3 M 3 
o o» 


Page 20 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

415 




• u. > 
z 
UJ <t 

r> + 

<x u 

A 4 

u 

\ S 


o f'l ^ >C CD l 


CM 

* 

o i- CM w -o co 

CM + 4 + + + 44 + + + + 

+ LtcxAAacxQcacxacacAA 

J >- ►— H- ►— ►— ►— H~ ►- *— *— 

► u-cncncncncncncncntncncncocnuj 


+ 

a + oaooooaooaaooocjz 

Q 4 UJUJUJUJUJUJUJUJUJUJUJUJUJUJUJUJ 


>- 4 ce in z ui in to id a. :> 2 o i- 

a + jKju*-MM-MnuJhOfl.a. 

A 4 <Ii1CZJJJJJJ3uuYh. 

LU 4- Z3£HMUJUJUJbJUJIlijyZUUQ 

x 4Mi-iza.yujUJUjUiiij<iiZ<t<zujz 

cj •- u. uit-t/icciZizacizacDucKiiZa; 


m 'O c 
«r in ( 
oo — r 


cm O' o~ U- rx 

in 'O N u co 

CD CD CO 00 UJ GJ 

o o o o o> o 


II II II II II II II II II II II II II II II 

u.r*rs.NC0O'<x®iau.»-roinr''O'U. 

CNinininininininintn'O'O'O-O'OCN 

QQQaQOQGQQaMQaaa 

oooooooooooooooo 



<N 

§0 

§. 

c 

o 

'ts 

•S 

■u» 

c 

o 


+ o 
+ o 
+ a 
+ I- cn 
+ uj o 
+ cn o 

4 a. A 

+ <r <C 


+ a a 

4 - A 

+ <x <x 


+ I- 
+ <1 
♦ UJ CO 

+ oc o 

+ UQ 


14 0 0 
i 4 ► CQ 

: + <r <x 

♦ 


+ U_ 

♦ 2 

■*• UJ CO 

4 a. o 
+ o a 
+ -a 
4 <r <x 


+ i 

4 | 

+ 

•f <r 






+ 



O 








A 




a 


Q 
























z 


z 


z 


z 
















X X I X 

X I 







<r 


<r 


<r 


<x 


A 














O O o O 

O o 


























4 



oo CD CD CD 

a CD 







-j 




_l 




a 






















iX 


X 


A 


A 
















x oc. oc cc 

X cc 







4- 


i— 






_i 











4 

X 


o o o o 

o O 







u 


o 


CJ 


u 


UJ 


\ 




\ 





♦ 



\ \ > \ 

x x 







•* 








C 



s 

o 







4 

a 


-> u: *- 

UJ >- 







X 


UJ 


UJ 


_J 


O <4 




. 










t v S 

\ > 







\ 


\ 


\ 


X 


in # h 


o 

O 











* ► » 
















fM * O 


O 

in 



o 






<t 

o 

X X X X 

X x 







a 


A 

















+ 


► 

O o o O 

O O 







z 


z 


z 


Z 


O _l X 


II 

X 



II 






UJ 


® CO a) 0) 

CD X 







<L 


<r 


<r 




O uj U 


X 

<r 



X 
























a- A <r 


« 

a 



<1 








\£ QC at ic 

cn cc 









| 


j 


—J 


1 


A 







O' 


4 

oc Q_ 

o C C O 

o o 







on 


at 


X 


X 


O r + 


N 

44 



\ 
















h- 


1- 




H 


UO —1 O 


2 

* 



o 











«• 


o 

o 


CJ 

o 

CJ 

o 


o 

u 

o 

-X UO 


+ 

+ 



4 







ua<* 

cn a 




► 



•> 

a. 

» 

a. 

a. 

a. 

a. 

a. 

o \ CM 

cn 

X 

A 



X 






p- 


\ N \ \ 

N \ 

o 





o 

\ 

\ 

\ 

\ 

X 

\ 

\ 

\ 

CM CD 

<x 

<r 



O 

<r 






►H 





o o 




UJ 

1- 

N 

o 

1- 

1- 

Cc 

>- 

-X H 

CD 

a 

a 


CD 

a 









-XX 

X 




CO 

\ 

\ 


N 




\ 


4- O (ft 

UJ 

X 

'x 


O 




_J 




2 

O o O o 

o o 

o 

co 


p- 

p— 

<4 









r- \ A 


X 




o 






2 


CO CO OO CD 

CD cd 

A 

■*> 

CD 

•—« 

a. 


a 

A 

A 

A 


A 

A 

A 

- >- <r 



44 



+ 






UJ 

2 




c 

z 

i_i 

M 

A 

z 

2 

z 

2 

z 

2 

z 

2 

o x A 


+ 

4 



UJ 

4“ 





_l 

CC 

CH CC X CC 

CC CC 

OC 

Cl 


UJ 

UJ 

z 

<x 

C 

<1 

<r 

<1 

<X 

<r 

«t 

r- U 

(ft 

z 

«4 



o 



r—1 



A 

a 

O O o o 

Q o 

o 

JL 


ot 

CJ 












O 

44 



Z 



•— 

cn h- 

4 

O 

i- 




u 

u: 

•J 

UJ 

3 

.J 

-J 

-1 

_J 

-J 

-J 

J 

_l 

O 2 _J 

-J 

-J 

44 



<r 





CC 

UJ 

\ \ 




UJ 


■X 


CC 

A 

oc 

A 

oc 

A 

A 

A 

— UJ <t 



4* 









Cc 

CC 

<4 <1 A 

<r 



l— 



* 

y- 















C UJ 


2 

O) 3 c « 

+ 

4 

s 

' 

\ \ \ \ \ 

\ \ \ 

N 


\ 



N 

CJ 

CJ 

CJ 

CJ 

CJ 

CJ 

CJ 

CJ 

O •-x 

\ 

\ 

\ 

\ N 

s 

\ 


t- 4 i-i Cl. 
UJ + => 2 
OC 4 2”) 


+ *- a. 

4 => 2 • 
4 2“)' 


►H O. • 
O 2 
2 “) • 


-J * _! _l 4 

3 h j'!)«wNjhm + 

OX<X=>Qu.3E^xx<rx:oQ:uj4AAAAAAAAAAAAAAAlZiAAAAAAC 
2_I(_)U- !U“!w-IJU“)O.OlC 4 QAAAaAAAAAAAAOAaAAAAAAt 


A A A A co CQ A 

o a a A a A a 


A PO 
O CJ 

uj rn 
po c_) 

n in 

<r <x 

■O 'O 


CD <Z 

<x <x 
■o o 
o o 


A Ul 

<r <r 
o >o 
o o 


A A 
O O 
o o 


O PO 

— o 
uj n 
m cj 

rv o* 

A A 

«o >0 


U. PO 
O CJ 
UJ PO 
PO CJ 

O UJ 

A A 

>o O 

o o 


O O PO >o 

O O UJ o 

CJ in O CM CM 

mo u v uj 

. «- a m <r UJ CM 

■t-CJU.POLi.CJ 


•O M 3 T- 
O O UJ 
0 in O' 
•O UJ CD 
A — »- 
CJ *- CM 


CO < 
► A 
CJ CM 


—> CC t 


: oc 


•o o 
o o 

A O 

in o 

A PO «- N O' 
U CJ U. A CJ 


O O O O' 

4 in ra cm r\ *r 

cm in o o o a «r 

*T UO O CM CM -o in 

u.«r<rA'rooouoo- popo 

4inUUw4(NNUA <0 111 

CNino«Li<roorJ 40 -in 

ID 4 <IUU<IMNAUO' 0 «r 

ocn^-t-Ooooo — o<r«r 

imn<xuCi<KNrj«u<i'Oin 


y c/i a >- cn i 

uj a. 2 ► 

CC U H ; 

A A 3 1 
UO UO UJ 


(N PO 
UO *P 
PO UO 


CM UO 
<T O 
cm cm 


im O' 

uo o 

O CO 
CM »- 


»- — O 


O UO O l 

o o o < 
* « u. * 

— T- O ' 


• u o <x 
> o o o 
■ O O' o 

• T- — O 


P) 4 K<IAWOn- 00 'UU.CMn 4 

CJUUCJUUAAAAQAUJUJUJ 

•O'O'O'O-O'O'O'O'O-O'O'O'O'O'O 

ooooooooooooooo 


O PO UJ Tp Q a Q 

ci m *r cm m n v 

CJ — u. -«r UT CJ U- 

«r cm ij-) ^ u- 

CJ CJ CJ Tf PO CJ CJ 

4 4 4 cm n 4 r 

■- o no <r O uo o 

4 CM V CM N » in 


O CM 

cm m 

o u. 


UOt- PO'OO'CJOUOAOPOUOt— O'^TLi.COAAOCMUOf'v^CJ 
UJO--^ I --NPI(NP0nn4<rii0in<'O'0NNNNNN 
'OrMrNPs.rMrMrNrxrMrv.pvrMpMrMrMPsrvrvr^rMfv.rMrs.fMrx 
ooooooooooooooooooooooooo 


Tp A A Tp ill a CM O' O' 

CD O' « U a UJ O *- CM 

im pm rs rs re co cd co 

ooooooo oo 


Number 50 

416 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia 


Page 21 




(Las Vegas — continued from page 21) 



Fd>Jump Tafrla nf 
ffieal PaJJara 
Srspliiss Soiling 
aid 1 . 9 . Soding 

087F 40 B 

0880 00 OO 40 00 OO OO OO 03 10 OO OO OO IF 3F 3F 3B 

0890 01 IE 00 00 09 IB IF 2D 37 IF 3F 19 08 00 26 36 

0840 36 20 04 36 36 34 20 00 40 49 12 IB 19 09 08 00 

08BO 00 01 34 OC 10 04 3B 2D 2E 3B 08 06 08 02 OS 01 

O8C0 3C 2D IB IE 20 00 04 22 12 36 34 24 20 00 00 OO 

08DO 40 12 12 13 1A 12 12 00 00 00 00 00 IF 3F 3F 3B 

O8E0 00 00 00 00 00 OB 3F 3F 3F 3F 19 00 00 00 04 24 

0BFO 24 26 34 24 24 20 00 01 49 49 49 09 09 09 09 09 

0900 08 07 02 11 38 IB 18 38 12 07 38 07 06 30 38 IB 

0910 18 38 3B 2E 38 04 24 24 24 24 24 24 24 24 20 OO 

0920 00 40 01 09 09 09 08 00 00 00 OB 3F 3F 3F 3F 3F 

0930 3F 3B 00 00 37 3F 3D 3F 3F 3F 3F 34 00 00 00 24 

0940 24 24 24 20 00 00 00 00 00 00 00 00 00 09 09 09 

0950 00 00 00 IB IF 24 3F 3F 3F 30 00 00 OF 3F 3F 12 

0960 12 16 24 00 00 00 00 00 00 00 00 00 00 00 00 OO 

0970 OO 40 40 00 00 00 00 00 00 00 00 01 OB IB 3F 3F 

0980 3B 1 8 00 00 02 3E 3F 3F 3E 34 20 00 00 02 34 OO 

0990 00 00 00 00 00 00 00 00 00 40 01 09 09 09 08 00 

0940 00 00 OB 3F 3F 3F 3F 3F 3F 3B 00 00 37 3F 3D 3F 

09BO 3F 3F 3F 34 00 00 00 24 24 24 24 20 00 00 00 00 

09CO 40 00 42 14 02 14 00 00 00 00 00 3C 24 3C 24 3C 

09DO 24 20 00 00 00 24 24 3C 24 3C 24 38 00 00 00 24 

09EO 24 36 36 34 24 20 00 00 00 40 41 09 09 08 00 00 

09FO 00 00 00 16 24 00 00 2D 34 00 00 00 00 00 00 02 

0400 34 20 00 00 00 00 00 00 00 04 20 00 00 00 00 00 

0410 40 12 12 13 14 12 12 00 00 00 00 00 IF 3F 3F 3B 

0420 00 00 00 00 00 OB 3F 3F 3F 3F 19 00 00 00 04 24 

0430 24 26 34 24 24 20 00 00 00 00 00 00 00 09 09 09 

0440 00 00 00 IB IF 24 3F 3F 3F 30 00 00 OF 3F 3F 12 

0450 12 16 24 00 00 00 00 00 00 00 00 00 00 00 00 00 

0460 00 00 40 00 00 00 00 03 10 00 00 00 IF 3F 3F 3B 

0470 01 IE 00 00 09 IB IF 2D 37 IF 3F 19 08 00 26 36 

0480 36 20 04 36 36 34 20 00 40 49 12 IB 19 09 08 OO 

0490 00 01 34 OC 10 04 3B 2D 2E 3B 08 06 08 02 05 01 

0440 3C 2D IB IE 20 00 04 22 12 36 34 24 20 00 00 00 

06BO 40 12 12 13 14 12 12 00 00 00 00 00 IF 3F 3F 3B 

O4C0 OO OO OO OO 00 OB 3F 3F 3F 3F 19 OO 00 00 04 24 

06DO 24 26 34 24 24 20 00 00 40 00 42 14 02 14 00 OO 

04EO 00 00 00 3C 24 3C 24 3C 24 20 00 00 00 24 24 3C 

04FO 24 3C 24 38 00 00 00 24 24 36 36 34 24 20 00 00 

OBOO 00 40 40 00 00 00 00 00 00 00 00 01 OB IB 3F 3F 

0B10 3B 18 00 00 02 3E 3F 3F 3E 34 20 00 00 02 34 00 

OB20 00 00 00 00 00 00 00 00 00 00 01 09 09 08 00 OO 

0B30 00 00 00 1 6 24 00 00 2D 34 00 00 00 00 00 00 02 

OB40 34 20 00 00 00 00 00 00 00 04 20 00 00 00 00 OO 

0850 00 40 01 09 09 09 08 00 00 00 OB 3F 3F 3F 3F 3F 

0660 3F 3B 00 00 37 3F 3D 3F 3F 3F 3F 34 00 00 OO 24 

0B70 24 24 24 20 00 00 00 00 00 00 40 00 00 00 00 03 

OB80 10 00 00 00 IF 3F 3F 3B 01 IE 00 00 09 IB IF 2D 

OB90 37 IF 3F 19 08 00 26 36 36 20 04 36 36 34 20 00 

OB40 00 00 00 00 00 09 09 09 00 00 00 IB IF 24 3F 3F 

OBBO 3F 30 00 00 OF 3F 3F 12 12 16 24 00 00 00 00 00 

OBCO 00 00 00 00 00 00 00 00 40 12 12 13 14 12 12 OO 

0BDO 00 00 00 00 IF 3F 3F 3B 00 00 00 00 00 OB 3F 3F 

OBEO 3F 3F 19 00 00 00 04 24 24 26 34 24 24 20 00 01 

OBFO 49 49 49 09 09 09 09 09 08 07 02 11 38 IB 18 38 

OCOO 12 07 38 07 06 30 38 IB 18 38 3B 2E 38 04 24 24 

OCIO 24 24 24 24 24 24 20 00 00 40 01 09 09 09 08 OO 

OC20 00 00 OB 3F 3F 3F 3F 3F 3F 3B 00 00 37 3F 3D 3F 

OC30 3F 3F 3F 34 00 00 00 24 24 24 24 20 00 00 00 OO 

OC40 00 40 40 00 00 00 00 00 00 00 00 01 OB IB 3F 3F 

OC50 3B 18 00 00 02 3E 3F 3F 3E 34 20 00 00 02 34 OO 

OC60 00 00 00 00 00 00 00 00 00 00 00 00 00 09 09 09 

OC70 00 00 00 IB IF 24 3F 3F 3F 30 00 00 OF 3F 3F 12 

OC80 12 16 24 00 00 00 00 00 00 00 00 00 00 00 00 OO 

OC90 00 40 01 09 09 08 00 00 00 00 00 16 24 00 OO 2D 

OC40 34 00 00 00 00 00 00 02 34 20 00 00 00 00 00 00 

OCBO 00 04 20 00 00 00 00 40 00 00 40 00 00 00 00 03 

OCCO 10 00 00 00 IF 3F 3F 3B 01 IE 00 00 09 IB IF 2D 

OCDO 37 IF 3F 19 08 00 26 36 36 20 04 36 36 34 20 OO 

OCEO 40 49 12 IB 19 09 08 00 00 01 34 OC 10 04 3B 2D 

OCFO 2E 3B 08 06 08 02 05 01 3C 2D IB IE 20 00 04 22 

OBOO 12 36 34 24 20 00 00 00 40 12 12 13 14 12 12 OO 

0D10 00 00 00 00 IF 3F 3F 3B 00 00 00 00 00 OB 3F 3F 

OD20 3F 3F 19 00 00 00 04 24 24 26 34 24 24 20 00 OO 


Page 22 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

417 





by Leonard E. Garcia 


EUlCrV^El 


] I lLMH STFH EF1SI3 

1 STFUEfflEflT SEflENFETEN 


QUICK-KEY is an 8080 assembly language program that 
generates North Star BASIC commands and statements from 
pre-stored text in memory by using a two key command. 

The program also allows a user to enter and define any 
text that will be sent to the North Star BASIC interpreter 
(or any system program) upon hitting a special sequence 
of keys. 

Commonly entered routines, answers to prompts, even 
entire routines can be entered into the program and sent 
to any program that calls for a character from the terminal 
by just hitting two keys. A user no longer needs to enter the 
same information again and again. 

As written, the QUICK-KEY program contains commands 
and statements which are used by the North Star BASIC, 
but the text can be changed by the user interactively and you 
can make copies of the program containing text for an assem¬ 
bler, text editor, user program, etc. 

The text is stored in blocks of 32 characters, and the 
statements or text are accessed by hitting the sequence: 

ESC x 

where ESC is the ESCAPE key and the x is a letter key in the 
range of A thru Z. 

Once the program is executed in high memory, it will lo¬ 
cate the address of the user’s Character-In routine in the 
North Star DOS, patch it into its own routines, re-route the 
Character-In “calls” to itself and then return to the Disk 
Operating System. The program will then scan all keyboard 
entries for the ESC x sequence code to send the text to what¬ 
ever program called for a character from the terminal. 

Thus, the sequence: EscA 

will send the text: ABS (Absolute) 

to the BASIC interpreter, and display on the screen as it is 
being echoed by the system. A second ESC will cause the first 
text, ABS, to be rubbed out and the next statement that 
starts with “A” to be sent: 

APPEND 

Continuing to hit the ESC key will send the next command 
of the “A” series, deleting the last that was sent. Once a 
space or another character other than ESC is entered, the key 


Leonard E. Garcia-3517 Herschel Ave., Dallas, TX 75219 
Number 50 

418 


code is then voided and another ESC x sequence may be 
started to generate a different text. 

For example, the statement 

100 IF A1 = 0 THEN GOTO 300 ELSE PRINT “TEST” 
may be generated with the sequence: 

100 EscI A1 = 0 EscT EscGEsc 300 EscE EscP “TEST” 

Note that EscG will generate the text “GOSUB”. Since 
the statement we wanted was “GOTO”, another ESC was 
entered to rub out the “GOSUB” and send the “GOTO” 
instead. 

Should you wish to use spaces to indent a program, the 
sequence: 

Esc (Space bar) 

will send 5 blank spaces to the BASIC interpreter. Another 
immediate ESC will rub out the first 5 and send 10, and a 
third will rub the last 10 and send 15 spaces. The ESC (Space 
bar) will in fact act as tabs to enter a formatted program 
listing. 

CUSTOMIZING. 

Keys H, J, Q, U, X, Y and Z do not have any corresponding 
BASIC statement or command stored under them and are 
available to the user for any custom text. QUICK-KEY 
will accept, in its customizing mode, text to be stored and 
defined under ANY key. This text may exceed the 32 char- 
acters/key that is allowed, but the key code for the next 
block of text will be overlaid and cannot be used. 

When entering the customizing mode, hit “C” when the 
program asks for a command. It will then ask: “FOR KEY 
LETTER (A THRU Z)?”, enter the letter and a format will 
appear as a guideline to entering the text: 

.31 char . 

If the text = NOW IS THE TIME FOR ALL GOOD MEN TO 
WRITE PGMS (Ctl-C) is entered under key code “X”, then 
hitting EscX later will send the entire text to the interpreter; 
while hitting EscY will only send the portion “TO WRITE 
PGMS”, since it starts at the 33rd character. This feature may 
be used to send a name and address to a program or address 
only, etc. 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 









Another method of customizing text is by use of delimi¬ 
ters. The semi-colon (;) is used to signify to the program the 
end of characters. Thus an entry formatted as: 

NOW IS THE ;TIME FOR ALL;GOOD MEN (Ctrl-C) 

under a key code letter “Z”, will send text as follows: 

EscZ = NOW IS THE 

Esc = TIME FOR ALL (Rubbing out the “NOW IS THE”) 
Esc = GOOD MEN (Rubbing out the “TIME FOR ALL”) 

When customizing text in this mode, the last character 
you enter MUST BE A CONTROL-C. This will indicate to 
the program then end of text for that key letter. 

More than one line of text is allowed, with the carriage 
return being sent along with the text to the BASIC interpreter. 
Thus the custom text: 

1000 REM—COMMON USE ROUTINE— 

1010 FOR A = 1 TO 10 
1020 PRINT “ ” 

1030 NEXT A 
1040 RETURN 
(Ctrl-C) 


w 

-J 

o 


O l/l 

X l/i 
u in 
UJ _J 


Gift: 

+ w 
cl w h 

Cj l/i z 
Ci CL 111 
CL CD = 


O 

CL 

I/J 

6 

cr 

CD 


W 0 X 1- T. 

ID 0 UJ Dlhll- lL G CL 

l/l Oh ZIuh l/l CD l/l X CL Ci l/l Ci 

l/l - h • • X *T — 1 U) J O Ci Lj Ci . ___ 

ziDiuCuuGuEiatrJiiiiiD'rziiuoh-irjOcciLiflj 


iS* 


X 

IhO 
h- CO D C M 

: zooo 
. o X 


d*—. m cr j r- j « ^Lj^zCiCiC.CiC.c.jj!jcLljHH M n hjh 
I X X ll X O X ll u Cl Z D O X X I I X X X X I lL X Cl N fL Z G X G 
O J J X U Z u u O hi U) Z C u Ci (j Ci C i/i UJXUUhU^ZOZ 


u Cl Cj —. 

Cl _l -1 -I CL _1 - 



may be stored in memory under any desired key A thru Z. 
Of course, long text will overlay the existing text, but it is 
easy enough to have various copies of the QUICK-KEY 
program with different text. 

THE PROGRAM. 

... is assembled at 9A00H. This is the highest in memory 
that it can be assembled for a 32K North Star system with 
memory starting at the standard 2000H. The customizing 
routines, commands, etc., reside in the lower part of the 
program and can be overlaid by a user program once the QUICK- 
KEY is operating. However, since NS BASIC places temporary 
data at the highest address for which it has been set, it must 
be “MEMSET” after it has been loaded in memory to an 
address no higher than 39880 (decimal). This will prevent it 
from overlaying the functional part of the program. This 
reminder will be displayed by the program. 

After any text has been entered into memory in the cus¬ 
tomizing mode, and ended with a CTRL-C, the program will 
return to the command mode. Once the patch is effected with 
the “E”, (EXECUTE) command, it will re-route the user’s 
I/O routines and cannot be jumped to or customized again 
unless the I/O has been restored to it’s original configuration. 

This is done with the sequence EscO. This command will 
restore the I/O and then the QUICK-KEY program will be 
inoperative, no longer scanning the keyboard inputs. 

So, the normal procedure is to: 

1. With your North Star DOS loaded, execute the program 
from disk. 

2. If any customizing is required hit “C”. 

3. If none is desired, or if you are thru customizing, hit “E” 
to patch the I/O. 

4. After the program has returned to DOS, execute your 
BASIC interpreter and limit the memory it can use with 
the “MEMSET” command. 

5. Use the program, when done hit EscO to restore the I/O. 


o oi u o n a u. x c 

iT, UJ <?> «h 0 f - IT' '■LI C 


C KJ 


i_i ' u. i_i i - u in u- uj u 'i.> LL d> CD 0 \ O', d* CT* CM Q <L L 
O CM -< X O "T O U. 2 tL O <5 3 CM CM CM CM CM ^ CM O T 


?M !£ O 

N d* X Hi (J G UJ U. 0 IT d* (£ 

, i oj h ij * ^ ni n i Cl IT f-T l- i IT IT IT IT TT X T T 

d* d* d * d* d* d* d* d* d* d< d* d* d* d* d* d* d* d* d* d* d* d* d* d> d* d* 


5 CM CM CM 

'C d* (J (j u u U. CM 10 'D d* (E Lj Ll CM *T f 

•1 •“* *h cm cm cm cm cm cm cm it it n 

ira:a:o:'ra:a:a:i'ri(r*rcca:a:ci:a:a:(E 
r. d* d- 


ifSffOSSig 

Ci LL CM X N d* U 

ZZS&e&IQ 

d* d* d* d* d* d* d* 


»••••••••••••••••« 


UB 



t_i > i_i > 
HQjlii; 

in z o 


hulUI 

Hid: 

cl in o z 

3 E- — 

z m 

O h I HI 

E- UJ E- 

m cl z 

UJ Z Cl UJ 
Z CL Z 
HiLOUJ 
1 — ID Z J— 
d o h cr 
o cl in E- 
ll ll Ci m 


(L ^ 

o -I 


fc? 

u Ci 


UJ z 
h i- ll a: o 
z m CL E- 
h Ci UJ K~ l/l 
CL O -1 UJ Ci 

0. = o id o 


CL UJ 

UCh 

X CM 
X _J If) 
Q UJ K 
I 

• ij X 

u in e- 

LL 
Cl UJ 

ll x in 

X X 
Z I'- _1 
O _l 
UJ 10 X 

_i it Ci 


xix 

or. o a x c 

CM hoiIlCiIC 
O O IS u X h h ( 

CM CM CM 0 ® 0 0 l 


jjDjjjjG 

GGGGGGGCL 

UJUJUJUJUJUJUJO 


0 ^ 
in a 

in in z 
in in *-< 
z z X Ci 


'■ m s e- x 

O Ci UJ X IT 
'• O' Cl 0 


_l _1 X _l l-l ►H 

X X CL X a. N CL N Cl 
UUXUuEOIU 


l/l Z Cl u X M 
O ►h o CL Ll m E- Ci 
* * *CiOOO_IUJUJG* 


0 0 00000000000000000000000000000 
-< cm it io 'D r-- co d* 0 cm to 10 o n co d* 0 cm it t id o n co d* 0 

000559000 HHHHHHHHHH CM CM CM CM CM CM CM CM CM CM f-T f-T 
0000000 0 000000000000 0 000000 0 0 00 


A FINAL NOTE. 

Please remember that this program sends data in to DOS, 
BASIC or any other program that uses the North Star DOS 
for input. Commands such as LOAD, DESTROY, NSAVE, 
etc., are sent by the program just as if they had been typed 
in at the keyboard and MUST be deleted manually if in¬ 
correct! □ 


XX 0 X 'x 

d* d* CM d* d* 


QGLlGUJXUJXUJ 

ooxou.ou.ou. 

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IT 'D f'- X U U. i-l Tf 

xxxxxxx£xxxx£xx&§xx&xxxxx£xxx£S: 
a-. d> d* d* d* d* d* d* d* d* d* d* d* d* d* d d* d* d> d* d* d* d* d* d* d* d* d* d* d* d* 


Page 24 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

419 







a 

w« 

X 


© © 
CO O' 
tO to 


c- 



N 


1 

1 



3 

1 


X) 

O 

1 


(E 

-1 

1 


Z 

G 

1 


h- 

G 

G 




Z 


(E 

h- 

Z 

in 


X 

G 

o 


G 


Ci 

(E 

H 



G 


to 

o 

H 

G 

1 

L— 

F— 

G 

1 


G 

l- 

1 

G 

G 


1 



G 

1 




1 

Z 

LU 


1 

CE 



1 

_J 



1 

H 

G 


1 

G 

X o 


1 

CE G CE 

K G 

f— 

G G 1 

G _l ' 

G '• 

G ' 

G G \ 


G G G 

G G 

G G 

G G G 

Ci C. Ci 

Ci Ci 

C. Ci 

C. C Ci 


K< 

*T 



H 

H 



LU 

G 



H 

H 


© © © 

© © 

© © 

© © © 

© *h CM 

to rr 

ID G 

P - G O. 

rf rr rr 

rr rr 

rr rr 

rr rr rr 

’-i 

1-1 *-l 

*i *-i 

•H H H 


3 

C 


z 

id 

lL 

LU 

X 

H- G 

3 

k| 

?=. 

Cl 

59 

o ~ 

-< CO 
F“ _] 

UJ £ 

£5 


LU 

P 

cP 

G LU 


LU 


z 

3z 

G & 


I (L h u : 

O C, 

O Z _1 O H 
LlI I— LU _J I— •—*_ 

g lo t-i g g o 
go; h a: o i in ^ a :\~ 
zzGLnx»-GGGG_jF-xG 
x g x x = ►-< x *-< x g 

GGGGGOF-I— iE G g 

1-1 X O G F- W LU O 

iu -• g ldlum -• ld g o g 

g g in g g in -. z> m cc o os •- 

IOLJIOliJGiEli'ililjKLUO 

u z > (j z: > z in •-« > ll m n z 


uID IK2 G j§ 
3 X Ll Z ffl Ll X h CC (j O © I 

m LU LL LU © Ll LU I - W Cl - . l 

xaGGZSinGOZGGGO-xi 

i/i Cn Cn Cn <z i-. z *-• Zj z> ' *■ 

J J J J Cl LL M u LL N ll 1 J LL N L 

LL Cl LL LL J U H| J U U Z U h 2 ; l 




Z ID Z 

lu <l > a: 

© —I Ci 3 

G Ll a: 


G > ICl 
z IU IU 
G G > 


Z F- 
> G X 
G G G 
LU © Z 


© LU Z 
©KM 

•• •• z 

X Ci G 


© Ll ID © © *■« 

CM rr rr CM in rr 


UJ U .1 l_l UJ 'J ■ 

rr rr cm rr cm 


N ll© rr rr 


CM (M CM CM CM CM 


rr rr cm in rr rr 


G t o CM ll 

rr rr CM r 

© 

u. 05 ,T lu r 

CM CO llJ CM L 

- x 2: r ’ J z ^ c 

r © rr rr rr r 

t-1 CM X 
f -0 Kj z 

LLlLUh 

CT -. IT. 


’-i fM Kj 

£&&& 

O' O' O' 


U Ci Ci Ci D Ci LU Ll © -* rr «.j5 it. Q LU th rr Ij’i [-. z O Ll CM ll© ll© U© ID CO ZCiO f-5 

aa 8Sa5i8§888&a8lji8BHWH£kikiU!fclii!!5lii88 

O* 0> O■ 0< O' O' a? o, it-, it. it, it. it, it, it, it, cr, cr, it. <t. 0> it, it, it, o. (T 'O' O’ - ' 0< O* 'O' O'- 


►••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••I 


G 

G F- 
LU LU 
C. I© 


o 

X c- 

G LL 
LU G 


g, lu 

a i- Ci 
Z LU o 

1-1 © o 


I© © O CL OS X X O Z _J O LL G 
Z -• Z G G - X G O , X G I— 
uQjuZIhEiQU'JULCiuZ'IZ 


JhJ X LL z © © —I r-1 N Mjvi 

Z © 'Z G Z z O O Z G Z © Z z ! 

G Z G Ci *“> G Z Z G G © Z G m ► 


UJ z 
z z 


Ll lL 
G Z 
G F- 

g m 


LU 

F— • 

g in 

Z LU 
LL Z 

z ^ 
Z F— 
G —i 
Q 
m cl 
o 

Cl o 
UJ 


LU 'Z 

z g 

G © 


'© -J 
G _l 

z 

in g 


UJ LU UJ 
Z Z h- © o 

gG'~*f-ggxgf- 
Ci c t m <z j uj 


C. Z Z O Z z 'X Z LU 

LU ll © Ll X © © CE 

Z Z Z © G Z O -• 
G m h h LO G Z 

H G Z © Z © G G G 
z GCl^-mZiXCCiCEH 
LL m Z G G © z z 

_ ' m H z 1L Z IE G CL 

O CE G 

\ LUZ3hhCECiCiZ 
►-* m ©GZGOZZ© 
= DCLzmniLicQ. 


CM Z 
CM + l 

© + z: 
m z - - 
iri ►- z 


Ji 


GGG-G-iZZZG 
Z Z Z X Z © h- h* H Z 
g g m g m e m in in 


0 l-fe 
1 feS 


% 

w ss 





5 


is^ 


G Z 

Z^ZGX'SizZZGGSzGZGGGG 

G 


IC| xIxIxIxtxiOIZiZDIDIlijSl 

M JU^J^JIJUfGHUhEOZUCCXU 




to 

in iTi *- w 


* 

> 

6 

I 

g 

I 

* 


in 

CE G Z 

G G ••• 


© © © © © © © © © © © © © ©i © © © © © © © © © © © © © © © Ci © © © © © © © © © © © © © © © © © © S © © © © © © © © © © © © © © © 

<9 <5 p r r P ? P P P »> @ - fj J B p N Of O' ®-N (2 t P Ml n ® O' ® - (N n ’» IT. M) N 05 cf. ® - R lo V K 3 N S S O - fj K. 4 u-i X K 5 O' o - 

'Li '£i n r-- r-- r-. r-- n r - r- r- r-- uj oj oj oj oj oj oj <x> oj uj ' 0 > g 'O* io> o- >t< g it. o- io> ©©©©©©©©©©—< «-* «-i —i »-i »-■ »-<»-« -h cj in cm cm >n cm in cm cm cm lo to 

LJ © © © © © © © © © © ©OO'jOOQ'SOSQEOQISC'OOCHSOHHrtHHHHHHrlHHHHHHHHHHWHrtrtHHH -r* Ji 14 U 


© © © 
cm to rr 
r o Kj t o 


© © © 
u~» 'Ci r 
to to to 


i g Ci cci r 

j © G IN l 


Ci Z C M -1 CM G CM CM CM 10 
G CM CM CM CM f- j tO tO tO G 


G ^ to 'Ll P - (E 'I Hi G 11 rt O 'i) |T-I CC u Li 11 £' f -0 G G G G G (O' G G CM L"j F'- Z Ci © tO tO \0 tO G (O' G L CM UO CO ill G n CM U'.i G CO iu u © CM li"J G P-- 
u“> CT 1 'O' (O' (O' < 0 ' 'O' u - ' (O' ' 0 > 'O' O' 'O' 'O' ( 0 > ( 0 * O' (O' (O' 'O' ' 0 > CP* ' 0 > 'O' 'O' 'O' (O' (O' (O' O' 'O ' 1 (O' 'O' (O' O' O' (O' O' 'O' O' 'O' O' (O' O' ' 0' 1 O' O' O' 0 > O' O' O' O* O' O' O' 0 * O' O' 


: g co cci cd 

: 1111 

, O' O' O' O' 


ID rr rr ’ 

i -z UJ W r 
j © rr y-i L 

j Cl LU 


Z G G 

S © © 

G G . 

O' O' O' 


Number 50 

420 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 25 











© 

D* 

© 


DC 

X 


© 

X 

X 

X 

© ■' 

© 

o 



I X 

h- 

3 

© z 

X 

6 

© UJ 

X 

z 

_ © »- 

r* 


© © 



U. LL LL U_ © _l 

poor in x <r 

X O. Cl ►> ~ X O 


a: uj in i/i in ifi in i/i in in © 

X O a: *-< GCiCiCjCiCi>-<£i 


X 2 

h- l-l 

* * * o 


in in 

hhw 

X O ttZIIh 
K X © > Q h D I- X 
U D LJ U u u X 
* * ♦ZOi'ZlLUJh 


O00OOOGGiGiOOGCjG0Ci&GiO6O 
O -* N R V R © N 0 j O'. © -« CA Vi rr If; © N 0 ) O'. © 

© © © © © © '/i © © N N f'- N N f'- N N N N CO 

M N N M M CA ('■l CU'I (N M N CN N M M N M N M M 


X 

M N X 

R V) O 

■f + •% 

© ' OCl _J 

H* 111 H _| 

X X £ X X X 

I- X Eo H X O 

UK' LU I— 


ID ID 
CO X CO CO X CD 

u u Ci O u u 


O Ci G G Gj O 
*T If) © N 0) O'- 
CO 0) CO 0) CO CO 
N IN N M CA CA 


5C X _j 

X X o 

X X 0 

-V- JJ 

1- X X 

»- X x 

K X ID 

P LU Z 

X K- 

X I- 

X t- \ 

X h- '■ 

ID 

ID 

O 

O 

XX© 

© X © 

© X © 

© X © 

Cl O c. 

Cl 0 Cl 

Ci 0 Ci 

Ci O Ci 




o © © © © © 

04 CA M M M M 

^ tr Hi -i 

T * 3 - \0 rr 


00 X T to x to 
to rt ca n't in 

©'t tn cr- 
R ^ v in 

© © © in rr 

R R to 'T in 

© © © © 
rr rr R to 

0^ X 
rr rr 

O©.h© 0 n 
CA't rr 'T 'T 



© © © © © © 

CA CA CA CA CA CA 

© X Vi CO 
tO *T V Vi 


o cr. m x x x 

*-« © *T X Ci 
rr R rr rr rr 

in rr Ci © in *r 
rr in rr R rr rr 

© © rr o in 

R R rrrrrr 

in f 
in in 

Vi X m rr o 
u'j rr LG u"j *t 

© 

CA 

© 

© 

© © © © © © 

CA N M N M CA 

t o Vi to X X 
in rr ||'J rj- 

in 

rr 

U«( 0 OMM 
'T rt T 'T 'T 'T 

rr © © CA ON 

UI rrRUDrr 

to on © K) X 
in rr rr in in rr 

m in x o in 
in rr rr rr rr 

R x 
in rr 

cr. in © © 
rr rr rr M M 

© 

§ 


M © —i ^ rr 

'f in *r u") in 

ON 

m 

—• 00 t0 tO CO Qj 
'T t 'T 'T Vt K) 

*-< li) O * 3 - rr 
rr rr "T u”j rr 

o © © © M no 
rr uo Vi in in rr 

x o in © m 
* r rr *t rr ui 

x c- 
rr rr 

© O © u*j Vi 
ca rr m rr y-i 

? to 

1 c, x © 

!t8S 

© ©©©©©O^H 

CA nCACA CA CA CA © 

? S Pi xr K © 

M -* 
rr © 

to to CO CO Vi f *-i 
rr 'T tO R *T In © 

rr rr in r © 
rr rr rr m R © 

uo u) u"j in M © «-• 
t t mr in M © 

© © X © © —* 

*r rr rr rr © 

f '- ft ^ 

rr R © 



8822SB2S 

(r. (T. <r, <t, cr. O'- <r> c 


n m on o> x x 

SSS2S2 

N fi fi S Ji 


SSS5S 

<JN (JN CD O' O'* 


0j O' ^ rr lj‘i ^ 

88S88g 

o', cr* cr- x- it. 


it. x ^ oit 

N Ngj 0 j C 


J x 

• o m m 

i x K w 

IX u LJ 


X Z X OS Z XI 
Cl ^ D UJO 
C. O X > XOht-l 
X U- I- LJ o (J Z I 
^ Z f- U 


Is 8 * 

L) K- CJ Ci (J 
Z X CO 
UJ Z) o I- 
I^OhhOX 


X|||8*S««SS8 ¥ a: 5; 

[XjuXuIuJlXQiiiC 
o o (J o o h Ci: 


J O Z X 
X 0 3 
JUJOZlil 

: n z h z 


X 

-r 


X X 

X 



Cl z 

K © 

X 


S 3 

10 

►H 0 

o 


© 

0 H 

z 


Z l/i 

UJ 

o 

o 

- 0 

X x 

X 


X c 

Ui 

X 


o 

X 1- 



Z 


z 

in 

10 >- 

t— x 

3 

2 

x x 

in <r 

r 


X o 

X I 

X 

X 

10 © 

x o 

X 

X 

3 © 


' u. 

h x in x 11 

s ICmjh o lu 
© X M Cl rr Z U"; 
n X O 10 Ci m o 


X X 
O © X 
Z TJ- -• 
HOJI 


CO X I- I-INI ^ lL. X 

“ ^ St ~ Sr Q Si-! p s’ X -L X LLUO X O © U f— f- UL © U Z Z X 

-L. X © X D X © uj Z o h O c H o > c X u E M z r - Ci © X X X X Ci © X *-< 0 3 X 

_ _ _ _ , J-M . . -■ -j u u • x ,; in Ci o -.x - x ■■ o -iz - x m k in c. -- x o o 

I 31 I X Ci III X XXUXUZXXLHUJX X XXXjZXZXOXXXX xxzxoxxxxxzoxoxo x 

t I— Ci Ci Cl Ci Ci J— 

Cj Ci Ci Ci Ci X _i >-*XXXXN*-*XX»- , X _i i j h-» X ►-> X _l - i X i-. f'J •-* X X X X *-i f J J h I iv I (V (T — , 

XXXXXZ O ZhOOhZDf-Z^E O lZ©l-3l-X5l6z5xZ3h : ZZZXZl3HZZZ6H O 

c. i_i l_j i_i Ci x £_ in _j Ci in *-> a. in *-■ - ►> x in in z m z m _i z -i z *-* z o *-• z m m h q *-> j z m _ in m z in x 


KL X 3 
X z X X o o 
Ci H © > © X o 


I ► 
h x © o : 

X Cl © X - 

l/i Cl -- X c 

X X X Z O c 


* X X X X N -- X X ► 
huOhZDI-E: 

: m _i Ci ci z in *-•: 


X 3 X 

in 

X X X X Ci z 


X3XXXH 
O O O O O X 
X z X X X X 


© © © © c 

I--I Vi V U‘| '• 

CO CO CO CO c 


) © © © © © © © c 

) — ( a Vi’t u‘i o r-- c 

'■ O' O. 0 - . Cr- O'. O- X- C 


)©©©©©© 
:> -• 'N Vi *T li"' o 
J © © © © © © 
J N M in n CA CA 


© © © © c 

K CO X- © - 

© © © *“l - 

•N *N C l IN c 


) ©©©©©©©©©©©© 


I— X 
X 

* * * X 

©©©©©© 
T U'J VO f'- © X. 

uo in in u - ) in in 

C>l CA c>l C-l CA N 


I Vi '■£> '0 O »D C 
I IN N CA CA CA ( 
) O O O O o C 

•• X- x. x. X* x. c 


J X X IN li I f'- 
I c-i cj r j Vi Vi 

) O O o o o 
O '. X. X' x> x< 


X Cl X (N IN 

r i p to tt rr 


o x x x X X' © X XX© X' X' H X' O O X" X © 

X" X" X X- X X- CL X- Vi vO © X- f'- © f'- X- © X- X- © 

CA CA X CA X iN ^ X © O CO X X iN X (N Vi O Vi X iN © X iN O N O X- N 

IN CA Vi Kj tO tO CA rf iN rt CA K X © Vi Vi CA S O X © M R R ©MONK) 


CO E? Z *-• X- 
X ['. © c x o 


■ y r : y.. uj 


Page 26 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

421 





I/I 



0 



0 



LD 




CD 

CD 

Ki 05 

Ki 

n 


+ 

+ LD 

1- l/i 

_l \ 

Z> f— 

1- -i 

H _l 

1- 


X X 0 

X X 0 

L- G D 

H ID 0 

h- ID Xi 


o o 
cd 0 co cd 0 m 
DUGGOD 


GiOiSSISCi 
rr UJ 0 T'- 05 O'- 
rr £ rr T rr rr 
ro w Ki ki w kj 


-V- V 


v V 

y 

P ID X 

P LD G- 

P LD N 

K* 

ID h- % 

U 1 - ••• 

LD h- \ 

ID 

O 

0 

0 

... 

& 0 05 

G 0 CO 

G 0 G 

G Z 

GOG 

GOG 

GOG 

Ci G 

X 


N 


H 

P 

h 


LD 

LD 

LD 


h- 

h- 

h- 

* 

0 0 0 

0 0 0 

0 0 0 

0 0 0 

0 Z2 C D 

Kj rT U"j 

G T'- CO 

cr. o ^ 

ii - j in y-i 

y5 h) Kj 

l~j in y-j 

y-j G u5 

Kj Ki Kj 

Kj Kj Kj 

Kj Kj Kj 

Kj Kj Kj 


tjH in (n o 10 kj in '■[) *-< conoid kj in ^ cr. cd o w m in 0 cd o in kj u - j «-• 

iioin© m rr M rr y-j *3- © in o in m o in rr cd rr in © y-j t od rr y-j rr © y, rr cd t y, 7 o 

G G «h DlUntliJH NCOh CO 0 ^ CDO*-t 05 C 

CD CD rj- y-j in •■& •■£) p CD 05 <55 CC Cu CD U G^UJ U_ L 

fcfcfc fc&fc&fcfc fcfcfc fcfcfc fcfcfc H 


OIO-.iT'^DUJCClD- — - 7 ;*^ 
•u *-< G CC CD CD O'* G G CC xu 1 D G 
'iccGcrocroaiuGDJixu. 
O'. O'- CT* O'- O. O'. O', o'. O’. O', o - . O'. O'. 

Ct! - H OOIZH'J 
thIDhZ hl-hhhh 
2! U'i (J U'l X *-« D5 X x - v - x 
UjZCOljJiZJlJJlillJjlJjUJlJJ 
OuHZZGOChHKI-Hh 


OCQHmj^HHHHrtHH 

H u O I in u CD 0 u 05 ’T 0 

O I 0 IT u 'I u u u G OJ li. 0 . 

CD 0*. 0 O'. O'. O'. 0-. O'- 0-. O'. O'. O' O'. 

O iC N ¥ IOZ w > 

li...l3CJZOHh;ht^£!7. 


■ o g D5 0 o-. g cr. t-j kj ^ r* ^ r! 

G 1 I 1 ^ O O'* O'- f'- 0 O'. D5 CD LD CE 

'I G O O U u U Z ill G OJ ID li. 

0> Cl 0 0 O'- O'. O'. O'. O'. O', o. o- o. 

H h- I- T L J fC X 

— 1 ozhcchhi-hh 

O U X *-i OJ 'I X X 5-0 X X 

X0l/llJ-G0O'if— GGGLDG 
uuUJZiLQCliihhHH-h 


f u lCi I cu 0 N cd f-- *1 rl r? 

0-. 0 y5 ^ CD O'J 05 CD f'- rr 0 j- 1 w 

uOuuIiIuuOjuOJOJL 

o. CD O'. O', o. o. o. O', o. O', o. cr. o. 

X CC T I u Kj OJ X G 3 
Zl-ul-Dul- U'l hhhhh 
H J G h O'l h I U X X X X .X. 

X Q Z G U'l 0 0 D. G G G G G 

G<-jG_JZ:00U'lh-H-l-l-f- 


U 0 CD CD in 0 0 <N CD IE E 1 

it. ,x it. a id 0 rr r-'j cd g 0 * jj 

UU0U0LU0ULUDGDO. 

o. cr. CD O'. O'- cr. o. O'. O'. O'- O'. O'. O'. 

I- Kj U X 0 C D G *~f CL p. 

0 Z 0 O O G I— h- H H H 

G _j U'l > U'l CC H ZX X X x x 

G O 0 LD Oj D_i G G G G G ID 

£ u D x E Z G l'l h I- h I- I- 


0'. O'- Kj G 0. G 111 G u Z H Z ^ p 

3 r-- t u 0 Kj 0 rr 0/0 u w y N 

0 0 0 05 0 CJ 05 O CD G G LD 0 I 

O'. O'. O'- O'- O'. O'. O. O. O'. 0. 0- O'. O'. O'. 

CD CN H CD CD 

hhhDOI-ODKhhhhJ 
0 Z O'l 0 O'l X 0 Z X X x x .x. 0 

U u j 2 L"'i DiXOJOJOJDOJOII 
I O Cj w E Z 0 tl H h H h h h 


0 

0 

0 


CD 0 

CD _| 

CD 0 

CD '■ 

Ki G 

Kj G 

Kj _J 

Kj h 

+ 

+ 

+ •*. 

+ G 

LO 

**> l/i 

JZ h* 

—J U'l 

h 

h M 

H LO 

►“ z 



X X >-i 

x 5<- G 

LD ►-> 

hUi 

h- G G 

y- g z 

1- '■ 

G h- • . 

g 

G 1- 


0 0 0 0 0 0 

1'- CO O’- 0 , ~ i CD 


- rr 0 xr rr cd m rr rr 0 rr rr rr rr -t 0 


G r-l 

o. 

0 

Cj G 

UGh 

f'- 05 -i 

N CO 

in 0 -h 

(j G H 

U G r-l 

ill ij H 

L 

sy 

it. rr! 

s 

G G 

Ul. g 0 

Q 0 G 

•h 04 

G G G 

Kj Kj rr 

G G LU 

rT rr 0 

G G G 

N f'- CO 

G G LU 

05 05 0 

LU G G 

0 CC u 

G G G 

G G G 

G G G 

[j 

O'- 

O'. 0. (t. 

O'. CT 1 . O'. 

O', cr- o'- 

O'. O', jt. 

O'. O'" 'T 1 

o*. O', o - . 

Cr. O'* O'* 

Cr. O'* O'- 

0 


Number 50 

422 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 27 










FRENCH 

TRES BIEN! 

BICYCLE=LE VELO 

MAIS NON! 

SUBWAY=LE METRO 

HOUSE=LA MAISON 

ROOM=LA CHAMBRE 

RABBIT=LE LAPIN 

HELICOPTER=L' HELICOPTERE 

FLOWER=LA FLEUR 

MUSHROOM=LE CHAMPIGNON 

SNAIL=L' ESCARGOT 

WINE=LE VIN 

TRAIN=LE TRAIN 

CHEESE=LE FROMAGE 


LISTING 


PROGRAM TUTOR 

THIS IS A PROGRAM TO PROMPT THE STUDENT TO SPELL WORDS IN A 
LANGUAGE WHEN GIVEN A WORD IN A DIFFERENT LANGUAGE. 

BY: GARY D. GAUGLER 5706 SEASCAPE. CITRUS HEIGHTS, CA 95610 

IMPLICIT INTEGER (A-Z) 

COMMON LINE(80),KOL,MXKOL 

DIMENSION LANG1(20),LANG2(20),ERROR(20),IANSC20) 

DIMENSION LANG(20),JPROMP(5),CORECT < 20),NCOREC(20) 

DATA CARAT,SPACE / 1H~, 1H / 

DATA JPROMP /2H W.2H0R.2HD ,2HF0,2HR / 

. FETCH OUR LANGUAGE FILE IF IT EXISTS 

OPEN (UNIT=2,NAME='DK1:FRENCH.DAT',TYPE='OLD', 

1 ACCESS*'SEQUENTIAL') 

DIRECT=0 !0=ENGLISH—>FOREN 

MXTRY=2 

TYPE 10 

FORMAT (IX,"DO YOU WANT TO ENTER FOREIGN FOR ENGLISH? (Y/N) ',*> 

READ (7,20)ANSWR 
FORMAT <A1> 

IF (ANSWR. EQ. ' N ' ) DIRECT= 1 ! FOREN—>ENGL I SH 

. GET FILE'S LANGUAGE BASE AND MESSAGES 
CALL INPUT 

CALL NAME(LANG,LENLAN) 

CALL INPUT 

CALL NAME(CORECT,LENOK) 

CALL INPUT 

CALL NAME(NCOREC,LENBAD) 

. READ A WORD-PAIR 
CALL INPUT 
FORMAT (20A1) 

. CLEAR-OUT THE ARRAYS 
DO 120 1=1,20 
LANG1(I)=SPACE 
LANG2<I)=SPACE 
ERROR <I)=SPACE 
IANS(I)=SPACE 

. GET LANGUAGE WORD 
CALL NAME < LANG1,LEN1) 

. NOW GET THE SECOND LANGUAGE WORD 
CALL NAME(LANG2,LEN2) 

. NOW PRESENT A WORD TO THE STUDENT 
NTRY=0 

IF (DIRECT.EQ.1) GO TO 350 !FOREN—>ENGLISH 

KOL= 1 

DO 325 J=1,LENLAN 
LINE(KOL)=LANG(J) 

K0L=K0L+1 
DO 330 J=1,5 
N2=JPROMP(J) 

N1=N2/256 
N2=N2-256*N1 
LINE(KOL)=N2 
LINE(KOL+1)=N1 
K0L=K0L+2 
DO 335 J=1,LEN1 
LINE(KOL)=LANG1(J) 

K0L=K0L+1 

DO 340 J=KOL,40 

LINE(J)=SPACE 

TYPE 40,(LINE(J),J=1,40) 

FORMAT (IX,'TYPE THE ',40A1> 

GO TO 400 


tutor : 

A 

FOREIGN 

LANGUAGE 

VOCABULARY 

TRAINER 

by Gary D. Gaugler 


This program is designed to be the 
basis of a foreign language instruction sys¬ 
tem. When run on a single-user system, 
the user can practice, learn and build a 
foreign language vocabulary. When in¬ 
stalled on a multi-user system, many stu¬ 
dents can simultaneously use the pro¬ 
gram. Further, each student user can be 
practicing a language different from the 
other users. 

The program presents a foreign lan¬ 
guage word to the student and waits for 
the student’s response. The words are 
retrieved from a disk file which contains 
words in English and their associated for¬ 
eign equivalent. The file also contains a 
header indicating the foreign language, 
a character string to be displayed when a 
correct response is made and a string 
which is displayed when an incorrect 
response is made. The program also per¬ 
mits the student to practice English- 
foreign or foreign-Enghsh. The student 
replies to the program’s prompt for the 
desired direction. 

When a word is presented, the pro¬ 
gram checks each character of the stu¬ 
dent’s response for correctness. For each 
character which does not match the 
correct response, an up-arrow (t) is 
placed below it, indicating an incorrect 
character response at that location. The 
student has one more chance to respond 
before the program moves on to the next 
word. 

The program, called TUTOR, is writ¬ 
ten in PDP-11 FORTRAN-IV for RT-11. 
This version of FORTRAN is very similar 
to FORTRAN-66 so one should have 

Gary D. Gaugler-5 706 Seascape Court, 
Citrus Heights, CA 95610 


Page 28 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

423 









little difficulty adapting it to any system 
which has a FORTRAN compiler. 

Included with the program’s listing is 
a sample language file for French. Using 
this as an example, other language files 
can be made. The first line defines the 
language for which the specific file is in¬ 
tended (the example is FRENCH). The 
second line will be displayed verbatim 
when a correct response is made. The 
third line will be displayed verbatim when 
an incorrect response is made. The re¬ 
maining lines are the English-foreign 
word pairs organized as: English=foreign. 
The equals sign delimits the English and 
foreign words. Embedded spaces are sig¬ 
nificant and must be included for a cor¬ 
rect response. 

I would be pleased to provide a floppy 
copy of the program to those sending a 
formatted diskette (RX-01 or RX-02) 
and return postage and container. I also 
welcome communicating with others 
interested in PDP-11/LSI-11 hardware 
or software. □ 


0054 

C 

350 

TYPE 50 » (LANG2( I), I * 1,LEN2 ) 

0055 

50 

Q 

FORMAT (IX*"TYPE THE ENGLISH WORD FOR ',20Al/> 


c.... 

CHECK FOR CORRECT WORD & SPELLING 

0056 

400 

READ (7*35)IANS 

0057 


JERR-0 

0058 


DO 425 J*1 * 20 

0059 


IF (DIRECT.EQ.1) GO TO 410 

0061 


IF (LANG2(J).EQ.IANS<J) ) GO TO 425 

0063 


JERR=1 

0064 


ERROR(J)*CARAT 

0065 


GO TO 425 

0066 

410 

IF (LANG1(J).EQ.IANS(J)) GO TO 425 

0068 


JERR-1 

0069 


ERROR(J)=CARAT 

0070 

425 

q 

CONTINUE 


C. . . . 

REPORT IF OK OR AN ERROR 

0071 


IF (JERR.EQ.1) GO TO 500 

0073 


TYPE 60 » (CORECT ( J ), J=1 , LENOK ) 

0074 

60 

FORMAT ( IX,//,1X.20A1/) 

0075 

q 

GO TO 110 


C. . . . 

ERROR 

0076 

500 

TYPE 65 , ERROR ,( NCOREC < J ), J=1 , LENBAD ) 

0077 

65 

FORMAT ( 1X.20A1//,1X,20A1/) 

0078 


NTRY*NTRY+1 

0079 


IF (NTRY.LT.MXTRY) GO TO 320 

0081 


GO TO 110 

0082 


END 


Thanks go to Carol Newhouse for sup¬ 
plying the French vocabulary. 


SUBROUTINES 


0001 

p 

SUBROUTINE INPUT 


L 

c 

p 

THIS SUBROUTINE READS ONE LINE FROM THE DISK FILE 

0002 


COMMON LINE(80),KOL * MXKOL 

0003 

c 

DATA IBL /1H / 

0004 

c 

KOL= 1 


c... . 

READ A LINE FROM THE LANGUAGE FILE 

0005 


READ (2,30,END*900)LINE 

0006 

30 

p 

FORMAT (80A1) 


L 

c... . 

DETERMINE THE LAST USEFUL COLUMN 

0007 


DO 200 1*1,80 

0008 


IF (LINE(I).EQ.IBL) GO TO 200 

0010 


MXKOL*I 

0011 

200 

CONTINUE 

0012 


RETURN 


L 

c.. . . 

END OF DATA FILE 

0013 

900 

STOP 

0014 


END 


Gary Gaugler is currently a computer 
system designer at McClellan AFB, CA. 
His background includes hardware and 
software design, analysis and construc¬ 
tion. He was previously an IC design en¬ 
gineer and system architect at the Air 
Force Avionics Laboratory, Wright - 
Patterson AFB, OH. He was involved in 
IC development, microprocessor design 
and development and software engineer¬ 
ing. His interests are IC design, computer 
simulation of electronic circuits and hard¬ 
ware design. 


0001 


SUBROUTINE NAME(IOUT,NCHARS) 


c 

c 

THIS SUBROUTINE READS A WORD FROM THE INPUT LINE 


c 

INTO THE ARRAY PASSED AS AN ARGUMENT (IOUT). THE LENGTH 


c 

p 

OF THE WORD IN CHARACTERS IS RETURNED IN 'NCHARS'. 

0002 

L 

p 

COMMON LINE(80),KOL,MXKOL 

0003 

L 

DIMENSION IOUT(20) 

0004 

p 

DATA ICM.IEQ /1H,, 1H=/ 

0005 


NCHARS=0 

0006 


IK0L=1 


c 

c.. . . 

BUILD THE WORD IN 'IOUT' UNTIL TERMINATOR ENCOUNTERED 

0007 

100 

IF (KOL.GT.MXKOL) GO TO 900 

0009 


IF (LINE(KOL).EQ.ICM) GO TO 900 

0011 


IF (LINE(KOL).EQ.IEQ) GO TO 900 

0013 


IOUT(IKOL)=LINE(KOL) 

0014 


K0L*K0L+1 

0015 


IK0L=IK0L+1 

0016 


NCHARS=NCHARS+1 

0017 

p 

GO TO 100 


L 

c.. . . 

END OF WORD FIELD 

0018 

900 

K0L=K0L+1 

0019 


RETURN 

0020 


END 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


424 


A/ 

END 

Page 29 



INTERFACING THE WH14 PRINTER 

to your microcomputer’s serial port 
is simpler than you think 

by Lachman Sippy 


What is wrong with this relatively inexpensive feature 
loaded printer? I ask this question because I have read so many 
articles or letters from disappointed or frustrated owners of 
the WH14.1 will describe my own experience and tell you how 
to get the most out of it. 

I acquired a WH14 printer at a bargain price from the 
recent Microage redistribution list. According to them, it was 
in perfect working order except that it was missing the RS232 
cable and it was out of warranty. Since the serial port on 
my own system does not have handshaking,* I wired only 
four RS232 signals, namely RS2320UT(2), RS232IN(3), 
signal ground(7) and protective ground(l). Several off-the- 
shelf serial I/O boards do not use the handshaking signals 
including Morrow’s Switchboard, North Star serial ports, 
3P + S. 

To my delight, the printer worked. However, above 300 
baud, it became evident that one must use handshaking. 
I was determined to try all possible ways to avoid that so I 
tried delays after C/R, after each character output, but to no 
avail. It seemed that I have no choice but to use the RTS(4) 
or the DTR(20) RS232 signals to provide for handshaking, 
via one of the parallel ports on my system. On reading the 
manual again, I noticed that the WH14 also provided hand¬ 
shaking via the output side of the same serial port. Simple, 
when the printer is not ready for any reason it sends a 
CTL-S(13H), and when ready it outputs a CTL-Q(llH). 
These signals are evidently sent on a continuing basis at the set 
baud rate. I programmed a new output driver to test the input 
status and if a character is received it tests for a 13H. If a 13H 
is received I wait in a loop until an 11H is received before 
sending the character to the printer. With this simple driver the 
printer works at all the available baud rates without losing any 
data. As the reader will note, having this ability to do the 
handshaking with software via the same serial port makes the 
WH14 extremely versatile, and one should have no problem 
connecting to any microcomputer. 

The WH14 operations manual indicates that it is normal 
for the printer to occasionally stop printing even though 
the printer is not out of paper, there is no paper jam, and the 
print head is still cool. By simply using the on-line key (re¬ 
leasing the key and then depressing it again) the printer is 
restored without losing any characters. This is true and it 
works with the driver that is mentioned here. However, I 
wish that Heathkit or Zenith would do something about it. 
With all the intelligence in the printer, a modification to then- 
software in ROM, the printer should reset itself. 

I should mention an additional problem that I encountered 
with my printer. It turned out that when my printer stopped 

* The term “handshaking” refers to a pulse exchange be¬ 
tween the CPU and asynchronous communicating peripheral 
device/s. Handshaking establishes synchronization and ensures 
proper operating. 


Lachman Sippy - Box 1107, 2000 Center Street, Berkeley, 
CA 94704. 


for no apparent reason, my use of the on-line key as de¬ 
scribed in the previous paragraph had no effect. In fact, 
when the printer stopped, I was unable to recover even if 
I powered off. My diagnosis of this failure led me to believe 
that I had a problem with the baud rate generator on the 
WH14’s 8250 UART. I determined this by querying the input 
from the WH14. What I would receive was strings of l’s and 
0’s in various combinations. Since I was not absolutely sure 
that it was a baud rate problem, I was about to take it to the 
local Heathkit service center. The cost to fix it would be 
$65.00 plus parts. The price of a replacement 8250 was 
approximately $14.00 from Heathkit. I decided to take a 
chance and bought one in spite of the fact that they said they 
did not take back ICs once sold, even if it was defective, 
because it was sure to be good. I was surprised at the way 
the salesman handled the MOS chip, probably out of sheer 
ignorance. Anyway, after I replaced the 8250 on my printer I 
had no further problems. 

To sum up, it appears that the WH14, due to its versatility, 
is a good buy for the price, assuming that it proves to be reli¬ 
able in the long run. The sample code for the driver follows. 
The code assumes serial port on the Morrow’s Switchboard 
with the I/O base address set to 20H, and the data to be out¬ 
put in the C register. 

STAT = 22H 

DATA = 21K 

PDA = 40H 

THE * 80H 

NPAR = 7FH 

CTLS = 13H 

CTLQ = 11H 


0000 

DB 22 

DRVR: 

IN 

STAT 

;Get input status 

0002 

E6 40 


ANI 

RDA 

;Data avail? 

0004 

CA 0000 


JZ 

DOUT 

;No, continue 

0007 

DB 22 

DRVI: 

IN 

STAT 

;Get status again 

0009 

E6 40 


ANI 

RDA 

;Data avail? 

000B 

CA 0400 


JZ 

DRVI 

;Wait 

000E 

DB 21 


IN 

DATA 

;Get the char rec'd 

0010 

E6 7F 


ANI 

NPAR 

;Strip parity, if any 

0012 

FE 13 


CPI 

CTLS 

;CH/-S? 

0014 

CA 0400 


JZ 

DRVI 

;Yes, wait till printer ready 

0017 

FE 11 


CPI 

CTLQ 

;CTL~Q? 

0019 

C2 0400 


JNZ 

DRVI 

;No, not ready yet 

001C 

DB 22 

DOUT: . 

IN 

STAT 

;Get status 

00 IE 

E6 80 


ANI 

TBE 

;Port ready for output 

0020 

CA 1C00 


JZ 

Dcxn 

;No, wait 

0023 

79 


MTV 

A,C 

;Mcrve char to A-reg 

0024 

D3 21 


an 

DATA 

; CUtput char to printer 

0026 

C9 


RET 



The code 

can 

easily 

be modified 

for any senai port by 


changing the port addresses and the status bits. The reader 
should also note that when the power is off on the WH14, 
input data on the serial port will be a 00H. This fact can be 
used to print a message on the console device. Also, if one 
looks at the status, one will see an overrun condition. This 
can be ignored. □ 


Lachman K. Sippy is currently with the University of 
California in a computer planning capacity. He has worked 
in (he past for both Boeing Airplane Company and IBM. 
He is also the Director of Innovative Interfaces, Inc., a 
Berkeley-based company which has pioneered the use of 
microcomputers in large libraries. 


Page 30 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

425 




PROGRAM 

DOCUMENTATION 


by Freeman L. Moore 


Computer programming: is it merely 
writing a set of instructions to accomplish 
a specific task? I would hope we agree 
that writing the set of instructions can 
be a very involved process—working 
with such things as clarifying the problem 
statement, developing an algorithm, flow¬ 
charting, testing, debugging, documenta¬ 
tion, and writing the code or instructions. 
Quite often, one considers a program com¬ 
pleted when it produces the correct re¬ 
sults. This may be acceptable for pro¬ 
grams which are used only once; but 
for production jobs which are kept and 
used again, good documentation is essen¬ 
tial. 

Documentation of a computer pro¬ 
gram should consist of the problem state¬ 
ment, operating instructions, flowcharts 
and sample input and output, among 
other items. Some features are part of 
what might be referred to as a “user’s 
manual,” while others belong to a “pro¬ 
grammer’s manual.” Ideally these two 
manuals will be kept separate since it 
should never be assumed that the user is 
capable of programming, and that the 
programmer tends to forget the needs 
of the naive user. 

The user’s manual should include 
sample input; sample output; anticipated 
errors, their meaning and possible correc¬ 
tions; and, purpose of the program. 
Sample input is necessary to provide the 
user with an idea of what the program 
expects, while the sample output will 
reinforce the user’s belief in the pro¬ 
gram by having results to compare. 
Including a directory of errors should 
not be considered discouraging to the 
user. Such a directory lets a user know 
the program is capable of detecting 
errors without causing unknown conse- 
qences. If an unexplained error message 
should appear, then expand upon it in 

Freeman L. Moore-Computer Science 
Dept., Central Michigan University, Mt. 
Pleasant, MI 48859 



Page 32 

426 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 








69 

0019 

CE 

02 

08 

ERR2 

LDX 


#MERR2 

CAN’T OPEN INPUT FILE 

70 

001C 

20 

03 



BRA 


ERROUT 


71 

001E 

CE 

02 

23 

ERR3 

LDX 


♦MERR3 

CAN’T OPEN OUTPUT FILE 

72 

0021 

BD 

05 

09 

ERROUT 

JSR 


PSTRNG 


73 

0024 

CE 

01 

B9 


LDX 


♦FINAL 

PRINT FINAL MESSAGE 

74 

0027 

BD 

05 

09 


JSR 


PSTRNG 


75 

002 A 

7E 

71 

03 


JMP 


DOS 

AND RETURN TO FLEX 

76 





* 





77 





* START 

PROGRAM BY OPEMI 

MG FILES 

78 





* 





79 

002D 

CE 

01 

88 

XTRl 

LDX 


♦INTRO 

PRINT STARTING MESSAGE 

an 

0030 

BD 

05 

09 


JSR 


PSTRNG 


81 

0033 

CE 

02 

B 8 


LDX 


#FCBIN 


82 

0036 

an 

71 

27 


JSR 


GETFIL 

PROCESS FILE SPEC AS INPUT FILE 

83 

0039 

25 

D9 



BCS 


ERR1 

SYNTAX ERROR? 

84 

003B 

CE 

02 

B8 


LDX 


♦FCBIN 


85 

003E 

86 

03 



LDA 

A 

#3 

SET EXT FOR .BAS FILES 

86 

0040 

BD 

71 

2D 


JSR 


SETEXT 


87 

0043 

C6 

09 



LDA 

B 

#9 

MUM OF CHARS IN FILENAME 

88 

0045 

FE 

02 

A5 

COPY 

LDX 


CHAR90 

INPUT FILENAME POSITION 

89 

0048 

A6 

on 



LDA 

A 

o,x 

GET CHAR 

90 

0 04 A 

08 




1 NX 




91 

004B 

FF 

02 

A5 


STX 


CHAR90 


92 

004 E 

FE 

04 

F 8 


LDX 


PTR1 

TRANSFER F1L^ NAME 

93 

0051 

A7 

00 



STA 

A 

9,X 

TO FCBREM 

94 

0053 

08 




1 NX 




95 

0054 

FF 

04 

F 8 


STX 


PTR1 


96 

0057 

FE 

04 

FA 


LDX 


PTR2 

TRANFER FILE MAMF 

97 

005 A 

A7 

00 



STA 

A 

0,X 

TO FCBEXT 

98 

005C 

08 




1 NX 




99 

005D 

FF 

04 

FA 


STX 


PTR2 


100 

0060 

5A 




DEC 

B 


DECREMENT CHAR COUNT 

101 

0061 

26 

E 2 



BNE 


COPY 

REPEAT UNTIL COPIED 

102 

0063 

CE 

02 

B8 


LDX 


♦FCBIN 

OPEN FILE 

103 

0066 

86 

01 



LDA 

A 

♦ READ 

FOR READING 

104 

0068 

A7 

00 



STA 

A 

0,X 


105 

006 A 

BD 

78 

06 


JSR 


FMS 


106 

Q06D 

26 

AA 



BNE 


ERR2 

ERROR IN OPEN PROCESS 

107 

006F 

CE 

03 

78 


LDX 


♦FCBREM 

OPEN REMARK FILE 

108 

0072 

86 

02 



LDA 

A 

♦WRITE 

FOR WRITING 

109 

00 74 

A 7 

00 



STA 

A 

o,x 


110 

0076 

BD 

78 

06 


JSR 


FMS 


in 

0079 

26 

A3 



BNE 


ERR3 

ERROR RETURN? 

112 

007B 

CE 

04 

38 


LDX 


♦FCBEXT 

OPEN CODE FILE 

113 

007E 

86 

02 



LDA 

A 

♦WRITE 

FOR WRITING 

114 

0080 

A7 

00 



STA 

A 

0,X 


115 

0082 

BD 

78 

06 


JSR 


FMS 


116 

0085 

26 

97 



BNE 


ERR3 

ERROR RETURN? 

117 





* 





118 





* M A 

1 N 


P R 0 C E 

SSING LOOP 

119 





* 





120 

0087 

BD 

02 

83 

CONT 

JSR 


BCHAR 

GFT NEXT NON-BLANK CHARACTER 

121 

008 A 

70 

02 

A4 


TST 


EOF 

OUT-OF-DATA? 

122 

008D 

27 

03 



BEQ 


CONTI 

NOT YET 

123 

00 8 F 

7E 

01 

53 


JMP 


DONE 

YES - TERMINATE LOOP 

124 

0092 

CE 

00 

03 

CONTI 

LDX 


♦NUMBER 

BEGINNING OF STATEMENT 

125 

0095 

C6 

01 



LDA 

B 

♦ TRUE 

SET TO TRUE 

126 

0097 

D7 

11 



STA 

B 

SNEW 


127 

0099 

D 7 

12 



STA 

B 

RNEW 

TEST FOR STATEMENT # 

128 

009B 

81 

30 


CONT 2 

CMP 

A 

♦ ’0 

LESS THAN ZERO? 

129 

009D 

2D 

OC 



BLT 


NEXT 

YES-GET OUT 

130 

009F 

81 

39 



CMP 

A 

♦ *9 

GREATER THAN NINE? 

131 

00A1 

2 E 

08 



BGT 


NEXT 

YES-GET OUT 

132 

00A3 

A7 

00 



STA 

A 

0,X 

SAVE AS STATEMENT NUMBER 

133 

00A5 

08 




1 NX 




134 

00A6 

BD 

02 

83 


JSR 


BCHAR 

GET NEXT CHAR 

135 

00A9 

20 

F0 



BRA 


C0NT2 

REPEAT PROCESS 

136 





* 





137 

00AB 

6F 

00 


NEXT 

CLR 


0,X 

CLEAR END-OF-NUMBER 

138 

00AD 

20 

03 



BRA 


TYPE 


139 

00AF 

BD 

02 

83 

TYPEA 

JSR 


BCHAR 

GET CHAR 

140 





* 





141 





* MOV/ DETERMINE STATEMENT TYPE 

142 










143 





* 





144 

00B2 

97 

0D 


TYPE 

STA 

A 

SAVE 

SAVE 3-LETTER 

145 

00B4 

BD 

02 

83 


JSR 


BCHAR 

KEYWORD 

146 

00B7 

97 

0E 



STA 

A 

SAVE+1 


147 

00B9 

BD 

02 

83 


JSR 


BCHAR 


148 

00BC 

97 

OF 



STA 

A 

SAVE+2 


149 

00BE 

C 6 

01 



LDA 

B 

n 

CONSTANT ONF 

150 

ooco 

96 

0D 



LDA 

A 

SAVE 


151 

00C2 

81 

52 



CMP 

A 

♦ ’R 

TEST FOR R-E-M 

152 

00C4 

26 

1C 



BNE 


STMT 


153 

00C6 

96 

0E 



LDA 

A 

SAVE+1 


154 

00C8 

81 

45 



CMP 

A 

#’E 


155 

00CA 

26 

16 



BNE 


STMT 


156 

OOCC 

96 

OF 



LDA 

A 

SAVE+2 


157 

00CE 

81 

4D 



CMP 

A 

#’M 


158 

00D0 

26 

10 



BNE 


STMT 


159 

00D2 

86 

01 



LDA 

A 

♦ TRUE 

FOUND ONE! 

160 

00D4 

97 

10 



STA 

A 

REM 

SET REM SWITCH ON (TRUE) 

161 

00D6 

DE 

09 



LDX 


RCOUNT 


162 

0008 

BD 

71 

30 


JSR 


ADDBX 

INCREMENT REM COUNTER 

163 

00DB 

DF 

09 



STX 


RCOUNT 


164 

00DD 

CE 

93 

78 


LDX 


♦FCBREM 

SET FILE - |n (continued) 


the user’s manual as well as provide some 
clues on how to correct the mistake. 

The programmer’s manual is directed 
towards the maintenance programmer, 
one who is consulted when the program 
fails to execute correctly, or when 
modifications are desired. Items of inter¬ 
est to the maintenance-programmer are 
commented source listing of the program, 
flowcharts, data file descriptions and 
layouts, and special or unique processing 
needs. 

Data file specifications and layouts are 
crucial if the application is to be modified 
to retain additional information, as well 
as being an aid if file dumps are taken to 
verify the contents of the existing file. 

Flowcharts are an area receiving mixed 
reactions from progammmers. Some 
proponents consider the flowchart essen¬ 
tial to the documenation package, where¬ 
as others are content with a well-docu¬ 
mented listing. Even the form of the flow¬ 
chart varies from the ANSI version to 
the structured version (see Figure 1). 
Alternatives to the flowchart are possible, 
such as pseudocode, HIPO charts, and 
even computer generated flowcharts. 

Comments are the English-like state¬ 
ments included with the language state¬ 
ments for the programmer’s benefit, 
not the computer’s. It appears that all 
computer languages have some feature 
which allows for comments, such as the 
C of * in column one used by 
FORTRAN, the REM statement for 
BASIC, the — for ADA, etc. If properly 
done, comments can provide a great deal 
of the documentation needed for a pro¬ 
gram. For example, it is common practice 
to include a header block of comments at 
the top of a program describing the 
purpose of the program, the author, 
date of last revision, etc. Even throughout 
the code, segments of comments can be 
introduced, thus visually separating por¬ 
tions of the program into individual units 
of code. Comments are intended to en¬ 
lighten the reader, not duplicate his 
knowledge. For example, consider the 
following sample assembly statement: 

ADD ONE ADD ONE TO THE ACCUM¬ 
ULATOR 


It is obvious from the instruction what is 
being done, so that the comment is 
wasted. A more meaningful comment 
might be the following: 

ADD ONE INCREMENT THE CARD 
COUNTER 

In BASIC, the remark (REM) state¬ 
ment is used to denote a comment. Most 
versons allow multiple statements per 
line, separated by a special character, 
generally the colon ( : ). With this ability, 
it is possible to write a statement and 
immediately follow it with a comment, 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 33 

427 




much like the assembly example shown 
earlier. 

The problem with remarks in BASIC 
is that they generally require memory 
space. The common versions of BASIC 
for microcomputers are interpreters. 
An interpreter normally keeps the source 
program in memory and, upon demand, 
decodes the statement and executes it. 
If a program were heavily commented, 
it would occupy considerably more 
memory space, as well as slowing down 
execution, than a comparable non- 
commented version. Thus it is quite easy 
to write a large program for a small 
machine and not have enough available 
memory space to load the program. One 
reaction would be to remove the com¬ 
ments to conserve space. Since this re¬ 
moves necessary information, it should 
not be done. What are the alternatives? 
Consider separating the comments out 
of the program as done by EXTRACT. 

EXTRACT is a program written for 
SWTP BASIC running on a M6800 
microcomputer using the FLEX operating 
system. EXTRACT will accept as its 
input a file containing the BASIC pro¬ 
gram. The output will consist of two 
files, one being all of the remarks found, 
and the second containing only instruc¬ 
tions. The file containing just the RE¬ 
MARKS can be listed on a hard-copy 
device and become a permanent part of 
the programmer’s documentation. The 
file of statements can be used for sub¬ 
sequent interpretation. Since it contains 
no remarks, its memory requirements 
will be smaller and execute faster. 

EXTRACT is written in M6800 
assembly language in order to properly 
read a source file. While SWTP BASIC 
can read files, string input is separated 
by commas, causing problems during 
input. Rather than write an assembly 
subroutine for a BASIC program, one 
language was used. EXTRACT is care¬ 
fully commented so that one need only 
read the comments and understand the 
operation of the program. The concept 
of segments of code is used by including 
blocks of comments to separate the 
major portions. The header block in¬ 
cludes information about the origin and 
purpose of the program. The flowchart 
can also be consulted for an overview of 
the logic. 

For non-M6800 users, could this pro¬ 
gram be modified for another machine? 
Conversion of the concept should not be 
difficult due to the quality of the com¬ 
ments and code, as well as minimal 
reliance upon the operating system. 
For reasons mentioned earlier, a BASIC 
implementation would not be practical. 

The idea of documentation lacks en¬ 
thusiastic backers in the computer indus¬ 
try. Tools such as EXTRACT should be 
employed to automate the process as 
much as possible, thus encouraging and 
furthering the documentation process. □ 


165 

00E0 

20 

17 



BRA 

STMT2 


CONTINUE 

166 

00E2 

7F 

00 

10 

STMT 

CLR 

REM 


NOT REMARK STATEMENT 

167 

00E 5 

OE 

0B 



LDX 

SCOUNT 



168 

00E 7 

BD 

71 

30 


JSR 

ADDBX 


INCREMENT STATEMENT COUNTER 

169 

OOEA 

DF 

OB 



STX 

SCOUNT 



170 

00EC 

CE 

04 

38 


LDX 

* FCBEXT 


SET FILE-10 

171 

00EF 

7D 

no 

ii 


TST 

SNEW 


FIRST STATEMENT? 

172 

0OF2 

26 

05 



BNE 

STMT2 


YES - BRANCH 

175 

00F4 

86 

3 A 



LDA A 

#' : 


NO-OUTPUT SEPARATOR 

174 

00F6 

BD 

78 

06 


JSR 

FMS 



175 





* 





176 

00F9 

FF 

05 

5B 

STMT2 

STX 

FI LEID 


SAVE FILE-ID 

177 

00FC 

96 

0D 



LDA A 

SAVE 


MOW 

178 

00FE 

BD 

05 

10 


JSR 

OUTFIL 


OUTPUT THREE CHARACTER 

179 

0101 

96 

0E 



LDA A 

SAVE + 1 


KEYWORD 

180 

0103 

BD 

05 

10 


JSR 

OUTFIL 



181 

0106 

96 

OF 



LDA A 

SAVE* 2 



182 





* 





183 





* COPY 

CHARACTERS UNTIL 

CR IF REM, ELSE 

184 





* 

ONLY COPY UNTIL 

• 

FOUND. 

185 





* 





186 

0108 

BD 

05 

10 

LOOP 

JSR 

OUTFIL 


OUTPUT TO FILE 

187 

010B 

BD 

02 

7E 


JSR 

GCHAR 


GET AND COPY CHARACTERS 

188 

010E 

81 

0D 



CMP A 

#CR 


END-OF-L1NE? 

189 

0110 

26 

10 



BNE 

0VER1 


NO-SKIP OVER 

190 





* 





191 





• TEST 

IF CR IS NEEDED 

AT END OF EACH LINE 

192 





* 





193 

0112 

7D 

00 

ii 


TST 

SNEW 


STATEMENT NEEDS ONE? 

194 

0115 

26 

08 



BNE 

LOOPIO 


NOPE-BRANCH 

195 

0117 

86 

0D 



LDA A 

#CR 


YES-OUTPUT CR 

196 

0119 

CE 

0 4 

38 


LDX 

#FCBEXT 



197 

one 

BD 

78 

06 


JSR 

FMS 



198 

011 F 

7D 

00 

12 

LOOPIO 

TST 

RNEW 


REMARK NEEDS ONE? 

199 

0122 

26 

08 



BNE 

LOOP20 


NO-BRANCH 

200 

0124 

86 

0D 



LDA A 

»CR 


YES-OUTPUT CR 

201 

0126 

CE 

03 

78 


LDX 

fFCBREM 



202 

0129 

BD 

78 

06 


JSR 

FMS 



203 

012C 

7E 

00 

87 

LOOP20 

JMP 

CONT 


GET NEXT LINE OF INPUT 

204 





* 





205 





• TEST 

1 F THE 

: IS IN 

A 

OUOTE FIELD, SUCH AS 

206 





* 

PRINT 

' HI : " 



207 





* 





208 

012F 

7D 

00 

13 

OVER 1 

TST 

QUOTE 


CURRENTLY IN QUOTE FIELD? 

209 

0132 

27 

09 



BEQ 

0VER2 


NO-BRANCH 

210 

0134 

81 

22 



CMP A 

#•" 


END OF QUOTE FIELD? 

211 

0136 

26 

DO 



BNE 

LOOP 


NOPE-GET NEXT CHAR 

212 

0138 

7F 

00 

13 


CLR 

QUOTE 


YES - CLEAR SWITCH 

213 

013B 

20 

CB 



BRA 

LOOP 


AND CONTINUE 

214 





* 





215 

013D 

81 

3A 


0VER2 

CMP A 

# • : 


END-OF-STMT? 

216 

013F 

26 

08 



BNE 

0VER3 


NO-SKIP 

217 

0141 

7D 

00 

10 


TST 

REM 


REMARK? 

218 

0144 

26 

C2 



BNE 

LOOP 


YES-REPEAT COPY UNTIL CR 

219 

0146 

7E 

00 

AF 


JMP 

TYPEA 


NO - GET NEXT TYPE 

220 

0149 

81 

22 


0VER3 

CMP A 

»•" 


START OF QUOTE FIELD? 

221 

014B 

26 

BB 



BNE 

LOOP 


NO-GET NEXT CHAR 

222 

014D 

C6 

01 



LDA B 

#TRUF 


YES - TURN SWITCH ON 

223 

014F 

D 7 

13 



STA B 

QUOTE 



224 

0151 

70 

B5 



BRA 

LOOP 


AMD REPEAT 

225 





* 





226 





• END 

0 F 

R U N 

P 

ROCESSING 

227 





* 





228 

0153 

CE 

02 

B8 

DONE 

LDX 

#FCBIN 


CLOSE INPUT FILE 

229 

0156 

BD 

02 

A8 


JSR 

FILECL 



230 

0159 

CE 

03 

78 


LDX 

fFCBREM 


CLOSE REMARK FILE 

231 

015C 

BD 

02 

A8 


JSR 

FILECL 



232 

015F 

CE 

04 

38 


LDX 

fFCBEXT 


CLOSE CODE FILE 

233 

0162 

BD 

02 

A8 


JSR 

FILECL 



234 





* 





235 





* FILES 

CLOSED 

, OUTPUT 

TOTALS 

236 





* 





237 

0165 

CE 

00 

09 

D0NE1 

LDX 

fRCOUNT 


REMARK COUNT 

238 

0168 

5F 




CLR B 



ZERO SUPPRESS 

239 

0169 

BD 

71 

33 


JSR 

OUTDEC 



240 

016C 

CE 

01 

C6 


LDX 

fMESSl 



241 

016F 

B0 

04 

FC 


JSR 

PDATA 



242 

0172 

CE 

00 

0B 


LDX 

fSCOUNT 


STATEMENT COUNT 

243 

0175 

5F 




CLR B 




244 

0176 

BD 

71 

33 


JSR 

OUTDEC 



245 

0179 

CE 

01 

D 8 


LDX 

f MESS2 



246 

017C 

BD 

04 

FC 


JSR 

PDATA 



247 

017 F 

CE 

01 

B9 


LDX 

#FINAL 


PRINT FINAL MESSAGE 

248 

0182 

BD 

05 

09 


JSR 

PSTRNG 



249 

0185 

7E 

71 

03 


JMP 

DOS 


ALL DONE!! 

250 





# 





251 





* MISCELLANEOUS CONSTANTS AND DATA STORAGE 

252 





* 





253 

0188 

0D 



INTRO 

FCB 

CR, LF 



254 

018A 

45 




FCC "Extract REM 

's from a BASIC program, version #" 

255 

01B7 

31 




FCB 

VERNO+'O 

, 

EOT 

256 

01B9 

45 



FINAL 

FCC 

'End Extract. ' 

257 

01C5 

04 




FCB 

EOT 



258 

01C6 

20 



MESSl 

FCC 

' REMarks 

found. ' 

259 

01D5 

00 




FCB 

CR,LF,EOT 


260 

01D8 

20 



MESS2 

FCC 

' statements found.' 


Page 34 

428 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 




261 

01EA 

0D 



CRLF 

FCB 


CR,LF,EOT 

262 

01 ED 

53 



MERR1 

FCC 


'Syntax 

error In file name.' 

263 

0207 

04 




FCB 


EOT 


264 

0208 

55 



MERR2 

FCC 


'Unab1e 

to open 1NPUT file.' 

265 

0222 

04 




FCB 


EOT 


266 

0223 

55 



MERR3 

FCC 


'Unable 

to open .REM or .EXT file.' 

267 

0244 

OD 




FCB 


CR, LF 


268 

0246 

44 




FCC 


'Do they already exist?' 

269 

02 5C 

04 




FCB 


EOT 


270 

0250 

55 



MERR4 

FCC 


' Unab1e 

to properly close a file.' 

271 

027D 

04 




FCB 


EOT 


272 





* 





273 





* SUBROUTINE 

TO RETURN 

NEXT CHARACTER 

274 





* 





275 





* ENTRY 

GCHAR 

RETURNS 

NEXT CHAR WHEREAS ENTRY 

276 





* 

BCHAR 

RETURNS 

'JFXT MON-BLANK CHAR 

277 





* 





278 

027E 

7C 

02 

A7 

GCHAR 

INC 


BFLAG 

SET BLANK TRUE 

279 

0281 

20 

03 



BRA 


GCHARl 


280 

0283 

7F 

02 

A7 

BCHAR 

CLR 


BFLAG 

ELSE FLAG FALSE 

281 

0286 

FF 

02 

A5 

GCHARl 

STX 


CHARQ0 

SAVE XR 

282 

0289 

CE 

02 

B 8 


LDX 


# F C B 1 N 


283 

028C 

BD 

78 

06 

GCHAR2 

JSR 


FMS 

GET CHAR 

284 

0 2 8 F 

26 

0D 



BNE 


GCHAR8 

ERROR RETURN 

285 

0291 

7D 

02 

A7 


TST 


BFLAG 

TEST BLANK FLAG 

286 

0294 

26 

04 



BNE 


GCHAR3 

OK-RETURN 

287 

0296 

81 

20 



CMP 

A 

# ' 

IS IT SPACE? 

288 

0298 

27 

F2 



BEO 


GCHAR2 

YES - GET NEXT CHAR 

289 

029A 

FE 

02 

A5 

GCHAR3 

LDX 


CHAR90 

RESTORE XR 

290 

029D 

39 




RTS 



AND RETURN 

291 

029E 

86 

01 


GCHAR8 

LDA 

A 

#TRUE 

SET 

292 

02A0 

B 7 

02 

A4 


STA 

A 

EOF 

END-OF-FILE ON 

293 

02A3 

39 




RTS 




294 





* 





295 

02A4 

00 



EOF 

FCB 


0 


296 

02A5 

02 

BB 


CHAR90 

FDB 


FCBIN+3 

XR STORAGE 

297 

02A7 

00 



BFLAG 

FCB 


0 

RETURN BLANK INDICATOR 

298 





* 





299 





* SUBROUTINE 


TO CLOSE 

A FILE 

300 





* 





301 

02A8 

86 

04 


FILECL 

LDA 

A 

♦ CLOSE 

CLOSE CODE 

302 

0 2 AA 

A7 

00 



STA 

A 

o,x 


303 

02 AC 

BD 

78 

06 


JSR 


FMS 


304 

02 AF 

26 

01 



BNE 


FILER 

ERROR? 

305 

02B1 

39 




RTS 



NO-RETURN 

306 

02B2 

CE 

02 

50 

FILER 

LDX 


#MFRR4 


307 

92B5 

7E 

00 

21 


JMP 


ERROIIT 

ERROR PROCESSING 

308 





* 





309 





* FILE 

CONTROL BLOCKS 

(FCB) FOR 

310 





* . BAS 


- INPUT 

FILE 

311 





* .EXT 


- CODE FILE 

312 





* .REM 


- REMARK 

FILE 

313 





* 





314 

02B8 




FCBIN 

RMB 


142 


315 

0378 




FCBREM 

RMB 


12 


316 

0384 

52 




FCC 


1 REM' 


317 

0387 





RMB 


177 


318 

0438 




FCBEXT 

RMB 


12 


319 

0444 

45 




FCC 


'EXT' 


320 

0447 





RMB 


177 


321 

04F8 

03 

7B 


PTRl 

FDB 


FCBREM+3 FILE NAME PTR 

322 

04FA 

04 

3B 


PTR2 

FDB 


FCBEXT+3 FILE NAME PTR 

323 





* 





324 





« SUBROUTINE 

TO OUTPUT 

CHARACTERS, 

325 





* TERMINATED 


3Y EOT. 


326 





* 





327 

04FC 

A6 

00 


POATA 

LDA 

A 

0,X 

GET CHAR 

328 

04FE 

81 

04 



CMP 

A 

♦ EOT 

END-OF-STRING? 

329 

0500 

27 

06 



BEQ 


PDATA1 

YES - RETURN 

330 

0502 

BD 

71 

12 


JSR 


PtlTCHR 

OUTPUT CHARACTER 

331 

0505 

08 




1 NX 




532 

0506 

20 

F 4 



BRA 


PDATA 

AMD REPEAT 

333 

0508 

39 



PDATA1 

RTS 



RETURN 

334 





* 





335 





* SUBROUTINE 


PSTRNG 


336 





* CALL PDATM, AND 

THEN PRINT CR/LF 

337 





* 





338 

0509 

8D 

FI 


PSTRNG 

BSR 


PDATA 

OUTPUT STRING 

339 

050B 

CE 

01 

EA 


LDX 


#CRLF 


340 

050E 

20 

EC 



BRA 


PDATA 

OUTPUT CR, LF 

341 





* 





342 





* SUBROUTINE 


OUTFIL - 


343 





* OUTPUT 

ACC-A TO PROPER FILE. 

344 





* OPTIONALLY OUTPUT 

STATEMENT NUMBER 1 F 

345 





* NEEDED. 




346 





* 





347 

0510 

B7 

05 

58 

OUTFIL 

STA 

A 

TCHAR 

SAVE CHARACTER 

348 

0513 

70 

00 

10 


TST 


REM 

IN REMARK? 

349 

0516 

26 

0A 



BNE 


OUT 10 

YES - BRANCH 

350 

0518 

7D 

00 

11 


TST 


SNEW 

STATEMENT NEEDS NUMBER? 

351 

051B 

27 

2C 



BEO. 


OUT80 

NO-BRANCH 

352 

051D 

7F 

00 

11 


CLR 


SNEW 

CLEAR INDICATOR 

353 

0520 

20 

08 



BRA 


OUT 50 

BR TO OUTPUT STMT # 

354 

0522 

7D 

00 

12 

OUT 10 

TST 


RNEW 

REMARK NEEDS NUMBER? 

355 

0525 

27 

22 



BEQ 


OUT80 

NO-BRANCH 

356 

0527 

7F 

00 

12 


CLR 


RNEW 

CLEAR indicator (continued) 


Figure 1. 

Structured Flowchart for EXTRACT 


open input file (.BAS) 
open output file (.REM) 
open output file (.EXT) 


loop until end-of-input-file 


save statement number 


loop until end-of-line 


type = 'REM' 


increment 

remark 

counter 


increment 

statement 

counter 


: needed 



output 

to 

file 


loop until : or EOL 


get character 


output to proper 
file 


print counts of statements 
and remarks 



Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 35 

429 



















357 





* 





358 





* OUTPUT 

STATEMENT NUMBER 


359 





* 





360 

05 2 A 

CE 

00 

03 

OUT50 

LDX 


♦NUMBER 


361 

052D 

FF 

05 

59 


STX 


SAVEXR 

PT TO FIRST DIGIT 

362 

0530 

FE 

05 

59 

OUT60 

LDX 


SAVEXR 


363 

0533 

A6 

00 



LDA 

A 

0,X 

GET DIGIT 

364 

0535 

27 

12 



BEQ 


OUT80 

BR IF MO MORE 

365 

0537 

08 




1 NX 



ADVANCE TO NEXT DIGIT 

366 

0538 

FF 

05 

59 


STX 


SAVEXR 

AND SAVE POSITION 

367 

053B 

FE 

05 

5B 


LDX 


FILEID 


368 

053E 

BD 

78 

06 


JSR 


FMS 

OUTPUT TO FILE 

369 

0541 

27 

ED 



BEQ 


OUT 60 

REPEAT IF NO ERROR 

370 

0543 

CE 

05 

5D 

OUT65 

LDX 


#I0ERR 


371 

0546 

7E 

00 

21 


JMP 


ERROUT 

ERROR PROCESSING 

372 





* 





373 





* OUTPUT 

' SINGLE 

: CHARACTER 

1 (TCHAR) 

374 





* 





375 

0549 

FE 

05 

5B 

OUT80 

LDX 


FILEID 


376 

054C 

B6 

05 

58 


LDA 

A 

TCHAR 

OUTPUT CHARACTER 

377 

054F 

BD 

78 

06 


JSR 


FMS 


378 

0552 

26 

EF 



BNE 


OUT65 

ERROR? 

379 

0554 

B6 

05 

58 


LDA 

A 

TCHAR 

RESTORE CHAR 

380 

0557 

39 




RTS 



AND RETURN 

381 





* 





382 

0558 

00 



TCHAR 

FCB 


0 

STORAGE FOR SINGLE CHAR 

383 

0559 

00 

00 


SAVEXR 

FDB 


0 

XR STORAGE 

384 

055B 

00 

00 


FILEID 

FDB 


0 

ADDRESS OF FILE-FCB 

385 

05 50 

49 



I0ERR 

FCC 


'1/O error 

when writing to output 

386 

0583 

04 




FCB 


EOT 


387 






END 


XTRACT 


NO ERROR(S) 

DETECTED 







♦♦♦EXTRACT,SIMPLE.BAS 

Extract REM's from a BASIC program, version #1 

3 REMarks found. 

4 statements found. 

End Extract. 

♦♦♦LIST,SIMPLE.EXT 
20LET A=5 

30PRINT A :PR I NT "MULTIPLE STATEMENTS" 

50END 

♦♦♦LIST,SIMPLE.REM 
10REM THIS IS A REMARK 
20REM THIS IS AN INLINE REMARK 
40REM ALL DONE 

♦♦♦LIST,SIMPLE.BAS 
10 REM THIS IS A REMARK 

20 LET A-5 : REM THIS IS AN INLINE REMARK 
30 PRINT A : PRINT "MULTIPLE STATEMENTS" 

40 REM ALL DONE 

end 


Symbol Table 


ADDBX 

7130 

BCHAR 

0283 

BFLAG 

02A7 

CHAR90 

02A5 

CLOSE 

0004 

CONT 

0087 

CONTI 

0092 

CONT2 

0098 

COPY 

0045 

CR 

0000 

CRLF 

01EA 

DONE 

0153 

DOME 1 

0165 

DOS 

7103 

EOF 

02A4 

EOT 

0004 

ERR1 

0014 

ERR2 

0019 

ERR3 

001E 

ERROUT 

0021 

FCBEXT 

0438 

FCB 1 N 

02B8 

FCBREM 

0378 

FILECL 

02A8 

FILEID 

055B 

FILER 

02B2 

FINAL 

01B9 

FMS 

7806 

GCHAR 

027E 

GCHAR1 

0286 

GCHAR2 

028C 

GCHAR3 

029A 

GCHAR8 

029E 

GETFIL 

7127 

INTRO 

0188 

I0ERR 

055D 

LF 

000A 

LOOP 

0108 

LOOPIO 

011F 

LOOP20 

012C 

MERR1 

01ED 

MERR2 

0208 

MERR3 

0223 

MERR4 

025D 

MESS1 

01C6 

MESS2 

01D8 

NEXT 

00AB 

NUMBER 

0003 

OUT10 

0522 

OUT 50 

052A 

OUT60 

0530 

OUT 6 5 

0543 

OUT 80 

0549 

OUTDEC 

7133 

OUTFIL 

0510 

0VER1 

012F 

0VER2 

013D 

0VER3 

0149 

PDATA 

04FC 

PDATA1 

0508 

PSTRNG 

0509 

PTR1 

04F8 

PTR2 

04FA 

PUTCHR 

7112 

QUOTE 

0013 

RCOUNT 

0009 

READ 

0001 

REM 

0010 

RNEW 

0012 

SAVE 

000D 

SAVEXR 

0559 

SC0UNT 

OOOB 

SETEXT 

712D 

SNEW 

0011 

STMT 

00E2 

STMT2 

00F9 

TCHAR 

0558 

TRUE 

0001 

TYPE 

OOB2 

TYPEA 

00AF 

VERNO 

0001 

WRITE 

0002 

XTR1 

002D 

XTRACT 

0000 




(continued from page 9) 

NLOGS cont’d 


NOTE 

Following the terminology well- 
established by the pocket calculator, 
the following abbreviations will be 
used in the balance of this paper: LOG 
will stand for “the logarithm to the 
base 10;” EXP will mean “10 raised to 
the _ power.” The distinction be¬ 

tween LOG (logjp) and log (general 
term) should be kept in mind. 


REFERENCES 

Reference (1): The article on “Loga¬ 
rithms” in the 1967 edition of the 
Encyclopaedia Brittanica, by K.O. 
May. 

Reference (2): The International Dic¬ 
tionary of Applied Mathematics; 
D. Van Nostrand 1960; definition 
of “A ccuracy. ” 

Reference (3): Keneth A. Simons, 
“The dB Anything,” Proc. IEEE 
(Letters), pp. 495-96, April 1973. 



Page 36 

430 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 






MCVIT 


by William D. Loughman 


The standard 2000 hex address of the North-Star DOS can 
be an annoyance at times. Large programs starting anywhere 
below the DOS sometimes cannot be loaded from disk, as the 
DOS may be overwritten before the load is completed. There 
are a lot of nice programs which were not designed for use 
with the N * disk system. 

These can be used painlessly by tacking them onto a short 
‘mover’ program. MOVIT cares not where it is started. It 
finds its own location in RAM by putting a ‘RET’ at 0 hex, 
executing ‘RST O’, and accessing the stack to find the return 
address. Subsequent operations are all by adding offsets to 
this reference address. MOVIT is short enough to enter ‘by 
hand’ with a monitor; just pay attention to changes needed 
in lines 80-81 and line 93. If you use an assembler, in addi¬ 
tion to those changes you should delete line 16 and you must 
change the execution address assignment in line 41. After 
assembly, load your own program to reside at whatever ad¬ 
dress is represented by line 100. The 6 bytes there are only a 
sample; load on top of them. Save the combined programs to 
disk. 

Now the combination can be loaded from disk and execu¬ 
ted at almost any arbitrary location in memory. Your pro¬ 
gram will be moved to its correct location (overwriting the 
DOS, perhaps) and started up. I give my disk files a ‘GO’ 
address in high memory, making sure the loaded program will 
fit. Then all I need to do is ‘GO .. .’, and it auto-executes 
just like ‘proper’ programs do. 

An aside: this letter is formatted using H. Watson’s POW 
(DDJ #29). L. Morgenstem modified that for use with Pro¬ 
cessor Tech’s EDIT program (DDJ #32:42 Feb. 70). I have 
adapted the latter version for use with either ALS-8 or PILOT 
file structures, which I use in my home-brew (disk) operating 
system. This allows use of the nice screen editors in those 
programs, and thus provides a pretty good and very, very in¬ 
expensive CRT word processor system. Many thanks to them, 
and to you. O 


LISTING 

ASSMX 0 


0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 

0000 


0001 * * MOVIT * 

0002 * 

0003 * An address-independent routine for 
0004 * 'load-and-go' use, from disk, of 
0005 * programs blocked by the standard 
0006 * NorthStar DOS at 2000 hex. 

0007 * 

0008 * Orig. : Wm.D.Lougliman 1 May 1980 
0009 * PUBLIC DOMAIN: 12 June 1980 
0010 * 

0011 * Set BYTES, BOTAD, and XEQ (below) 
0012 * to reflect your own program needs. 
0013 * (EXAMPLES below: use for a test) 
0014 * 

0015 * my OS and assembler usage: 

0016 SOLOS EQU 0C004H for EXAMPLE 

0017 SP EQU 6 (for ALS-8) 

0018 * 

0019 * Assemble this program-mover at any 
0020 * convenient address. Add your own 
0021 * program to it at PROGM (below). 
0022 * 

0023 * Create a disk file large enough to 
0024 * hold BOTH your program AND this 


William D. Loughman -293 Gravatt Dr., Berkeley, CA 94705 


0000 




0025 

* 

preamble. 

Save all of it to disk. 

0000 




0026 

* 





0000 




0027 

* 

Give 

the disk file 

any convenient 

0000 




0020 

* 

'GO' 

address which 

is neither in 

0000 




0029 

* 

the : 

DOS address space, nor that of 

0000 




0030 

* 

your 

program's final location. 

0000 




0031 

* 





0000 




0032 

* 

Now, 

•GO 

(filename)', and enjoy. 

0000 




0033 

* 





0000 




0034 

* 





0000 




0035 

* 

— 

- SET 

VARIABLES HERE — 

0000 




0036 

* 

your 

program's length in bytes: 

0000 




0037 

BYTES 

EQU 

6 

for EXAMPLE 

0000 




0038 

* 

your 

program's correct load addr: 

0000 




0039 

BOTAD 

EQU 

0 

for EXAMPLE 

0000 




0040 

* 

your 

program's execution addr: 

0000 




0041 

XEQ 

EQU 

SOLOS 

for EXAMPLE 

0000 




0042 

* 





0000 




0043 

* 





0000 




0044 

* 


— 

MOVIT — 


0000 




0045 

* 

assume a valid stack (1 call); 

0000 




0046 

* 

and 

find our own RFRNC address 

0000 

21 

00 

00 

0047 



LX I 

H, 0 

'RST 0' needs 

0003 

36 

C9 


0048 



MV I 

M, 0C9H 

'RET' 

0005 




0049 

* 





0005 

C7 



0050 



RST 

0 

call it 

0006 

3B 



0051 

PFRNC 

DCX 

SP 

return here 

0007 

3B 



0052 



DCX 

SP 

to get 

0008 

E3 



0053 



XTHL 

. 

RFRNC addr 

0009 

5P 



0054 



MOV 

E,L 

clone it 

000A 

54 



0055 



MOV 

D, H 


00 0B 




0056 

* 

now, 

make 

our own 

stack at RFRNC, 

00 0B 




0057 

* 

ruining this nice 

program* 

000B 

F9 



0053 



SPHL 



oooc 




0059 

* 





oooc 




0060 

* 

find 

MOVE 

addr 


oooc 

3E 

20 


0061 



MV I 

A,MOVE 

-RFRNC offset 

000E 

85 



0062 



ADD 

L 

plus RFRNC addr 

000F 

6F 



0063 



MOV 

L, A 


0010 

3E 

00 


0064 



MV I 

A , 0 


0012 

8C 



0065 



ADC 

H 


0013 

67 



0066 



MOV 

II, A 

is MOVE addr 

0014 

E3 



0067 



XTHL 

. 

saved in stack 

0015 




0068 

* 





0015 




0069 

* 

find 

PROGM (to move) 

0015 

EB 



0070 



XCHG 

. 

REFRNC addr 

0016 

3E 

2D 


0071 



MV I 

A,PROGM-RFRNC 

0018 

95 



0072 



ADD 

L 

plus offset 

0019 

6F 



0073 



MOV 

L, A 


001A 

3E 

00 


0074 



MVI 

A, 0 


001C 

R C 



0075 



ADC 

H 


ooin 

67 



0076 



MOV 

H , A 


001E 

ER 



0077 



XCHG 


is PROGM addr 

001F 




0078 

* 





001F 




0079 

* 

set 

up the move 


001F 

01 

06 

00 

0030 



LXI 

B,BYTES its length 

0022 

21 

00 

00 

0081 



LX I 

H,BOTAD its load addr 

0025 

F.3 



0032 



XTHL 

. 

(balances MOVE) 

0026 




0083 

* 





0026 




0034 

* 

move 

the 

program; 

execute it 

0026 

E3 



0085 

MOVE 

XTHL 

. 

get load addr 

0027 

1A 



0086 



LDAX 

D 

move a byte 

0028 

77 



0087 



MOV 

M,A 


0029 

13 



0083 



INX 

D 

set up next 

002A 

23 



0089 



INX 

H 


002B 

0B 



0090 



DCX 

B 

bytes-1 

002C 

79 



0091 



MOV 

A ,C 


002D 

B0 



0092 



ORA 

B 

done? 

002E 

CA 

04 

CO 

0093 



JZ 

XEQ 

do it, else 

0031 




0094 

* 

put 

load . 

addr in stack, also 

0031 

E3 



0095 



XTHL 

. 

get MOVE addr 

0032 

E9 



0096 



PC1IL 

. 

and do more 

0033 




0097 

* 





0033 




0098 

* 

your 

program goes 

here, 

0033 




0099 

* 

replacing 

this dummy. 

0033 




0100 

PROGM 

EQU 

$ 


0033 

11 

n 


0101 



DW 

1111H 


003 5 

2 2 

2 2 


0102 



DW 

2222H 


0037 

33 

33 


0103 



DW 

3333H 


0039 




0104 

* 






BOTAD 

0000 

0081 


BYTES 

0006 

0030 


MOVE 

0026 

0061 


PROGM 

0033 

0071 


RFRNC 

0006 

0061 

0071 

SOLOS 

C004 



SP 

0006 

0051 

0052 

XEQ 

C004 

0093 



€ND 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 37 

431 



6800 and 1802 

Cross-Assembler for CP/M 

by William C. Colley III 


What Is a Cross-assembler? 

A cross-assembler, like a normal assembler, is a program 
that converts human-readable assembler source code for a 
given microprocessor into binary machine code for the same 
processor. The difference between a cross-assembler and a 
normal assembler is this: a normal assembler program is 
run on the same type of processor as the output of the assem¬ 
bler and a cross-assembler program is run by a different pro¬ 
cessor. For example, a 6800 assembler runs on a 6800 and 
converts source code in 6800 machine code. This particular 
6800 cross-assembler runs on an 8080 or Z-80 and converts 
6800 source code into 6800 machine code. 

With an appropriate cross-assembler, you can write and 
assemble code for another (in this case 6800 or 1802) pro¬ 
cessor using your existing (in this case CP/M) editors and 
floppy disks. This keeps you from having to have separate 
disks, disk operating systems, editors, etc. for each different 
processor. 

General Description of Both Cross-assemblers 

CP/M comes with an assembler (ASM.COM) of about the 
same capabilities as these two cross-assemblers. Thus, the 
cross-assemblers will be described in terms of how they 
compare to the ASM. 

The assembler syntax of the cross-assemblers is similar to 
ASM’s, but not identical. Line numbers are not permitted, as 
the cross-assemblers make no attempt to scan them off. A 
leading * will cause an error rather than mark a comment line. 
Comment lines should begin with a semicolon. No colons 
should appear after labels as the colon is a legal alphabetic 
character and will become part of the symbol name. Labels are 
distinguished from opcodes by the fact that labels begin in 
column 1 and opcodes do not. 

The opcodes are those of the particular microprocessor 
instead of those of the 8080. The only lower-case to upper¬ 
case conversions performed by the assembler are in opcocdes 
and keywords such as NOT, AND, MOD, etc. Thus the opcode 
“LDA” is the same as “Ida”, but the label “LABEL” is not the 
same as the label “label”. 

The expression evaluator has more operators than ASM’s 
and the operators have a slightly different precedence order. 
The additional operators are: 

HIGH meaning “the high byte of” 

LOW meaning “the low byte of” 

relational operators EQ, NE, LT, LE, GT, GE (which can also be 

written as =, O, <,<=,>, >= respectively) 


William C. Colley, III-409 Marlborough St. #24, Boston 
MA 02115 


Finally, the pseudo-ops have been renamed according to 
the particular processor. Also the IF-ENDIF pair has been 
enhanced to IF-ELSE-ENDI. The ELSE is, of course, optional. 

Like ASM, the output of the cross-assemblers is in INTEL 
hex. This was chosen because INTEL hex can be loaded into 
memory by DDT and SID. Of course, the disassembly functions 
of DDT and SID will not work correctly on a non-8080 
instruction set. 

Particular Description of the 6800 Cross-assembler 

The 6800 cross-assembler’s basic syntax is as follows: 

[label] LDA A X, 3 Comment field. 

The parser is built such that the accumulator specifier “A”, 
the indexed mode designator “X”, and the offset “3” can be 
specified in any order. The designators “A”, “B”, and “X” 
can be written in either upper or lower case. Immediate 
addressing is specified by a #sign as per Motorola usage. 

Also in accordance with Motorola usage, two formats for 
numeric constant are supported. The Motorola-format con¬ 
stant $FF is equivalent to the INTEL-format constant 0FFH. 
Hex numbers and INTEL-format base designators can be 
written in either upper or lower case. 

The current location counter is referenced by a * instead of 
the $ sign as per Motorola usage. 

Finally, when given the choice between direct (short) 
addressing and extended (long) addressing, the assembler will 
choose direct addressing if the following two conditions are 
met: 

1. The address in question contains no forward references. 

2. The address in question is in the range 0 to $FF. 

Particular Description of the 1802 Cross-assembler. 

The 1802 cross-assembler implements two additional 
pseudo-ops above the set available in ASM. They are: 

1. PAGE which sets the current location counter to the top of the 

next 256-byte page, and 

2. LOAD register, value 

This is, in effect, a built-in macro. The assembly of a 
LOAD pseudo-op places the following code into the object 
file: 

LDI HIGH value 
PHI register 
LDI LOW value 
PLO register 


The LOAD pseudo-op is included since this construct is so 


Page 38 

432 


Dr. Dobb's Journal of Computer Calisthenics 8i Orthodontia 


Number 50 





common in 1802 code that RCA saw fit to include it as a 
pseudo-op in some of their assemblers 

What Machine Resources are Required? 

The cross-assemblers are supplied in source form only 
(except as noted below) as both the source and object of the 
assemblers would not fit on a single-density 8” disk with the 
other three programs on the disk. Each assembler has six 
modules written in BDS C. A seventh module (called either 
A68TBLS. MAC or A18TBLS.MAC) is written in Microsoft’s 
MACRO-80 in such a way that it assembles into a link module 
for the BDS C linker. The details as to how this is done are 
included on the disk. In addition, for those who have BDS C 
but not MACRO-80, the assembled versions (A68TBLS. 
CRL and A18TBLS.CRL) are included on the disk. BDS C 
and MACRO-80 are available through Lifeboat Associates 
who advertise in most of the microcomputer magazines. 

The required machine resources are thus: 

1. the BDS C compiler, and (optionally) the MACRO-80 macro¬ 
assembler, 

2. 40K or more of RAM, and 

3. CP/M version 1.3 or 1.4. 

The cross-assemblers have not been tested under CP/M 2.x, 
though there should be no problems involved. 

What Do I Get and Where Do I Get It? 

The cross-assemblers are available on single-density 8” 
disk from the C User’s Group. Send them a disk and enough 
postage to mail it back to you. Write to: C User’s Group, 
c/o John Nall, Computer Center, Love Building, Florida 
State University, Tallahassee, Florida, 32306, (904) 644- 
2764. 

The disk includes the 8 source files of each cross-assembler 
(an include file, 6 C modules, and the MACRO-80 module), 
the assembled versions of the MACRO-80 modules, and print 
image copies (ready to pip to 1st:) of the 20-page user 
manuals. The disk also includes a combination BDS 
C/MACRO-80 program that uses a parallel input bit and a 
parallel output bit to read and write cassette tapes compatible 
with the El.F II. This gives you a method of getting the 
output of the 1802 cross-assembler into an 1802 system to be 
executed. The tape program also requires a simple hardware 
interface (1 CMOS chip, 5 resistors, 2 capacitors, and a po¬ 
tentiometer) that is diagrammed in the program documenta¬ 
tion. A couple of useful disk utilities written in BDS C are also 
on the disk. 

Conclusion 

I wrote the cross-assemblers for my own use and for the 
use of a friend. I saw no reason, however, why others should 
have to “reinvent the wheel,” so I am trying to distribute them 
to anyone who wants them. I hope they prove useful, o 


A legal note: CP/M, ASM. DDT, and SID are trademarks of Digital Re¬ 
search, and MACRO-80 is a trademark of Microsoft. 



Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 39 

433 



1 




wm mm 



nr 

■ 

■ 

■ 

>P0f 

90S! 

9l On Strings f 

by Ralph Deane 

on 1 

FOR 

th] 

1 

1 

__ 1 

\— _ 





_ 

=:::=! 


Once a person has used FORTH 
for a period of time, two deficiencies 
usually appear. These are the lack of 
floating point (real) numbers, and the ab¬ 
sence of any string handling functions. 
Much of the work currently being done in 
BASIC could be done quicker and easier 
in FORTH if these two problem areas 
were fixed. 

The area of floating point numbers 
has been adddressed by different groups, 
and Kitt Peak Observatory has published 
their approach in the Kitt Peak FORTH 
Primer. This will probably become the 
standard in the future. 

The problem of string handling in 
FORTH is an area which, as yet, has 
received little attention. In this article 
I propose to outline one approach to 
solving this problem. In no way is this 
method to be thought of as a finalized 
standard solution to string handling. 
It is meant to be a starting point from 
which to build a unique (and powerful) 
string handling package. 

The obvious place to start is at the 
beginning: creating string variables. Since 
FORTH is a member of the structured 
family of languages, it requires all vari¬ 
ables to be declared before use. String 
variables will be no exception. This raises 
the first problem: should we allow 
strings to have unlimited length or should 
they have a maximum length set by the 
system? Also, where shall we store the 
string data: in the dictionary or in a 
separate table? 

In order to remain compatible with 
the other data types supported by the 
language, I feel that the string should be 
stored in the dictionary. This gives the 
user maximum access to the data with a 
minimum of overhead. This storage 
system will also require that a maximum 
length be set by the system in order to 
know where the next free dictionary 
location is situated. If the maximum 
length is set at 255 (the same as Micro- 
Soft BASIC) then any character in the 
string can be addressed with an eight 
bit index register. This can be very 


Ralph Deane-Box 27, Little Fort, BC, 
Canada VOE 2C0 


important on most micros in terms of 
speed and program size. 

Another nice feature would be to 
allow the user to specify, for any string 
variable, a maximum length which is less 
than or equal to the system’s maximum 
length. This would allow a great saving 
in dictionary space requirements for 
short strings. It hardly makes sense to 
reserve 255 bytes of space for a variable 
which the user knows will have a maxi¬ 
mum of 10 characters stored in it. 

If the user is allowed to specify a 
maximum size, then that size should 
be stored at the start of the string area. A 
null ($00) should also be stored as the 
last character in order to signal the end 
of the string. This would give an over¬ 
head of two bytes per variable but would 
make for much more efficient program¬ 
ming. 

In keeping in line with other FORTH 
variables, a string variable should place 
the address of its first character on the 
sack when the variable name is executed. 
It should also put the current length of 
the string on the stack. The reason for 
this is that the current length can vary 
from the maximum length and the string 
handling functions should not have to 
search a string in order to know its length. 
This would also make it compatible with 
the string output function, TYPE, which 
has already been defined. Since TYPE 


requires the length to be the top stack 
value, with the address second, let’s also 
define string variables so that they place 
their data on the stack in the same order. 

Now that we have defined the form 
of our string variables we only need to 
implement them via a variable defining 
function. 

The defining function could be called 
STRING (a rather obvious choice) 
and will probably be defined by using 
< BUILDS and DOESX FIGURE I 
shows two different approaches to im¬ 
plementing STRING. Function (a) creates 
a variable whose current length is equal 
to the maximum length and which 
contains all blanks. Function (b) will 
create string variables with a current length 
of 1, with that character being a blank. 
Neither (a) nor (b) will allow variables 
to be created with a maximum length 
less than 1 or greater than 255. The 
runtime routine of both (a) and (b) 
are identical. It increments the starting 
address of the character string around 
the length byte and then searches the 
string to find the current length. This 
data is left on the stack in the required 
order. 

The other data type associated with 
strings, besides variables, is the literal 
string. This is usually a string of char¬ 
acters enclosed in quotes. Since the single 
quote, ’, has already been used as a func- 


FIGURE I 


o 

i 

9 

3 

4 

5 
A 
7 

6 
9 

10 
:l :l 

1.2 

1.3 

1.4 


tapes ) 

1. + SWAP 0= END SWAP 
DECIMAL 


( Definition of STRING - two 
{ SRCH DUP BEGIN DUP C@ SWAP 
( Type a STRING definition ) 

5 STRING <BUILDS ABS 255 MIN 1. MAX DUP Cv 0 DO 32 C 
LOOP 0 C» D0ES> 1 + DUP SRCH i 

< Type b STRING definition > 

! STRING <BUILDS ABS 255 MIN 
0 Cv LOOP D0ES> 1 + DUP SRCH i 

< When definin'? STRING you must chose either type a 
or type b to implement. See text for an explaination 
of the differences. > 


1 


DECIMAL 
MAX DUP 


Cv 32 Cv 0 DO 


Page 40 

434 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 






tion name we will have to use the double 
quote, ”, Since ” will be used as a 
function name it must be separated 
from the rest of the strings by a blank. 
Another ” can be used as the termi¬ 
nating character. 

Since we desire maximum flexibility 
from any function, the literal string 
function must be directly executable or 
compilable, depending on the user’s 
needs. It should also be compatible with 
the string variables so that the string 
handling functions do not have to know 
which data type they are dealing with. 
This means that a literal string, when 
executed, will place the starting address 
of the data, as well as the string length, 
on the stack. The string, wherever it is 
stored, must also have a null ($00) 
appended to it to signify the last char¬ 
acter. 

An inspection of FIG FORTH’S .” 
function shows a method which can be 
used to define the ” function. The 
function is split into two parts and the 
compilation flag is used to choose which 
part is executed. If ” is being used inside 
a colon definition (i.e., :the flag is set) 
the string is compiled into the dictionary 
along with the address of a runtime 
routine, (”), and the string length. 
The function ( ” ), when executed, will 
place the string address and its length 
on the stack. 

Direct execution of ” produces a dif¬ 
ferent sequence. The string is stored in 
the area at the end of the dictionary, 
along with its length and terminating 
character. The address of this area and 
the length of the string is then placed on 
the stack. Since the string is stored in a 
rather volatile area, any operations to be 
performed on it must be done before 
anything else is added to the dictionary. 

The definition of ” is left up to the 
implementor as it will depend on the 
specific system being used. The 
function can be used as a model if so 
desired. One thing to be remembered 
is that a null must be appended to the 
string for proper operation of the hand¬ 
ling functions. Also ” is to be made an 
immediate function. 

Now that the format and runtime 
characteristics of the string data types 
have been outlined we can go on and 
define some string handling functions. At 
the minimum the package should contain 
all the string functions supported by 
BASIC. More functions can be added as 
the need arises. 

One of the first functions needed is 
the string store routine. In keeping with 
a FORTH standard it will be called 
S! (pronounced string-store). It will 
take data from one string and place it 
in another. The variable in which the 
data is stored will have a null placed at 
the end of the new string to indicate the 
current length. The string will also be 
truncated if its length is longer than the 


variable’s maximum length. 

Where S! is used to replace the whole 
string, the function SUB! is used to re¬ 
place a substring on a one-for-one 
basis. The current length of the variable 
will be unchanged by use of SUB! . If the 
string is longer than the substring it 
replaces, it will be truncated at the 
substring’s length. 

The stack values required for S! and 
for SUB! are identical. The top two 
values are the address and length of the 
destination string (or substring). The 
next two values are the address and 
length of the source string. The lengths 
do not have to match, as the string is 
adjusted to fit the destination string. 
FIGURE II is one method of defining 
S! and SUB! . Trying to store into a 
literal string, while possible, is a real 
no-no and drastic happenings can occur if 
it is attempted. 

The next type of handling function to 
be discussed will be the substring ex¬ 
traction routines. These include MID$, 
LEFT, and RIGHTS. These functions 
generate addresses and lengths of speci¬ 
fied substrings. Since LEFTS and RIGHTS 
are just special cases of MIDS, we will 
concentrate on it for the moment. 

There are two different types of 
MIDS functions presently in use in 
BASIC. One type requires the starting 
character location and the length of the 


desired substring. The other needs the 
location of both the starting and ending 
characters. 

I have, for no specific reason, chosen 
the second type of MIDS. The first type 
can be used if so desired, and is equally 
as easy to define. MIDS should make 
sure that the substring it defines is 
entirely inside the parent string. If it is 
not, then the starting and ending loca¬ 
tions should be adjusted. MIDS expects 
the top two stack values to be the address 
and length of the parent string. The next 
value is the ending character location, 
while the last value is the starting char¬ 
acter location. These last two values will 
be forced into the range of 1 to the cur¬ 
rent string length. MIDS will return the 
address and length of the substring as 
defined by these values. 

LEFTS is the special case of MIDS 
where the starting character location is 
assumed to be 1. Only the address and 
length of the parent string, as well as the 
ending character location, are needed. 
RIGHTS is another special case in which 
the ending character location is assumed 
to be the last character in the parent 
string. The starting character location 
and the parent string information is all 
that RIGHTS requires. FIGURE III 
is one possible definition of MIDS, 
RIGHT and LEFTS. 

Concatenation of strings is another 


P 


FIGURE II 


0 ( Definition of S! and SUB! ) 

1 : S' DROP DUP t - CP ROT MIN 1 MAX OVER OVER + 

2 0 SWAP C- CMOVE f 

3 

4 ! SUB! ROT MIN 1 MAX CMOVE f 

5 

6 ( Note that in PIG FORTH the function C- is called C! ) 

7 
B 
o 

10 
11 
I 2 

1.3 
14 

1. 5 


FIGURE III 

0 ( Definitions of MIDS. LEFTS and RIGHTS ) 

1 : MIDS SWAP SAVE ROT MIN 1 MAX SWAP OVER MAX OVER 

2 + SWAP UNSAVE + 1 ~ SWAP OVER SRCH MIN 5 

3 

4 : LEFTS SAVE SAVE 1 SWAP UNSAVE UNSAVE MIDS -S 

5 

6 ! RIGHTS SAVE SAVE 256 UNSAVE UNSAVE MIDS i 


~\ 


L.L 


8 ( Note that in FIGFORTH the functions SAVE 

9 are called >R and R> » respectively* ) 

10 

11 

12 

13 

14 

15 


is rid UNSAVE 


Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 41 

435 




function which should be part of the The implementor can tailor these func- lists the definitions for SINP and S = 
package. S + will be used as the conca- tions to each individual system. FIGURE This concludes my proposal for string 
tenation function name. Due to the way V shows the definitions for LEN and handling functions for FORTH. I have 
that strings have been defined S + will MLEN. tried to present a string data type which 

have a few restrictions. The location Two more functions which might be will be easy to add new functions to at 
literal strings are stored in, when di- useful to have in the package are string a later date. This is very important in 

rectly executed, rules out their being input (SINP) and string comparison FORTH as the language is so easily ex- 

both arguments of S +. Also the resulting ( S= ). SINP expects the top two stack tended that new functions are con¬ 
string produced by S + will have a maxi- entries to describe the string into which stantly being added. In order to show the 

mum length of 255, as no variable can the input data is to be placed. This should power of these functions I have recoded 

hold more characters than that. S + be a variable. S= assumes the top four the Soundex program which was present- 

will store the new string in a temporary stack entries describe the two strings ed in the MAY 1980 issue of BYTE 

location ana place that address and string which are to be compared. It will return magazine on pages 196-200. Executing 

length on the stack. A null will be ap- a 1 if the strings are identical, including SOUND will cause a prompt for the 

pended to the new string. length, and a 0 otherwise. FIGURE VI name. The name is terminated after 30 

Since one of the arguments of S + 
can be a literal string, we cannot use 
the area at the end of the dictionary as 
temporary storage. An argument could 
be destroyed if we did. Instead we 
will have to create a storage area in the 
dictionary. This could be done with an 
ARRAY definition or any other storage 
reserving method. If the ARRAY data 
type is supported on the system, it is the 
easiest way to reserve space and still 
have access to the address. The temporary 
storage area must be 256 bytes (255 
characters plus a null) long. FIGURE IV 
shows one possible definition of S +. 

Assume that the top two stack values 
define a string called B, while the next 
two values define the string A. S + 
will produce the string (A + B). This new 
string will be truncated after 255 char¬ 
acters, with the first data coming from 
string A. 

A few miscellaneous functions are 
all that is needed to complete the basis 
of our string handling package. These 
include VAL, STR$, LEN and MLEN. 

We shall now look at these individually. 

VAL is used to convert the string 
representation of a number into its 
numeric value. In FORTH this should 
be done with regard to the current 
BASE. When VAL is executed, the top 
two stack values describe the string to 
be converted. Conversion will stop 
at the first non-numeric character. The 
value computed is left on the top of the 
stack. 

STR$ converts a number into a string 
representation of that number. This 
should also be done with regard to the 
current BASE. The top stack value is the 
number to be converted. STR$ will leave 
the address and length of the string 
produced on the stack. A special area can 
be set aside to hold the string or it could 
be treated as a literal string. A null should 
be appended to the end of the string. 

Since precision numbers would require 
a maximum of 7 characters of storage. 

LEN returns the current length of the 
string defined by the top two stack 
entries. MLEN returns the maximum 
length of that string. 

Since VAL and STR$ can make good 
use of routines already a part of the sys¬ 
tem, no definitions are shown for them. 



Page 42 

436 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 




characters or a carriage return. The the code produced. For more information 
Soundex code is then computed and on Soundex codes consult the BYTE 
typed out. The string variable S$ contains article. □ 


FIGURE VII 
Soundex Coder 

0 ( DEFINITION OF SOUNDEX CODER ) 

1 DECIMAL 

2 30 STRING N* 1 STRING K* 1 STRING L* 4 STRING S* 

3 ! NAME C LAST NAME? I TYPE N* SINP 5 
A i FIRST 1 N* LEFT* S* S! i 

5 ! ITH I I N* MID* DROP C@ 64 - f 

6 i KTH DUP “ 01230120022455012623010202* MID* K* S! i 

7 : BLS S* K* S+ S* B! ! 

8 : TEST K* L* S= K* “ 0* S* OR 0= i 

9 ; 1ST DUP 1 < ODER 26 > OR 0- t 

10 ! COMP N* LEN 1 + 2 DO ITH 1ST IF KTH TEST IF BLS THEN 

11 ELSE DROP THEN K* L* 8! LOOP t 

12 : SOUND NAME FIRST N* LEN 2 > IF COMP THEN S* " 0000" 

13 8+ S* S! CR C SOUNDEX CODE* I TYPE S* TYPE CR i 

14 


Some Examples of the String Handling Package 


DECIMAL < I/O in Base 10 ) 

50 STRING ALPHA < create a string variable ALPHA with a 
maximum length of 50 characters ) 

25 STRING BETA ( create a string variable BETA ) 

* NOW IS THE TIME" BETA S! < store the literal string 

NOW IS THE TIME into BETA ) 
BETA TYPE ( output the contents of BETA ) 

NOW IS THE TIME 

BETA LEN . < current length of BETA is 15 > 

15 

BETA MLF.N . < maximum length is 25 ) 

95 

5 10 BETA MID* ( substring consisting of characters 5 thru ; 

of BETA ) 

TYPE < output substring ) 

IS THE 

" AT" 5 6 BETA MID* SUB! ( replace the substring IS with AT 
BETA TYPE ( output new BETA contents ) 

NOW AT THE TIME 

6 BETA LEFT* < substring of characters 1 to 6 of BETA ) 

ALPHA S! < store in ALPHA ) 

ALPHA TYPE ( output ALPHA ) 

NOW AT 

5 ALPHA RIGHT* ( substring of characters 5 to 6 of ALPHA ) 
TYPE ( output, ) 

AT 

BETA ALPHA St < concatenate BETA and ALPHA ) 

ALPHA S' ( store in ALPHA ) 

ALPHA TYPE ( output, new ALPHA ) 

NOW AT THE TIMENOW AT 

ALPHA LEN . ( current length is 21 ) 

21 

" 12345" BETA S! ( new data for BETA ) 

BETA UAL . ( convert string to number ) 

12345 

32760 STR* ( convert number into string ) 

TYPE 

32760 


(continued on page 45) ■ 



Number 50 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 43 

437 















•H 

CL 










»• 


Si 


T-i -X 





Oi 




CJ 


□ 

X 






c 




0j 


r-i 


X 2 

G 




•H 




Cl. CJ 


rs 

in 

re x 

X 








2 


> 

•H 

-r-i 

~ 




X 




2 cn 




X 3 

u 




in 




LU 


£L 

CL 

U 

G 








Cl. Z> 


c 

3= 

re x 

v 




r 




-| Q 


X 

r—i 

X 2 

G 




X 




2 



no 

in 





r-i 




1 


CL 

> 


in 




3 




C 


2 


J: G 









2 r-i 


X 


fB r—i 

G 




G 







c 

t— i—j 

x 


G 


r—1 




O Cl. 


♦ 

G 

u ro 

CJ 


x 


2 




<X 


m 

0 

ns o 

ro 


I> 


•H 




Cl. 3 


CL 

CL 


u 


G 


X 




<r cn 



in 

g n 

ns 


G 


ns 




3 


i—i 


2 ns 

jC 


x 


Ll 




cn a 



CL 

X >- 

u 


G 


£ 




cn 


> 

.— 

s- 





0 




X LU 



X 

x ro 

o 


X 


G 




<T O 


X 


O 

r—i 


2 






2 2 


u 

CL 






G 






re 

I—i 

m c 

X 


X 


£. 




r—1 LL 


X 

■H 

G 

0 


o 


ns 




O 


tf! 

2 

u u 









2 2 



3 

•f-i x 

r 


x 


ot 




H-i 2 


o 


2 m 

X 


c 


rc 




2 


3 

X 

c 

xn 


G 




2 


Cl. 


X 

c 

r-i ns 

c 


£ 


u 


O 


U0 2 



CL 


G 


G 


ro 


H-i 


LiO O 


in 

£ 

G 1 

r-i 






X 


Ci _j 

<•. 

(L 

0) 

2 X 



G 




H-i 




U 

r—i 

x ns 

ro 




c 


2 


cn *• 

2 

•r-i 

CL 

G 



2 


• H 


H-i 


2 U 

CJ 

3 


♦ u 

r 


C 


u 


2 


<L 

i2 

CS 

2 

in u 

x 


o 


X 


UJ 


O 

cn 

Oi 

O 

X 

•H 

X 

G 


in 


H-i 


cn 


t- 

ns 

C G 

3 

2 

G 






2 Q. 

2 


Q> 

G X 



m 


X 


X 


2 2 

G 

Jl 


£ 

2 

> 



G 


<1 


H-i Q 

G 

ns 

X 

G G 

0 

<r 

G 



X» 

cn 


2 2 


u 

G 

f—4 r-i 

CO 

cn 

2 


m 


■cn 


2 

X 

L 


G C. 

G 

cn 

X 


X 


<L 


V * 


m 

2 

£ 


<L 



c 

• 



o 

r—i 


X 

x ns 

». 

cn 

m 


G 

m 

cd 


X 


tn 

xn 

o :< 

tn 


m 


£ 

G 

2 

2 

<X CM 

X 

c 

c 

G 

X 

o 

G 

X 

G i—i 

H-i 

<L 

i2 m 


•r-i 

m 

i- 

c 

t—; 

G 

2 

r-4 

2 

cn 

2 

LC 

* 

£- 

r-i 

G C 

G 


i! 


G 

ro 

X 

H-i 

<1 o 


X 


2 ro 

£ 

X 

ns r-j 


•H 

CO 

CJ 

cn 2 

X 

cn 

CL 

£ 

G 




G 

(- 


LU 




2 

3 J 

1—i 


o 


2 

to 

w 

2 

o 

c\i 


X 

C <T 

G 


X 


X 

> 

o 

-i 

r-j w 

X 

uo c 

fN 

2 O' 

C 


Ci 

ro 

X LO 


S “ Si 
> 01 o 
m £ O 

£ v «T 

■O n g 
<u £ I 


<D 


C O) 

QJ C . 

E‘5 ° 

— «» w 
a Q, a> 

E r T3 

._ -E «o 

i s£ 

-Q c O 

QJ O r_ 

'2 Q)" 

^ E c 

0) L. X: 
o O 0) 

•Stic 


o “ 
E « 


5 o 

C • ° 
CD -L CN 

6 H O 
i- cn 


.2 CN 4 "' 

u S o 

-c = a: 


u i 

< !r 

O 


58 

T3 I- 
CD O 



I i 

« S 

0) 

CD _Q 
■£ O 

W 

a> os 

■S 8 

&•= 

C 0) 

o a 

o > 

+-< 

3 s . 

CD x 

c H 

.2 £oc 

tS tO 

C <0 LL 
£ D) M- 

C 


°n 

& 

cu 

5 

p 


t3 

3 

•S 

■Ct 

c 

o 


> 

L 
CD 
V) 

CO 

a> 

If 
sS 


< co 
b- 


<1 

X 

as 2 


x 

x >- 
cn hi 

Ni Li_ Lu 
O X 
<r 2 

X _i 
£ S iii 
02 2 2 


“0 


2 

X 

2 






c 


Q 

X 

“0 



X 



ns 


2 

cn 



1 




2 


■ 


■ 



FN 






Ni 

X 


cn 




xn 


X 


X 


2 

2 



c 


X 

O 

2 



H-i 


2 

-|-i 


cn 

r-i 

2 


o 



2 

u 




■ 





X 

X 


Ni 

X 



x 



j—. 

m 



X 

CJ 



■cn 





'C 

cn 

CJ 


CD 

2 


2 

£- 




2 

«*. 


«► D> 

*•. 


c 


2 

Ni 



2 

G 


O 

X 


cn 


fN 

2 

cn 

1! 

i~ 




2 

2 

2 

2 

2 

i O' 

2 


in 

2 


o 


2 

<- I 

r—< 

2 

2 

G 

2 

= 


> 



£_ 



C 

2 

X 

■cn 

2 

ti 

!! X 

2 <1 

j> 


•H 


X 

cn 

CJ 

X 


X 3 

o 

2 

X 

■ 

2 

~o 


r-i 

C—i r—i 

x cn 


i_( 

3 

Cl. 

CD 


Ni 


i 


i~: 


Q 

3 

2 

S 


CD 

2 

i: 2 

2D 


*“ 

X 

■ 

X 

>C 

Ci 


CJ CD 

2 




Ni 


cn 

cn 


X 

X 

~i 

cn 


2 r-i 

H-i 


X “0 

X 

2 


' 2 

X 

<r 

CJ 

CD 

X 2 

cn n 

X 

X CJ 

Ci 

2 LS 

X 


<X 2 


2 

Ni X 

CJ 

X 

<r 

2 # 

~r 

2 

r-i 

CZi 

X 

x cn 

<1 

<r 

2 

CW 

X 


2 

C 


u. 

LU 


2 <r 

1 _i X 

cn . 

i X 
H N ■ 

i o o ■ 

' X CJ 

! >-i 2 

-j <r 

* Ni 
i cm © 
2 cj 

i co LU 

: ~o cn 

X ^ 

X X 
X X 
■ 2 
CO X 
2 2 
i Q_ H-i 


■ cn ^ 
2 

• Ni 2 
<r x 

H-i 

i X 


CJ 

* 2 


i O' 

cm 


LU ~ 
2 


x cn 
<r "5 « 




o 

# 


CJ 

CO 



2 

2 


X 



2 

X 

2 


X 


Q 



cn 

2 

X 

<r 

X 

2 

2 


2 

X 

ii 

2 


_i 

2= 

\ 





_ 

2 

"0 


X 

2 

a 

2 

CD 

2 

CJ 

T 

fN 

X 







cn 

2 


* 

2 

2 


D> 

2 

H-i 





2 

2; 

2 

<E 




2 

X 


o 

X 


O 

* 


2 

cn 

2 

2 

; 


H-i 

3 



i 

X 

i—i 

Q 

2 

2 

2 

X 


<r 

■cn 

2 

cn 

O 

X 

2 

CD 

CO 



<r 

2 = 

_j 



CO 

2 

u 

X 

X 

2 

CD 

2 

2 


CO 

2 


2 


2 




C-i 

CO 

2 


X 

cn 

X 

2 

X 

2 

2 

<L 

2 

2 

<E 


2 

cn 

■ 


o 

<E 



CO 



X 



_i 

2 


CD 

X 


X 

<L 2 


_J 

iiO 


2 

2 


X 

*• 

2 

=* 


C 


OS 

r-i 

H-i 

C-4 

H-i 

2 

2 


SD 

X 



Ni 

H-i 

CJ 

H-i 



X 

=* 

* 

OS 

CJ 

o 

2 

X 2 

H—< 

Ni 


CJ X 
X 


Ni i 
X 

2 <r 

H-i O i 

X LU I 

2 2 
«-« 2 i 

<z cm I 

x 

cn u i 
2 ! 
i X H-i 

H-i 

‘ n : 

GO i 
• C\J O' 


> CO 
CM 2 

2 


X 

X 


2 

HH X 
Ll. Ci 
Ci 2 


M . 
2 ■ 


<T 4±= 
X a 

: cn uj c 
x^x 


2 

CD 


cn 

cn 

* 


o 

2 


jx cn 

C H-i iXi 

X 2 <1 


: cj cj uo ♦♦ 
* cm ro <r iio 'C 


o ** ** *♦ •• ** - 

N CO O' O r-i CM 1 


* LU 
~ 2 ; 

SO i 
X 

2 2 


CJ 

cn 


lu <r o 
2 J CJ 


^ c-i r ; u' >c n cc 


—i u I— Ci Ld 

i Ni LU LU X X 

Ni 2 -J CO CO 

LU 2 LU * 


CJ 

CJ * 
00 

o 

<r 


2 

O ; 

H-I I 

x 2 i 

H-i LU ‘ 
2 _i 
H-i 00 i 
Ll. 2 
LU LU 
SO CO 
CO 

-j <r 
<r 

D X 
LU 


X 

O 

2 

<T 


<X 


2 

3 


<L 

cn 

cn 

3 


CJ 

cn 

x 

2 

2 

r—i 

O' 

2 


2 

_i_ 

2 

2 X 

X 

<r 

X 2 


3 

CJ 2 

rH 

cn 

2 



<E 2 

2 

x 


cn 


s 

2 

* 

CO 

2 

a 

X 

2 


i .1 

cn 

<r 2 

i 

in 

2 X 

X 

D 

- ~D 


2 <- 

2 ' 


2 * 

cn CD 

2 

<T 

“S 2 

H-i 

3 2 

X 


cn c 


i 

2 

X 

ii 

2 2 

2 2 


H-I 

=> X 

Ci 

2 

2 “S 

c« 

X <1 

2 


H-i 3 


a 

2 cn 

C5 

2 

H-i 

CJ 2 


2 2 

2 ' 

2 

2 

2 


a 2 


2 2 CJ 

x cn .2: 

X -r-i ""2 2 2 2 

H-i o LU 2 

CD Q_ ' 2 2 X 

H-i 2 X 2 O -J 

2 CJ X 'H <1 

2 _J 2 2 

LU it CO <1 H-i LU hh 

2 2 2 CD L0 CJ | 

O ni 2 2 2 

:c * x ** 2LU2 

i NS LO N O O' O r-i C-i fO ij". I 

r-i r— r—i —-i r—i r—t 1 


Number 50 Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia Page 45 

438 





















—FI BSEB DIME— 

JIVIIR IM iM Il 


w. 


by Kenneth Drexler 


If you want to get away from the slow speed, paper costs 
and noise of a teletype or other hard copy terminal, try a 
video display. Here is a 6800 video display program for use 
wih a memory mapped video board such as SSM’s VB1 or 
others using a IK display memory. 

The program has a full range of commands including: 
Cursor Up, Cursor Down, Cursor Right, Cursor Left, Cursor 
On and Off, Home, Erase to End of Line, Backspace, Screen 
Clear and, of course, Carriage Return and Line Feed. This 
displayed line and page length may be varied up to a maximum 
size of 64 characters by 16 lines. All data before being dis¬ 
played by the program are checked against high and low 
masks to see if the data falls within the limits set by these 
masks. By changing these masks which are located in RAM, 
it is possible to limit the characters to a subset of the full 
ASCII alphabet, such as capital or lower case letters only. 

The program occupies 435 bytes of memory, is fully re¬ 
locatable, and may be placed in ROM. It uses 16 bytes of 
RAM as temporary storage. The RAM may be located any¬ 
where in memory. The only address constraint is that the 
IK video display RAM must be located starting on a IK 
boundary ($0000, $0400, $0800, etc.) The program uses 12 
of the 32 ASCII control codes ($0400, $0800, etc.) The 
program uses 12 of the 32 ASCII control codes ($00-$IF) 
for control. 

Use of the program is simple. The character to be displayed 
(or control code) is placed in the A Register and a subroutine 
branch or jump to the program executed. The program then 
stores the character in the A Register at the cursor location 
in the video display RAM (or executes the appropriate control 
function), computes the address of the next character to be 
displayed, and, if the cursor is enabled, stores the cursor char¬ 
acter at the new location. After setting VNRDY, if neces- 
say, control is returned to the calling program. All registers 
are preserved. 

Sixteen random access memory locations are used to store 
variables used by the Program. These variables are listed in 
Figure No. 1. The first eight of these, LLNTH, PGLNTH, 
MASKLI, MASKHI, PAGE, VNRDY, CURSOR and CURBIT 
may be changed to alter the display characteristics. Thus the 
data stored at cursor ($FOA6) is used by the program as the 
cursor and by changing this data the cursor character may be 
changed. LLNTH ($FOA6) and PGLNTH ($FOAl) contain 
hex characters used by the program as the maximum line and 
page length, respectively. These bytes also control when a car- 

Kenneth Drexler-Three Embarcadero Center, Suite 2300, 
San Francisco, CA 94111 


riage return and line feed is generated by the program and 
when the display page is full. 

FIGURE 1: RAM VARIABLES 


NAME 

ADDRESS (Hex) 

FUNCTION 

LGNTH 

FOAO 

Line Length 

PGLNTH 

FOAI 

Page Length 

MASKLO 

FOA2 

Low Mask for Data 

MASKHI 

FOA3 

High Mask for Data 

PAGE 

FOA4 

Page Control, 0 = Off, 1 = On 

CURBIT 

FOAS 

Cursor Control, O-Off, 1-On 

CURSOR 

FOA6 

ASCII Code for Cursor 
Character 

VNRDY 

FOA7 

Full Page Flag, 1 = Full Page 

CURSAV 

FOA8 

Storage for Data under Cursor 

VSAVX 

FOA9 

Storage for the X Register 

CHAR 

FOAB 

Character psoition (0-63) 

LINE 

FOAC 

Line number (0-15) 

CHRPSN 

FOAD 

Memory address for the next 
character to be displayed 


Each of the first eight RAM locations must be initialized 
before the first subroutine call of the progam. A routine to 
perform this function is included in the listing. It sets the 
RAM locations to the initial values shown in Figure 2. The 
remaining variables are used by the program and should not be 
changed. 

FIGURE 2: INITIAL RAM VALUES 


BYTE 

VALUE 


(Decimal) 

LLNTH 

32 

PGLNTH 

15 

MASHLO 

32 (ASCII Space) 

MASKHI 

127 (AS11 Rubout) 

PAGE 

0 (Off) 

CURBIT 

25 5 (On) 

CURSOR 

62 (ASCII >) 


The PAGE feature requires some explanation. The PAGE 
feature is enabled if PAGE ($FOA4) is set to some value 
other than zero. When PAGE is enabled, after the location 
for display of the next character is computed, the program 
determines if this location is at the end of the page determined 
by LLNTH and PGLNTH. If it is, VNRDY set to “1” and no 
further characters are accepted for display. The program con- 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 46 


Number 50 

439 



tinues, however, to accept control characters, which allow the 
display RAM to be cleared or the cursor to be moved. □ 


usins 


♦THIS PROGRAM IS RELOC¬ 
ATABLE. THE VIDEO RAM 
♦MUST BE LOCATED ON A 
♦IK BOUNDARY. 

♦RAM ADDRESSES* 


000H 27 57 

6EQ 

VLF 

008C 81 OD 

CMPA 

#CR 

080E 27 5A 

BEQ 

VCR 

0918 81 15 

CMPA 

#ETOND 

0812 27 5D 

BEQ 

ERASLN 

0014 81 16 

CMPA 

#CLEAR 

0816 27 5D 

BEQ 

CLSCRN 

0818 81 0B 

CMPA 

tCUP.UP 

001A 27 5B 

BEQ 

CURUPP 

001C 81 84 

CMPA 

#CURDN 

001E 27 43 

BEQ 

VLF 

0028 81 06 

CMPA 

#CURFW 

0022 27 5A 

BEQ 

CURFWD 

0024 81 8E 

CMPA 

#CURBK 


F0A8 


ORG 

$F0A0 

0026 27 5D 


BEQ CURBAK 

F0A8 

LLNTH 

RMB 

1 

8028 81 10 


CMPA #HQMUP 

F0A1 

PGLNTH 

RMB 

1 

002A 27 68 


BEQ HOME 

F0A2 

MASKLO 

RMB 

1 

002C 81 08 


CMPA #BS 

F0A3 

MASKHI 

RMB 

1 

082E 27 66 


BEQ DELPRV 

F0A4 

PAGE 

RMB 

1 

0038 81 18 


CMPA tCAN 

F0A5 

CURB IT 

RMB 

1 

0032 27 6F 


BEQ CANCEL 

F0A6 

CURSOR. 

RMB 

1 

0034 81 17 


CMPA #CRONOF 

F8A7 

VNRDY 

RMB 

1 

0036 27 74 


BEQ CURTOG 

F0A8 

CURSAV 

RMB 

1 


♦CHECK 

FOR FULL PAGE 

F0R9 

VSAVX 

RMB 

2 

0038 7D F0 A7 


TST VNRDY 

F0AB 

CHAR 

RMB 

1 

003B 26 20 


BNE VEXIT 

F0AC 

LINE 

RMB 

1 


♦CHECK 

DATA V MASKS 

F0AD 

CHRPSN 

RMB 

2 

003D 81 F8 A2 


CMPA MASKLO 





0048 2D IB 


BLT VEXIT 

DC08 

VRAM 

EQU 

$DC00 

0842 B1 F0 A3 


CMPA MASKHI 

00C-C 

VRAMHI 

EQU 

$DC 

8045 22 16 


BHI VEXIT 






♦STORE 

DATA, COMPUTE 


♦VIDEO 

COMMANDS* 


♦NEW POSITION 





8047 A7 88 


STAA 8,X 

000D 

CR 

EQU 

$D 

0049 7C F0 AB 


INC CHAR 

000H 

LF 

EQU 

$A 

004C 8D 65 

VUP 

BSR GPSN1 

000B 

CURUP 

EQU 

$B CTRL K 


♦SAVE DATA AT NEW POS- 

0006 

CURFW 

EQU 

$6 CTRL F 


♦ITION, 

INSERT CURSOR 

000E 

CURBK 

EQU 

$E CTRL N 

004E A6 08 


LDAA 0,X 

0004 

CURDN 

EQU 

$4 CTRL D 

0858 87 F8 A8 


STAA CURSAV 

0017 

CRONOF 

EQU 

$17 CTRL W 

0053 7D F8 A5 


TST CURBIT 

0016 

CLEAR 

EQU 

$16 CTRL V 

0856 27 85 


BEQ VEXIT 

0015 

ETOND 

EQU 

$15 CTRL U 

8058 86 F8 A6 


LDAA CURSOR 

0008 

BS 

EQU 

$8 CTRL H 

085B A7 08 


STAA 0,X 

0010 

HOMUP 

EQU 

$18 CTRL P 


♦RESTORE REGS AND EXIT 

0018 

CAN 

EQU 

$18 CTRL R 

085D 32 

VEX IT 

PULA 





005E 33 


PULB 

0008 


ORG 

$0080 

005P FE F0 A9 


LDX VSAVX 





0062 39 


RTS 


♦ENTRY 

AND I 

MAIN LOOP* 









♦VIDEO 

SUBROUTINES* 


♦SAVE 1 

REGIS 

TERS 




0000 37 

VIDEO 

PSHB 


0063 8D 58 

VLF 

BSR RPLCUR 

0001 36 


PSHA 


0065 7C F0 AC 


INC LINE 

0002 FF F0 A9 


STX 

VSAVX 

8068 28 E2 


BRA VUP 

0005 FE F8 AD 


LDX 

CHRPSN 

006A 8D 49 

VCR 

BSR RPLCUR 


♦CHECK 

FOR i 

COMMANDS 

006C 7F F8 AB 


CLR CHAR 

0088 81 8A 


CMPA 

#LF 

006F 20 DB 


BRA VUP 


(continued) 


Page 47 


Number 50 

440 


Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia 



0071 8D 48 

ERflSLN BSR 

ETENO 

4 




0873 20 D7 


BRA 

VUP 

00EB 26 F6 


BNE 

SCLOP 

0675 20 52 

CLSCRN BRA 

ESCRN 

08EO B6 F0 A1 


LOAA 

PGLNTH 

0077 8D 30 

CURUPP 

BSR 

RPLCUR 

00F8 B7 F0 AC 


STAA 

LINE 

0879 7A F0 AC 


OEC 

LINE 

08F3 7F F0 AE 


CLR 

CHAR. 

007C 28 CE 


BRA 

VUP 

00F6 80 4B 


BSR 

VPSN 

007E 80 35 

CURFWD 

BSR 

RPLCUR 

08F8 80 Cl 


BSR 

ETENO 

0888 7C F0 AE 


INC 

CHAR 

08FA 33 


PULB 


0883 28 C7 


BRA 

VUP 

00F8 32 


PULA 


0085 80 2E 

CURBAK 

BSR 

RPLCUR 

08FC 39 


RTS 


0887 7A F0 AE 


DEC 

CHAR 

00FO 28 CA 

ESCRN2 

BRA 

ESCRN 

088A 28 C0 


BRA 

VUP 


♦GET NEW POSITION, 

008C 80 27 

HOME 

BSR 

RPLCUR 


♦AC-JUST CHAR AND LINE 

088E 7F F8 AE 


CLR 

CHAR 

00FF 37 

GPSN 

PSHB 


0891 7F F0 AC 


CLR 

LINE 

0109 36 


PSHA 


0894 28 B6 


BRA 

VUP 

0101 F6 F0 AE 


LOAB 

CHAR. 

0896 80 10 

0ELPRV 

BSR 

RPLCUR. 

0184 2A 0B 


BPL 

NEXT1 

0898 7A F0 AE 


DEC 

CHAR 

0106 F6 F0 A0 


LOAB 

LLNTH 

009B 80 16 


BSR 

GPSN1 

0189 F7 F0 AB 


STAB 

CHAR 

0090 86 20 


LOAA 

#$20 

018C 7A F0 AC 


OEC 

LINE 

089F A7 06 


STAA 

0, X 

018F 28 88 


BRA 

VCOK 

00A1 28 AE 


BRA 

VUP+2 

0111 FI F0 A8 

NEXT 1 

CMPB 

LLNTH 

00A3 7F F0 AE 

CAN13EL 

CLR 

CHAR 

0114 23 86 


BCS 

VCOK 

00A6 80 06 


BSR 

GPSN1 

0116 7F F0 AE 


CLR 

CHAR 

00A8 80 11 


BSR 

ETENO 

0119 7C F8 AC 


INC 

LINE 

08AH 28 A0 

VUP1 

BRA 

VUP 

011C F6 F0 AC 

VCOK 

LOAB 

LINE 

08AC 80 07 

CURTOG BSR 

RPLCUR 

011F 2A 04 


BPL 

NEXT2 

08AE 73 F0 A5 


COM 

CURBIT 

0121 7F F0 AC 


CLR 

LINE 

0061 28 9E 


BRA 

VUP+2 

0124 5F 


CLRB 


00E3 28 4A 

GPSN1 

BRA 

GPSN 

0125 F0 F0 A1 

NEXT2 

SUBB 

PGLNTH 

0885 B6 F0 A8 

RPLCUR LC-AA 

CURSAV 

0128 2F 0F 


BLE 

VLOK 

0868 A7 80 


STAA 

0 .. X 

012A 70 F0 A4 


TST 

PAGE 

006A 39 


RTS 


0120 27 05 


BEQ 

VSCRL 

00BB 86 40 

ETENO 

LOAA 

#$40 

012F 7C F0 A7 


INC 

VNRDY 

08BO B8 F8 AB 


SUBA 

CHAR 

0132 28 08 


BRA 

PSNXT 

08C0 C6 20 


LDAB 

#$20 

0134 80 A8 

VSCRL 

BSR 

SCROLL 

0802 E7 08 

ETL0P 

STAB 

Or X 

0136 5A 


OECB 


00134 08 


I NX 


0137 26 FB 


BNE 

VSCRL 

08133 4A 


OECA 


8139 7F F0 A7 

VLOK 

CLR. 

VNRC-V 

00136 26 FA 


BNE 

ETLOF 

813C 80 05 

PSNXT 

BSR 

VPSN 

00138 39 


RTS 


013E 32 


PULA 


0009 CE 00 08 

ESCP.N 

LDX 

#VRAM 

013F 33 


PULB 


00CC 86 20 


LOAA 

#'■ 

0140 39 


RTS 


08CE A7 08 

ESLOP 

STAA Or X 

0141 20 BA 

ESCRN1 

BRA 

ESCRN2 

000-0 88 


I NX 



♦COMPUTE CHRPSN= 

000-1 80 E0 08 


CPX 

#VRAM+1024 


♦64+LINE+CHAR+VRAM 

0004 26 F8 


BNE 

ESLOP 

8143 7F F8 AO 

VPSN 

CLR 

CHRPSN 

0806 7F F0 AB 


CLR 

CHAR 

0146 7F FO AE 


CLR 

CHRPSN+1 

000-9 7F F0 AC 


CLR 

LINE 

0149 B6 FO AC 


LOAA 

LINE 

080-0 20 00 


BRA 

VUP1 

014C C6 86 


LOAB 

#6 

08OE CE DC 08 

SCROLL 

LOX 

#VRAM 

014E 48 

VGLOP 

ASLA 


00E1 36 


PSHA 


014F 79 F9 AC- 


ROL 

CHRPSN 

08E2 37 


PSHB 


0152 5R 


OECB 


00E3 A6 40 

SCLOP 

LOAA 

$40 r X 

0153 26 F9 


BNE 

VGLOP 

00E5 A? 08 


STAA 0,X 

0153 B8 F9 AE 


ADDA 

CHAR 

08E7 08 


I NX 


0158 24 03 


BCC 

VPSN1 

08E8 80 OF 08 


CPX 

#VRAM+1024-6 

015A 7C F0 AO 


INC 

CHRPSN 


Page 48 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Number 50 

441 



0150 B7 F8 RE 

'v'PSNl STflfi CHRPSN+1 

0168 86 DC 

LDRR #VRRMHI 

0162 ee F 8 flO 

RDDR CHRFSN 

0165 87 F0 RD 

STflfi CHRPSN 

0168 FE F8 RO 

LDX CHRPSN 

0168 39 

RTS 

016C 01 

HOP 

0160 81 

NOP 

016E 81 

NOP 

016F 01 

NOP 

♦INITIALIZE VIDEO RfiM* 

♦CLEAR F8R8-F0RF 

0178 CE F8 R0 

VDINZ LDX #LLNTH 

0173 86 18 

LDRR #$18 

0175 6F 08 

VNZLOF CLP. 0/X 

0177 08 

I NX 

0178 4fi 

DECR 

0179 26 FR 

BNE VNZLOP 

♦SET: LLNTH=$28, PGLNTH 
*=$0F, MRSKL0=$28 
♦HRSDHI=$7F, CURSOR=>r 
*CURSOP=ON 

0178 CE F0 R8 

LDX ILLNTH 

017E 86 28 

LDRR #$28 

0188 R7 08 

STAR 8,X 

0182 R7 82 

STAR 2 , X 

0184 86 0F 

LDRR #$P 

0186 R7 81 

STAR 1,X 

0188 86 7F 

LDRR #$7F 

818R R7 83 

STAR 2 ,X 

018C 86 FF 

LDRR #$FF 

818E R7 85 

STAR 5.. X 

8190 86 3E 

LDRR #-> 

0192 R7 86 

STAR $6, X 

0194 28 RE 

BRR ESCRN1 

END 

NO ERROR< 

:S) DETECTED 


SlfTlEDI TFIELE 


BS 

0888 

CRN 

0018 

CANCEL 

08R3 

CHRP 

FORE 

CHRPSN 

FORD 

CLERR 

0016 

CLSCRN 

0875 

CR 

000D 

CRONOF 

0817 

CUR6RK 

0885 

CURBIT 

F8R5 

CURED 

000E 

CURDN 

0084 

CURFN 

0086 

CURFWO 

087E 

CIJRSRV 

F0R8 

CURSOR. 

F8R6 

CURTOG 

08AC 

CURUP 

088E 

CURUPP 

0077 

DELPRV 

0096 

ER.RSLN 

8071 

ESCRN 

88C9 

ESCRN1 

0141 


ESCRM2 

80FD 

ESLOP 

80CE 

ETEND 

008E 

ETLOP 

00C2 

ETOHO 

0015 

GPSN 

00FF 

GPSN1 

88B3 

HONE 

008C 

HOHUP 

0818 

LF 

000H 

LINE 

F8RC 

LLNTH 

F0R8 

MASKHI 

F8R3 

MASKLO 

F0R2 

NEXT1 

0111 

NEXT2 

0125 

PRGE 

F0R4 

PGLNTH 

F0R1 

PSNXT 

013C 

RPLCUR 

0885 

SCLOP 

08E3 

SCROLL 

00DE 

VCOK 

011C 

VCR 

006R 

VDINZ 

0170 

VEX IT 

085D 

VGLOP 

014E 

VIDEO 

0000 

VLF 

0863 

VLOK 

0139 

VNRDV 

F0R7 

VNZLOF 

8175 

VPSN 

8143 

VPSNl 

015D 

VRRH 

DC88 

VRAMHI 

00DC 

VSRVX 

F0RS 

VSCRL 

8134 

VUP 

084C 

VUP1 

80RR 


Elfl 



Number 50 

442 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 49 




etters 


... AND MORE ON TOP-DOWN 

Dear DDJ: 

In DDJ # 48, John Culleton, Jr. defended his statement 
that PASCAL does not support top-down programming in the 
physical construction of the program. I would like to say as an 
educator and programmer that I agree fully with his position 
that a language that does not have regard for the physical lay¬ 
out of the program can hardly be called a top-down structured 
language. In the final analysis, the physical layout of the pro¬ 
gram is what people will read and study, like a book, when try¬ 
ing to understand the program. Without logical placement of 
the program code, just reading the source listing can be next to 
impossible, especially on a long program. In this respect, a 
good BASIC compiler might be more useful than PASCAL, if 
the language is used properly in a modular way. 

I am seriously reconsidering my jump on the PASCAL 
bandwagon, for a return to a language that can produce read¬ 
able, understandable listings, that can be read in magazine arti¬ 
cles without a computer science degree. The introduction of 
CP/M and the BASIC compiler from Microsoft for the Apple, 
with it’s chain and global commands just might offer a more 
useful programming environment than PASCAL when it comes 
to creating understandable and readable programs. 

My experience so far indicates that people are not going to 
take to PASCAL without a lot of previous programming ex¬ 
perience, as the Apple version has already proven that using 
PASCAL requires a lot of big system savvy on the part of the 
user, and simple implementation of previous BASIC functions 
like PEEK and POKE require tremendous machine sophistica¬ 
tion on the part of the user in creating library units or linking 
small assembly subroutines. Contrary to popular belief, PAS¬ 
CAL is definitely not for the beginning programmer. And 
without clear, logically organized program layouts, I am not 
sure it’s right for the professional production programmer 
either, as one thing is constant in industry, and that is that 
programmers come and go like street cars, and it’s a sure bet 
the programmer who starts that big PASCAL project, won’t be 
the one who finishes it. 

Regards, P.O. Box 701 

David E. Smith Placentia, CA 92670 


However, if I choose to do my coding at the terminal, I 
can enter the main line routine first, then insert the subordi¬ 
nate routines before it, and so on. Any text editor will let you 
do that. 

It is true that the physical sequence required by PASCAL 
makes it a little awkward to read a program, but I believe that 
it only takes a little getting used to. I agree that this is a dis¬ 
advantage of PASCAL, but the ability to compile in one pass 
simplifies the compiler and undoubtedly allows it to run in 
less memory space. On a small computer, this is a tradeoff well 
worth making. 

Very truly yours, 1724 Blakemore Rd. 

Jim Scott Richmond, VA 23225 


Dear DDJ: 

It would be a pity if potential users of PASCAL were put 
off by John Culleton’s remarks in his letter {DDJ #48), which 
seem to be based on a misunderstanding. Top-down program¬ 
ming in PASCAL is simple and straightforward. 

First, standard PASCAL has a FORWARD directive, which 
allows a procedure to be called before its body is presented to 
the compiler. (See the Draft Standard, Secs 6.6.1,6.6.2 in the 
May 1980 issue of Pascal News.) This facility is necessary, 
since without it one could not compile co-routines, which call 
each other. 

Second, and more practically, any reasonably large program 
to be compiled on a micro or mini is going to have to make use 
of the EXTERNAL directive, which calls separately compiled 
procedures stored in a library. This is not standard PASCAL, 
but every PASCAL system I have seen provides for it. You 
want your utility programs in a library anyway, so that you 
can call them whenever you like without having to retype 
them at program entry via keyboard, disc, or whatever. 

In my opinion, PASCAL is the ideal language for the user 
of small computers. (Large ones, too, for that matter, but DDJ 
is the small user’s guide and vademecum, and we are looking 
out for them in the letter column.) It demands discipline; if 
properly used it makes for readable and maintainable pro¬ 
grams; and you can do anything with it that you ought to 
want to do anyway. As compared to the pitchfork, spade and 
overalls approach of the average FORTRAN/BASIC user it will 
cut debugging time at least in half. Let’s don’t badmouth it by 
mistake. 

Sincerely, AVB Associates, Inc. 

Arthur A. Brown Box 326 

Garrett Park, MD 20766 


MISCELLANEA 


Dear DDJ: 

In DDJ #48 John R. Culleton, Jr. gave a detailed argument 
as to why he believes top-down programming is impossible in 
PASCAL. His entire argument hinges on one sentence in the 
middle of the sixth paragraph: 

“Note that the physical sequence of the modules is also the 

order in which they are written.” 

J can find no reason for this statement. A programmer is free 
to code his modules in any order he pleases, and then put 
them into any physical sequence he pleases. 

I use PASCAL on my home computer, and I use top-down 
programming. Usually I code the whole program on paper 
first. I start, of course, with the main line module, then the 
modules subordinate to it, and so on, ending with any little 
utility modules that may be required. Then I key them in, usu¬ 
ally in the physical order required by PASCAL. 


Dear DDJ: 

Your readers might like to know that the American Sub¬ 
standards Committee X. 1.5 has recently partially approved a 
new phonetic alphabet for voice communications. Here it is: 


LETTER CODEWORD 


A AISLE 

B BDELIUM 

C CZAR 

D DJAKARTA 

E EUPHORIA 

G GNOME 

H HOUR 

I IAN 

J JOSE 

K KNIGHT 

L LLAMA 



Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 50 


Number 50 

443 



M 

MNEMONIC 

O 

OEDIPAL 

P 

PHONETIC 

Q 

QUEUE 

R 

RWANDA 

T 

TSAR 

U 

URN 

V 

VELDT 

w 

WRONG 

X 

XANADU 

Y 

YVONNE 

Z 

ZWIEBACK 


A typical example of the alphabet in use is this recent ex¬ 
change : 

RECORDING: You really can help keep your phone costs 
down, just by looking up numbers in your 
phone book, whenever possible. Thanks for 
helping. 

MA BELL: City and number, please? 

CALLER: Taco Bell in San Francisco. 

MA BELL: Was that “Paco Bell?” 

CALLER: No, “TACO.” “T” as in tsar, “A” as in aisle, “C” 
as in czar, “O” as in Oedipal. 

MA BELL: Was that “C” as in czar or “T” as in tsar? 

CALLER: Yes. 

MA BELL: Oh. 

Mike Gabrielson M. Gabrielson 

Bob Phillips P.O. Box 2692 

Ron Adler Stanford, CA 94305 

Tom Martin 
Jim Munro 
Glenda Core 


NON-HANDSHAKING SOLUTIONS 

Dear DDJ : 

In the August issue of Dr. Dobb’s Journal, you published 
my letter concerning the non-handshaking situation between 
my Heath H-14 printer and my North Star Horizon serial 
interface. Thanks to your audience, I was deluged with letters 
as well as phone calls. Software solutions outnumbered hard¬ 
ware solutions about two-to-one. 

One hardware solution I received was to interchange pins 
4 and 7 at the Heath connector to reverse the RTS and NOT- 
RTS signals. The gentleman claimed his H-14 was connected 
to serial port 2 of a North Star Horizon and stated that his left 
configuration header, package 3D, was wired the same as both 
my configuration headers are. Since the right configuration 
header, package 4D, controls the second serial port, his solu¬ 
tion may have worked for him, but not for me! 

The simplest hardware solution was provided by A1 Weiner 
of Waltham, Massachusetts. Without rewiring the Horizon 
header at 4D, all I had to do was change the Heath end of the 
cable to move DB-25 connector pin 20 to Heath connector 
pin 4 to tap the NOT-RTS signal provided in the Heathkit 
modification on DB25 connector pin 15. A1 even provided a 
three-line BASIC program to prove that the hand-shaking was 
working at 4800 baud! 


At first, the solution didn’t work. I finally hooked up my 
TVOM and discovered I didn’t have the NOT-RTS signal at 
the printer (although I had followed the modification instruc¬ 
tions during assembly). I had never opened the printer since 
its first visit to Heathkit Electronics Center in Seattle and as¬ 
sumed that they had checked it out thoroughly. 

They certainly did! Even though I advised them of the 
modification number, they ripped out the additional wiring 
underneath the PC board! I’ve rewired the mod, and my H-14 
is running along at 4800 baud with full handshaking under 
CP/M as well as N*DOS. The fix would have been imple¬ 
mented two weeks ago instead of this morning had HEC told 
me of their action months ago. 

Thanks to everybody who replied to my previous letter to 
the editor—it’s nice to know I’m not alone in the wilderness 
without help! And thank you, Dr. Dobb’s Journal, for publish¬ 
ing my complaint which triggered all the response. 

Cordially, 4807 15th Ave. S.E. 

John R. Dye, CPD Lacey, WA 98503 


Editor’s note: Herewith an example of the response to J. Dye: 


Dear DDJ. 

This letter is being printed on an H-14 connected to serial 
port 2 of a North Star Horizon using stock I/O drivers for 
North Star/UCSD PASCAL; communication rate is set at 4800 
baud. I think that we can conclude that the incompatibility 
discussed in the referenced letter can be readily resolved. 

First of all, the North Star software does not respond to 
the software interrupt handshaking provided by the DEC- 
style XON/XOFF signalling. It does not need to since the 
handshaking can be accomplished using RTS and CTS control 
lines which are incorporated in RS-232C. These lines are 
properly handled by the North Star software 

There are several generations of H-14 printers each having 
a different handshaking arrangement. To determine which one 
you have, read the description of the interface on H-14 
OPERATION manual page 9, being sure to incorporate any 
change notices into the manual first. Some of the earlier print¬ 
ers have a printer busy signal on pin 20 of the DB-25 connec¬ 
tor which goes positive when the printer can accept data. The 
current printer has a similar signal on pin 15 of the DB-25 
connector. In these later printers there is also an inverted busy 
signal on pin 4 of the DB-25 connector. Unfortunately, none 
of these connections is compatible with the configuration 
header wiring scheme on page 72 of North Star’s HRZ-D-DOC, 
What is needed is to present a signal on pin 4 of the DB-25 
connector that will go positive whenever the printer can accept 
characters. 

Page 8 of the H-14 OPERATION manual shows that by 
exchanging pins at the end of the RS-232C cable opposite the 
DB-25 connector, we can provide the correct signal on pin 4. 
To do this on the later H-14, all one needs to do is use a sharp 
tool to extract pins 4 and 7 of the connector, exchange them 
and reinsert them. On the earlier H-14, pins 14 and 7 need to 
be exchanged. 

To complete the interface, the left configuration header, 
package 3D, on the North Star motherboard must be strapped 
as follows (reference page 72 of HRZ-D-DOC): 


pin 1 to pin 12 
pin 2 to pin 16 
pin 3 to pin 15 
pin 4 to pin 14 
pin 5 to pin 11 
pin 7 to pin 8 
pin 9 to pin 10 



Number 50 

444 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 



This interface will allow the USART, package 3A, and the 
Software which controls it to interface the H-14 at any baud 
rate up to and including 4800. 

Sincerely, 2281 Cobble Stone Court 

Robert Rennard Dayton, OH 45431 


CP/M COMPATIBLE SOFTWARE MARKETING 

Dear DDJ: 

As the developers of CP/M and MP/M, Digital Research is 
preparing a list of vendors of CP/M-compatible software. We 
would appreciate the help of readers of your magazine in com¬ 
piling this list for distribution to all interested persons who 
contact us. 

If any readers are currently marketing CP/M-compatible 
software, please send us any or all literature pertaining to your 
software which controls it to interface the H-14 at any baud 
rate up to and including 4800. 

Thank you, Digital Research 

Marilyn Darling P.O. Box 579 

Pacific Grove, CA 93950 

AT ODDS WITH DDJ 

Dear DDJ: 

1 have received my copies of Volume 5, Issue 8 of DDJ, 
which contains my article ( A Note On 6502 Indirect Addres¬ 
sing), and I am slightly upset. 

I have about 70 papers to my credit, in all kinds of journals, 
and this is the very first time that I have not had the courtesy 
of having galley proofs to review before an article of mine is 
printed. 

I understand about your policy of quick publication; I want 
to see my ideas on programming published as quickly as pos¬ 
sible, too —but not with typists’ mistakes still in them! Typists 
are not infallible, nor should they be expected to be. For the 
record, the mistakes were as follows: 

P. 26 col. 1 line 37: “is keep” should be “is to keep” 

P. 26 col. 3 line 34: left paren should line up under I 
P. 27 col. 1 line 57: “each by” should be “each time by” 

P. 27 col. 3 line 11: [1] refers to reference number 1, 
which is not marked as such. (I don’t mind if you want to 
set up your own conventional notation for references to 
journal papers and books, but it has to be consistent with 
itself.) 

None of these turned out to be really serious, in this case— 
which is why I am slightly, rather than considerably, upset. 

Sincerely, George Washington University 

Professor W. D. Maurer S.E.A.S. 

Washington, DC 20052 

Prof. Maurer’s objection is well taken and the subject of this 
month’s editorial (see p. 1). -JP 


SIGNED COMPARISON: ALTERNATE ROUTINE 

Dear DDJ: 

While scanning the listing of the runtime library for the 
Small C compiler in issue #48,1 happened to notice the signed 
compare routine (“cccmp”). This routine performs a compari¬ 
son of two 16-bit signed numbers (two’s complement) by sub¬ 
tracting one of the numbers from the other and then examin¬ 
ing the sign of the result. This technique works fine as long as 
the difference between the numbers being compared is less 

Page 52 


than or equal to 32767; however, if the numbers differ by 
more than 32767, the result of the compare will be incorrect 
due to arithmetic overflow during the calculation. 

A different way to accomplish a signed comparison is to 
invert the sign bits of the two numbers being compared and 
then to perform an unsigned compare using the new numbers. 
A routine using this technique is shown below: 

; Common routine to perform a signed compare of DE &HL. 

; This routine compares DE & HL and sets the conditions: 

; Carry reflects sign of difference (set if DE < HL) 

; Zero/non-zero set according to equality. 


) 

cccmp: MOV 

A,H 

; invert sign of HL. 

XRI 

80H 


MOV 

H,A 


MOV 

A,D 

; invert sign of DE. 

XRI 

8 OH 


CMP 

H 

; compare msbs. 

JNZ 

cccmpl 

; unequal —comparison done. 

MOV 

A,E 

; equal—compare lsbs. 

CMP 

L 


cccmpl: LXI 

H,1 

; (required by Small C). 

RET 




This new method works by mapping the signed number do¬ 
main into the unsigned number domain, where 16-bit com¬ 
parisons may be easily made, before making the comparison. 
A few examples of number mappings are shown below: 


Decimal number 

Hex number 
before map 

Hex number 
after map 

-32768 

8000 

0000 

-32767 

8001 

0001 

-1 

FFFF 

7FFF 

0 

0000 

8000 

1 

0001 

8001 

32767 

7FFF 

FFFF 


Now, does this solve a problem or just create a new prob¬ 
lem? Consider the two expressions shown below, which appear 
to be equivalent: 


Expression 

New 

Old 

“Correct’ 


result 

result 

result 

(-4000 < 30000) 

True 

False 

True 

(-4000- 30000 <0) 

False 

False 

False 


Because of arithmetic overflow in the second expression, 
where “-4000 - 30000” is correctly interpreted as 31536 (not 
-34000), the expressions have different values. The new “im¬ 
proved” compare yields the differing results, depending upon 
how the expression is formed; whereas the old compare yields 
identical (but incorrect in one case) results no matter which 
way the expression is formed. Which attibute appeals to you 
more: correctness or apparent consistency? I vote for correct¬ 
ness in this case. 


Yours truly, Neoteric 

Harry B. Stewart 15816 San Benito Way 

Los Gatos, CA 95030 

Number 50 

445 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 




MORE ON LINKING WITH ERROR CORRECTION 

Dear DDJ : 

Many thanks for publishing Sylvan Rubin’s note on linking 
with error correction (DDJ #48). It is a fine example of a 
concise, lucid exposition of an improved technique applicable 
to a large class of programs and quite unrelated to any particu¬ 
lar processor. 

I should like to bring to your attention what I consider a 
small improvement to Mr. Rubin’s plan. Let the primary link 
field contain what Mr. Rubin calls the cross link: (predecessor 
address) XOR (successor address). By the method given in the 
italicized note this one field affects both forward and back¬ 
ward linking, if one knows where one has been. Then let the 
secondary link field contain the one’s complement of the pri¬ 
mary link. The one’s complement operation is chosen because 
of its sensitivity to stuck (stuck at one, stuck at zero) faults, 


which are among the most common machine faults. In the ab- 
sense of error the XOR of the two links will be all ones. 

Of course this scheme too has its limitations, While each 
zero in the XOR of the two links implies that one of them is 
wrong, each one may mean that they are both wrong. In that 
case, or when successive nodes have link errors one learns the 
value of backup copies and checkpointing. 

Incidentally, I cannot recommend the practice of “cor¬ 
recting” any portion of a dataset without notice to the user. 
A conscientious user needs to know about errors. That need 
is one of the reasons for writing exception reports. Errors rare¬ 
ly come as single spies; reporting those detected often helps 
detect others. If reporting errors makes the report too long 
then there are far too many errrors. 

Sincerely, Folly Fraction Farm 

J. A. MacLaughlin Clarksville, MD 21029 



Number 50 

446 


Dr. Dobb's Journal of Computer Calisthenics & Orthodontia 


Page 53 




Index 


This is an index to articles and programs, but some letters have also been indexed. References are of the 
form/ssne numberIpage numbers. Those in normal type are references to programs. References separated by a 
comma are connected in some way; those separated by a semicolon are completely distinct. Unless otherwise 
marked, a program is in assembly language. Except for author entries the processor type is marked or clear 
from the context. In general, a program can be found by author, processor type, and program type. 

The following table gives the correspondence between month/year and issue numbers. 


Vol 5—1980 


January 41 

February 42 

March 43 

April 44 

May 45 

June/July 46 

August 47 

September 48 

October 49 

November/December 50 


1802 

Cross-assembler [CP/M] 432 
Elf 122 

6800 

Cross-assembler [CP/M] 432 
Video-display program 439 

8080 

And CP/M 396 
And Z80 289; 394 
Fast fourier transform 164 
PILOT 82 

Registers in 47 bytes 173 
Small C compiler 176 
Translator system [to Z80] 216 
Unaltered 42 
Variations 173 

/Z80 indirect addressing 289; 394 

8813 

Polymorphic math functions 125 
9 or 16 bits? [Opcode design] 373 
9900 46; 108 


Acoustic coupler 351 
Addendum 

Newberry, S. 395 
Addition trick 125 
Addressing, indirect 
6502 333 

8080/Z80 289; 394 
Adler, R. 443 
ADM-3A 56 

Algorithms 130; 169; 207; 264; 350 

Allison, D. 73; 169; 207; 264; 350 

Alpha listing [H8] 104 

ALS-8 to CP/M conversion 24; 261 

Animal 350 

APPLE 

User interface 267 


APPLE II 

Program renumbering 67 
ROM byte-finder 243 
Arrays 

FORTH 242 
North Star 40 
Assemblers 

6800 + 1802 cross-assembler [CP/M] 432 
Table-driven 59; 171 
Z80, subroutines 159 

Bach, S. 243; 267 
Balcom, O. 39 

Barker. L. 42; 173; 205; 222; 268; 309 
BASIC 42 

Memory dump 260 
North Star 

Cross-reference 147; 151; 339; 382 
Patches 40; 171 
Statement generator 418 
String arrays 40 
Two-column display 259 
Poly 88 141 
Structured 201 
Tiny BASIC 201; 356 
Bender, A. 209 
Bentley, J. 130 
Bertollo, D. 348 

Binary to decimal conversion 73 

Bokelman, J. 42 

Borochoff, R. 126 

Bronstein, M. 122 

Brown, A. 443 

Brown, D. 67 

Bugs 

Small-C 83 
Sam 76's CP/M 83 

Byte 

ROM byte-finder [APPLE II] 248 


447 



C15;176;191 
C, small see Small C 
C, tiny see Tiny C 
Caesar, A. 309 
Cain, R. 176; 312 
Calculators 392 
Carter, J. 159; 267 
Cason, R. 127 
Cassette interface 13 
Caulkins, D. 230; 284 
CDOS 29; 394 
Colley, W. 432 
Compilers 

META II 169 
Small C 176; 312 
Conley, W. 352 
Conversions/converters 
ALS-8 to CP/M 24 
Binary to Decimal 73 
CP/M to UCSD PASCAL 367 
Core, G. 443 
Corrections 

Barker, L. 309 
Keay's table 41 
Parsons, R. 83 
Silverston, S. 172 
COSMAC 282 
CP/M II 

6800 + 1802 cross-assembler 432 
AL8-8 to CP/M file converter 24; 261 
And CDOS 29; 394 
Bug [SAM 76's CP/M] 83 
Game 406 

Hardcopy device driver programs 341 
Linking to Morrow's cassette interface 13 
OSI's CP/M 205 
PEN 34 
Software 4; 32 
Table-driven assembler 59 
Tiny interpreter [CP/M flavored C] 15 
To UCSD PASCAL file conversion 367 
Z80, 8080, and CP/M 396 
Crockett, T. 79 
Cross-assemblers 432 
Culleton, J. 125; 352 

Da Costa, F. 39 
Darling, M. 445 
Dea, R. 216 
Deane, R. 242; 434 
Design 

Algorithm 130 
Opcode 373 
Diablo 268 

Digital systems DDOS 127 
Displays 

6800 439 
North Star 259 
Documentation 426 
Double density system 339 
Douds, C. 127 
Drexler, K. 439 
Dump/Dumping 
BASIC 260 
Dye, J. 309; 444 


Ecklein, D. 394 
Elf 268 

Elizondo, F. 261 
Enhancements 
ADM-3A 56 


Entry points 267 
Equations, differential 392 
Errata of computer programming 244 
Errors 309; 349; 446 

Fiddes, L. 394 

File conversion see Conversion 
File transfer 375 
Flashwriter I 406 
Foreign language trainer 423 
Formatter, Tl 9900 46; 108 
FORTH 242; 434 
Frampton, H. 24 
Fusfeld, R. 168 

Gabrielson, M. 443 
Games, CP/M 406 
Gammell, J. 40 
Garcia, L. 418 
Gaugler, G. 345; 423 
Gelles, A. 85 
Gibson, T. 201 
Glitch 222 

Go: utility command under CP/M 11 
Gordon, H. 324; 373; 395 
Gramer, J. 125 
Graphics 

Flashwriter I [CP/M] 406 
Microprocessor-assisted system 79 
Guthery, S. 201 


Hallen, R. 34 
Hamlin, G. 79 

Hardcopy device driver programs [CP/M] 341 

Head, G. 222 

Heath 

H-8 104; 287 

H-14 201; 332; 395 
Hemminger, C. 309 
Hex keyboard 122 
Holtrichter, J. 339 
Horizon [ Interfacing H-14] 395 
Howell, J. 173; 266; 396 
Hudson, G. 259 
Hudson, L. 40; 382 
Hudson, R. 356 
Hughes, L. 375 


Improvements to: 

APPLE user interface 267 
CP/M and CDOS 394 
Zant's modular programming 266 
Indirect addressing [8080 & Z80] 289; 333 
Installation, Phantom-deselect 42 
Interface 

APPLE 67 

CP/M linked to Morrow's cassette interface 258 
H-14 to Horizon 395 
WH 14 printer to serial POR 443 
Interpreter 
LISP 268 
Tiny 15 


Jamieson, C. 83 
Johnson, D. 84 
Johnson, R. 171 
Johnson, S. 197 


448 



Keay, C. 41 
Kernigham, B. 191 
Keyboard, Hex 122 
Keyplus integrated utility 309 
Kildall, G. 2 
Knippenberg, H. 260 
Knuth, D. 88; 244 
Konopik, M. 234; 332 
Kruse, R. 272; 395 


Languages 
C 191 

Foreign 423 
META II 142 

Syntax-oriented compiler writing language 142 
Las Vegas super-slot 406 
Lesk, M. 191 
Lindenschmitt, G. 84 
LISP, interpreter 268 
Listing, H-8 104 
Logic 348 
Long, W. 371 
Loughman, W. 431 
Love program 345 
Lucky, R. 171; 309 
Lunsford, D. 172 

MacLaughlin, J. 446 

Martin, T. 443 

Math functions [8813] 125 

Mathematical typography 88 

Maurer, W. 333; 445 

MCALL-C 395 

McGaw, J. 125 

Memory dump [BASIC] 260 

Microchess 126 

Microsoft 222 

Miller, W. 13 

MITS DOS disk to disk copy routine 209 

Modular programming 266 

Monitors 

Elf tiny 268 
SYM-1 324 
Moore, F. 426 
Morrow, G. 13 
Moss, W. 104 
MOVIT431 

Multiple file transfer 375 
Munro, J. 443 


N-LOGS 400 
Naess, 0. 364 
Networks 226; 230; 257 
Newberry, S. 42; 125 
NIBASM 371 

North Star see BASIC; Horizon 
Number language [N-LOGS] 400 


Oliver, J. 39 
Opcode design 373 
OSI 205 

Output [COSMAC 1861] 282 

PASCAL 75; 127; 367 
Patches, North Star DOS 40 
PCNET 230; 284 
PEN 34 

Personal Computer Network see PCNET 


PET 127 
Pfafman, F. 42 
Phelan, C. 309 
Phillips, T. 443 
Phone dialer 84 
PI LOT 82 
Poly 88 BASIC 141 

Polymorphic 8813 math functions 125 

Price, G. H. 282 

Printer [H-14] 332 

Probes, logic 348 

Programs 

6800 439 
CP/M 406 

CP/M + CDOS compatability 29 
Love program 345 
User interface to APPLE-11 267 
Programmable calculator 392 
Programming 
BASIC 341 
C and tiny C 201 
C language 191 
CP/M 341 

Changing SPI to CP/M 32 
Errata 244 

Pastimes and pleasures 37; 285; 330 
Zant's modular programming 266 
Protocol 234 
Pugh, T. 234 
Purdin, T. 151 


Quick-key 418 
Quinn, C. 39 


Raeside, D. 121 

Reentrant formatter [TI9900] 108 
Register/storage [8080] 173 
Rennard, R. 444 
Ritchie, D. 191 

ROM byte-finder [APPLE II] 243 
Routines 

Alternate 445 

MITS DOS disk to disk copy 209 
Rowland, D. 269 
Rubin, S. 349 
Rules 309 

Runtime library [small C] 312 


S. D. board 257 
SAM 76 83 
Saunders, W. 395 
Schorre, D. 142 
Scientific computers 400 
Scott, J. 443 
Serial port 425 
Silverston, S. 172 
Simons, K. 400 
Sippy, L. 425 
Sjowall, T. 367 
Skjellum, A. 11; 289 
Small C 

8080 176 
Compiler 312 
Runtime library 312 
Small systems and monitors 324 
Smith, B. 267 
Smith, D. 443 
Smith, W. 240 


449 



Software 

CP/M 4; 445 
Software market 309 
Source-text area, extended 371 
SPI formatted programs 32 
Sprenkle, J. 279 

SR-52 programmable calculator 392 
Statement generator [North Star] 418 
Stewart, H. 445 
STOIC [North Star disk] 55 
Stowe, T. 287 

String arrays [North Star] 40 
Subroutines [Z-80 assembler] 159 
SYM-1 324 

Symbol table alpha listing [H8] 104 
Syntax-oriented compiler writing language 142 


Table driven assembler 59; 171 

Terminal parameters [PASCAL] 75 

Thomson, B. 223 

Tl 9900 45; 108 

Tiny BASIC see BASIC 

Tiny interpreter 15 

Tiny monitor [Elf] 268 

Tl PMX [Tl 9900] 46; 108 

Top-down 352; 443 

Translator [8080 to Z80] 216 

TRS-80 441 

Typography, mathematical 88 


UCSD PASCAL see PASCAL 
Utility 


Command under CP/M 11 
Multiple file transfer 375 


Van Buer, D. 59; 171; 268 
Video display RAM 439 
Vocabulary trainer 423 


Wakerley, J. 56 
Walters, N. 46; 108 
Warner, J. 29 
Wasserman, P. 172 
Wetherell, C. 37; 77; 285; 330 
Wexler, S. 309 
WH 14 printer 425 
Wilcox, R. 82 
Willoughby, S. 341 


X-Ref tool [North Star] 339 


Yakush, S. 392 


Z-80 

Assembler 159 
Circuit [H-8] 287 
Indirect addressing 289; 394 
Power increase 172 
Translator system from 8080 216 
Zant, R. 266 
Zeiger, M. 32 
ZX65 272; 395 


450 










5492-0 

$20.75 


00 

HAYDEN BOOK COMPANY, INC. 


Rochelle Park, New Jersey 


ISBN 0-8104-5492-0